diff --git a/.pg_format b/.pg_format new file mode 100644 index 0000000..882260a --- /dev/null +++ b/.pg_format @@ -0,0 +1,5 @@ +tabs=1 +function-case=1 #lowercase +keyword-case=1 +type-case=1 +no-space-function=1 diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index db7e676..1e38f4d 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -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 diff --git a/shell.nix b/shell.nix index 12cda20..85e1042 100644 --- a/shell.nix +++ b/shell.nix @@ -3,5 +3,6 @@ packages = with pkgs; [ go wgo + pgformatter ]; } diff --git a/sql/create.sql b/sql/create.sql new file mode 100644 index 0000000..2639a83 --- /dev/null +++ b/sql/create.sql @@ -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) +); +