2022-07-16 05:56:12 +00:00
|
|
|
CREATE TABLE accounts (
|
|
|
|
id serial PRIMARY KEY,
|
|
|
|
name varchar(100) NOT NULL,
|
|
|
|
pwhash varchar(100) NOT NULL,
|
2022-07-28 01:21:21 +00:00
|
|
|
god boolean NOT NULL DEFAULT FALSE
|
2022-07-16 05:56:12 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE sessions (
|
2022-07-28 02:05:48 +00:00
|
|
|
id varchar(100) PRIMARY KEY,
|
2022-07-28 01:21:21 +00:00
|
|
|
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',
|
2022-07-28 03:30:23 +00:00
|
|
|
exec perm NOT NULL DEFAULT 'world'
|
2022-07-28 01:21:21 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE objects (
|
|
|
|
id serial PRIMARY KEY,
|
|
|
|
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
|
2022-07-16 05:56:12 +00:00
|
|
|
);
|