2022-07-16 05:56:12 +00:00
|
|
|
CREATE TABLE accounts (
|
|
|
|
id serial PRIMARY KEY,
|
2022-08-01 15:15:18 +00:00
|
|
|
name varchar(100) NOT NULL UNIQUE,
|
2022-07-16 05:56:12 +00:00
|
|
|
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-08-01 16:00:43 +00:00
|
|
|
account integer REFERENCES accounts ON DELETE CASCADE
|
2022-07-28 01:21:21 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TYPE perm AS ENUM ('owner', 'world');
|
|
|
|
|
|
|
|
CREATE TABLE objects (
|
|
|
|
id serial PRIMARY KEY,
|
|
|
|
avatar boolean NOT NULL DEFAULT FALSE,
|
|
|
|
bedroom boolean NOT NULL DEFAULT FALSE,
|
|
|
|
data jsonb NOT NULL,
|
2022-12-23 06:03:37 +00:00
|
|
|
script text NOT NULL,
|
2022-07-28 01:21:21 +00:00
|
|
|
|
2022-08-01 16:00:43 +00:00
|
|
|
owner integer REFERENCES accounts ON DELETE RESTRICT
|
2022-07-28 01:21:21 +00:00
|
|
|
);
|
|
|
|
|
2022-08-01 16:00:43 +00:00
|
|
|
-- 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 'world',
|
|
|
|
|
|
|
|
object integer REFERENCES objects ON DELETE CASCADE
|
|
|
|
);
|
2022-07-28 01:21:21 +00:00
|
|
|
|
|
|
|
CREATE TABLE contains (
|
2022-08-01 16:00:43 +00:00
|
|
|
container integer REFERENCES objects ON DELETE RESTRICT,
|
|
|
|
contained integer REFERENCES objects ON DELETE CASCADE
|
2022-07-16 05:56:12 +00:00
|
|
|
);
|
2023-01-04 05:25:03 +00:00
|
|
|
|
|
|
|
CREATE TYPE heading AS ENUM ('north', 'south', 'east', 'west', 'above', 'below');
|
|
|
|
|
|
|
|
CREATE TABLE exits (
|
|
|
|
startroom integer REFERENCES objects ON DELETE CASCADE,
|
|
|
|
endroom integer REFERENCES objects ON DELETE CASCADE,
|
|
|
|
direction heading NOT NULL
|
|
|
|
);
|