Skip to content

Instantly share code, notes, and snippets.

@cazzer
Last active August 2, 2018 05:59
Show Gist options
  • Save cazzer/a5deb6f889f4974a2e9b124bc7450dfe to your computer and use it in GitHub Desktop.
Save cazzer/a5deb6f889f4974a2e9b124bc7450dfe to your computer and use it in GitHub Desktop.
create table if not exists users_and_groups (
id uuid default uuid_generate_v4() not null primary key,
name text not null
);
-- e.g. ('eac6...f6c9', 'alice') or ('0fdc...947f', 'E Corp')
create table if not exists items (
id uuid default uuid_generate_v4() not null primary key,
value text,
public boolean default false
);
-- e.g. ('f386...5e99', 'I row and therefore I am', true)
create type permission_role as enum (
'read',
'write'
);
create table if not exists permissions (
item_id uuid references items(id),
user_or_group_id uuid references users_and_groups(id),
role permission_role default 'read' not null
);
-- e.g. ('f386...5e99', '0fdc...947f', 'write')
create index on permissions(item_id);
create index on permissions(user_or_group_id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment