diff --git a/db/sql/01_schema.sql b/db/sql/01_schema.sql new file mode 100644 index 0000000..bb881ee --- /dev/null +++ b/db/sql/01_schema.sql @@ -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 +); \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 5473917..5a4b575 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: