2018-02-17 21:30:19 +00:00
|
|
|
CREATE TABLE collections (
|
|
|
|
uuid TEXT NOT NULL PRIMARY KEY,
|
|
|
|
org_uuid TEXT NOT NULL REFERENCES organizations (uuid),
|
|
|
|
name TEXT NOT NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE organizations (
|
|
|
|
uuid TEXT NOT NULL PRIMARY KEY,
|
|
|
|
name TEXT NOT NULL,
|
|
|
|
billing_email TEXT NOT NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE users_collections (
|
|
|
|
user_uuid TEXT NOT NULL REFERENCES users (uuid),
|
|
|
|
collection_uuid TEXT NOT NULL REFERENCES collections (uuid),
|
|
|
|
PRIMARY KEY (user_uuid, collection_uuid)
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE users_organizations (
|
2018-04-24 20:01:55 +00:00
|
|
|
uuid TEXT NOT NULL PRIMARY KEY,
|
|
|
|
user_uuid TEXT NOT NULL REFERENCES users (uuid),
|
|
|
|
org_uuid TEXT NOT NULL REFERENCES organizations (uuid),
|
2018-02-17 21:30:19 +00:00
|
|
|
|
2018-04-24 20:01:55 +00:00
|
|
|
access_all BOOLEAN NOT NULL,
|
|
|
|
key TEXT NOT NULL,
|
|
|
|
status INTEGER NOT NULL,
|
|
|
|
type INTEGER NOT NULL,
|
2018-02-17 21:30:19 +00:00
|
|
|
|
2018-04-24 20:01:55 +00:00
|
|
|
UNIQUE (user_uuid, org_uuid)
|
2018-02-17 21:30:19 +00:00
|
|
|
);
|