add database schema and update docker-compose for initialization
This commit is contained in:
15
db/sql/01_schema.sql
Normal file
15
db/sql/01_schema.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
CREATE SCHEMA IF NOT EXISTS ethnograph;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS ethnograph.users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
username VARCHAR(255) UNIQUE NOT NULL,
|
||||
created_utc TIMESTAMP NOT NULL,
|
||||
karma INTEGER
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS ethnograph.posts (
|
||||
id SERIAL PRIMARY KEY,
|
||||
user_id INTEGER REFERENCES ethnograph.users(id),
|
||||
content TEXT NOT NULL,
|
||||
created_utc TIMESTAMP NOT NULL
|
||||
);
|
||||
@@ -1,7 +1,7 @@
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16
|
||||
container_name: ethnograph-postgres
|
||||
container_name: ethnograph-db
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_DB: ethnograph
|
||||
@@ -11,6 +11,7 @@ services:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- pgdata:/var/lib/postgresql/data
|
||||
- ./db/sql:/docker-entrypoint-initdb.d
|
||||
|
||||
volumes:
|
||||
pgdata:
|
||||
|
||||
Reference in New Issue
Block a user