 
 CREATE INDEX projects_user_idx
     ON projects("user");
+
+CREATE UNIQUE INDEX projects_shares_token_idx
+    ON project_shares(token);

    SELECT encode(digest(gen_random_bytes(128), 'sha256'), 'hex')
      INTO token;

    INSERT INTO projects_share (project, token)
    VALUES (NEW.id, token);

    RETURN NEW;

  name text NOT NULL
) WITH (OIDS=FALSE);

CREATE TABLE IF NOT EXISTS project_shares (
  id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
  project uuid REFERENCES projects(id),
  created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
  modified_at timestamptz NOT NULL DEFAULT clock_timestamp(),
  token text
