main pico / sql / migrations / 20230707_add_projects_table.sql
Eric Bower  ·  2023-08-03
 1CREATE TABLE IF NOT EXISTS projects (
 2  id uuid NOT NULL DEFAULT uuid_generate_v4(),
 3  user_id uuid NOT NULL,
 4  name character varying(255) NOT NULL,
 5  project_dir text NOT NULL DEFAULT '',
 6  created_at timestamp without time zone NOT NULL DEFAULT NOW(),
 7  updated_at timestamp without time zone NOT NULL DEFAULT NOW(),
 8  CONSTRAINT projects_pkey PRIMARY KEY (id),
 9  CONSTRAINT unique_name_for_user UNIQUE (user_id, name),
10  CONSTRAINT fk_projects_app_users
11    FOREIGN KEY(user_id)
12  REFERENCES app_users(id)
13  ON DELETE CASCADE
14  ON UPDATE CASCADE
15);