Skip to content

Instantly share code, notes, and snippets.

@jasonho-lynx
Last active October 1, 2021 04:00
Show Gist options
  • Save jasonho-lynx/11cb9e30e8314462519a4215e12c0a6c to your computer and use it in GitHub Desktop.
Save jasonho-lynx/11cb9e30e8314462519a4215e12c0a6c to your computer and use it in GitHub Desktop.
-- users table
CREATE TABLE public.users (
id UUID PRIMARY KEY,
email TEXT,
created_at TIMESTAMP WITH TIME ZONE
);
-- table to store files that users create
CREATE TABLE public.files (
id UUID DEFAULT uuid_generate_v4() PRIMARY KEY,
data TEXT
);
-- table that records file permissions that users have.
-- role_name can be Owner, Editor, or Viewer
CREATE TABLE public.file_access (
id UUID DEFAULT uuid_generate_v4() PRIMARY KEY,
file_id UUID REFERENCES public.files,
user_id UUID REFERENCES public.users,
role_name TEXT
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment