Skip to content

Instantly share code, notes, and snippets.

@cazzer
Last active August 2, 2018 05:59
Show Gist options
  • Save cazzer/657fbfc11af640b1bd882ab9419c256f to your computer and use it in GitHub Desktop.
Save cazzer/657fbfc11af640b1bd882ab9419c256f to your computer and use it in GitHub Desktop.
Table schema for the column version of RLS performant applications.
create table if not exists items (
id uuid default uuid_generate_v4() not null primary key,
value text,
acl_read uuid[] default array[]::uuid[],
acl_write uuid[] default array[]::uuid[]
);
-- e.g. ('f386...5e99', 'I row and therefore I am', {'eac6...f6c9'}, {'0fdc...947f'})
create index read_permissions_index on items using gin(acl_read);
create index write_permissions_index on items using gin(acl_write);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment