Add db creation script

This commit is contained in:
2024-05-04 00:05:26 +02:00
parent 5ba718be26
commit 39ede643a2
4 changed files with 44 additions and 0 deletions

5
.pg_format Normal file
View File

@@ -0,0 +1,5 @@
tabs=1
function-case=1 #lowercase
keyword-case=1
type-case=1
no-space-function=1

View File

@@ -21,6 +21,8 @@ services:
- ./.env
volumes:
- db:/var/lib/postgresql/data
- ./sql/create.sql:/docker-entrypoint-initdb.d/init.sql
command: ["postgres", "-c", "log_statement=all"]
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 5s

View File

@@ -3,5 +3,6 @@
packages = with pkgs; [
go
wgo
pgformatter
];
}

36
sql/create.sql Normal file
View File

@@ -0,0 +1,36 @@
create table if not exists users(
id uuid not null primary key,
name text not null,
password varchar(100) not null,
email text not null
);
create table if not exists feeds(
id uuid not null primary key,
name text not null,
link text not null,
favicon_url text not null,
tags text[] not null,
submitter_id uuid not null references users(id)
);
create table if not exists entries(
id uuid not null primary key,
feed_id uuid not null references feed(id),
title text not null,
link text not null,
date timestamp with time zone not null,
content text not null,
author text
);
create table if not exists entries_users(
user_id uuid not null references users(id),
feed_id uuid not null references feeds(id),
is_read bool not null,
is_bookmarked bool not null,
is_read_later bool not null,
is_ignored bool not null,
constraint entries_users_pk primary keys(user_id, feed_id)
);