From 8fd90a538592050f70b874c7de322fe2e2e2d588 Mon Sep 17 00:00:00 2001 From: vilmibm Date: Wed, 27 Jul 2022 20:21:21 -0500 Subject: [PATCH] add more to schema --- server/db/schema.sql | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/server/db/schema.sql b/server/db/schema.sql index afebafb..6705692 100644 --- a/server/db/schema.sql +++ b/server/db/schema.sql @@ -2,10 +2,38 @@ CREATE TABLE accounts ( id serial PRIMARY KEY, name varchar(100) NOT NULL, pwhash varchar(100) NOT NULL, - god boolean DEFAULT FALSE + god boolean NOT NULL DEFAULT FALSE ); CREATE TABLE sessions ( session_id varchar(100) PRIMARY KEY, - account integer references accounts(id) + account integer references accounts ON DELETE CASCADE +); + +CREATE TYPE perm AS ENUM ('owner', 'world'); + +-- owner = 1, world = 2 +CREATE TABLE permissions ( + id serial PRIMARY KEY, + read perm NOT NULL DEFAULT 'world', + write perm NOT NULL DEFAULT 'owner', + carry perm NOT NULL DEFAULT 'world', + exec perm NOT NULL DEFAULT 'owner' +); + +CREATE TABLE objects ( + id serial PRIMARY KEY, + shortname varchar(200) NOT NULL UNIQUE, + avatar boolean NOT NULL DEFAULT FALSE, + bedroom boolean NOT NULL DEFAULT FALSE, + data jsonb NOT NULL, + + perms integer references permissions, + owner integer references accounts +); + + +CREATE TABLE contains ( + container integer references objects ON DELETE RESTRICT, + contained integer references objects ON DELETE CASCADE );