2018-02-18 00:30:19 +03:00
|
|
|
CREATE TABLE collections (
|
2019-05-20 22:12:41 +03:00
|
|
|
uuid VARCHAR(40) NOT NULL PRIMARY KEY,
|
|
|
|
org_uuid VARCHAR(40) NOT NULL REFERENCES organizations (uuid),
|
2018-02-18 00:30:19 +03:00
|
|
|
name TEXT NOT NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE organizations (
|
2019-05-20 22:12:41 +03:00
|
|
|
uuid VARCHAR(40) NOT NULL PRIMARY KEY,
|
2018-02-18 00:30:19 +03:00
|
|
|
name TEXT NOT NULL,
|
|
|
|
billing_email TEXT NOT NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE users_collections (
|
2019-05-20 22:12:41 +03:00
|
|
|
user_uuid VARCHAR(40) NOT NULL REFERENCES users (uuid),
|
|
|
|
collection_uuid VARCHAR(40) NOT NULL REFERENCES collections (uuid),
|
2018-02-18 00:30:19 +03:00
|
|
|
PRIMARY KEY (user_uuid, collection_uuid)
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE users_organizations (
|
2019-05-20 22:12:41 +03:00
|
|
|
uuid VARCHAR(40) NOT NULL PRIMARY KEY,
|
|
|
|
user_uuid VARCHAR(40) NOT NULL REFERENCES users (uuid),
|
|
|
|
org_uuid VARCHAR(40) NOT NULL REFERENCES organizations (uuid),
|
2018-02-18 00:30:19 +03:00
|
|
|
|
2018-04-24 23:01:55 +03:00
|
|
|
access_all BOOLEAN NOT NULL,
|
2019-05-20 22:12:41 +03:00
|
|
|
akey TEXT NOT NULL,
|
2018-04-24 23:01:55 +03:00
|
|
|
status INTEGER NOT NULL,
|
2019-05-20 22:12:41 +03:00
|
|
|
atype INTEGER NOT NULL,
|
2018-02-18 00:30:19 +03:00
|
|
|
|
2018-04-24 23:01:55 +03:00
|
|
|
UNIQUE (user_uuid, org_uuid)
|
2018-02-18 00:30:19 +03:00
|
|
|
);
|