diff options
Diffstat (limited to 'db/0-create.psql')
| -rwxr-xr-x | db/0-create.psql | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/db/0-create.psql b/db/0-create.psql new file mode 100755 index 0000000..39b4efd --- /dev/null +++ b/db/0-create.psql @@ -0,0 +1,28 @@ +CREATE TABLE users ( + user_id SERIAL PRIMARY KEY, + nick text UNIQUE NOT NULL, + hash text NOT NULL, + email text NOT NULL, + created_on timestamp NOT NULL DEFAULT now() +); + +CREATE TABLE rooms ( + room_id SERIAL PRIMARY KEY, + name text UNIQUE NOT NULL, + created_on timestamp NOT NULL +); + +CREATE TABLE messages ( + message_id SERIAL PRIMARY KEY, + user_id integer NOT NULL REFERENCES users, + room_id integer NOT NULL REFERENCES rooms, + content text NOT NULL, + created_on timestamp NOT NULL +); + +CREATE TABLE user_session ( + session_id bigint PRIMARY KEY, + user_id integer NOT NULL REFERENCES users, + id_address text NOT NULL, + ttl timestamp NOT NULL +);
\ No newline at end of file |
