created experimental database
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
docker-compose.yaml
|
||||||
|
database
|
||||||
3
Dockerfile
Normal file
3
Dockerfile
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
FROM postgres:alpine3.18
|
||||||
|
|
||||||
|
ADD init /docker-entrypoint-initdb.d
|
||||||
32
init/00_InitDB.sql
Normal file
32
init/00_InitDB.sql
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
DROP TABLE IF EXISTS Users;
|
||||||
|
DROP TABLE IF EXISTS Posts;
|
||||||
|
DROP TABLE IF EXISTS Reaction;
|
||||||
|
|
||||||
|
CREATE TABLE Users
|
||||||
|
(
|
||||||
|
id bigserial PRIMARY KEY,
|
||||||
|
username varchar(255) NOT NULL,
|
||||||
|
password varchar(255) NOT NULL,
|
||||||
|
deleted timestamp WITH TIME ZONE default NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE Posts
|
||||||
|
(
|
||||||
|
id bigserial PRIMARY KEY,
|
||||||
|
author bigserial REFERENCES Users(id) NOT NULL,
|
||||||
|
reference bigserial REFERENCES Posts(id) NOT NULL,
|
||||||
|
-- init with (select last_val from posts_id_seq)
|
||||||
|
title varchar(255) NOT NULL,
|
||||||
|
content varchar(1023) NOT NULL,
|
||||||
|
postDate timestamp WITH TIME ZONE NOT NULL DEFAULT now(),
|
||||||
|
postLocation Point NOT NULL,
|
||||||
|
deleted timestamp WITH TIME ZONE default NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE Reaction
|
||||||
|
(
|
||||||
|
id bigserial PRIMARY KEY,
|
||||||
|
post bigserial REFERENCES Posts(id) NOT NULL,
|
||||||
|
positive boolean DEFAULT NULL,
|
||||||
|
deleted timestamp WITH TIME ZONE default NULL
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user