gitea_pages/backend/migrations/2023-05-02-143642_init/up.sql
2023-05-21 18:58:10 +02:00

17 lines
530 B
SQL

CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE TABLE users (
id uuid PRIMARY KEY DEFAULT GEN_RANDOM_UUID(),
name text NOT NULL UNIQUE,
created_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamptz
);
CREATE TABLE repositories (
id uuid PRIMARY KEY DEFAULT GEN_RANDOM_UUID(),
user_id uuid NOT NULL REFERENCES users (id) ON DELETE CASCADE,
name text NOT NULL,
created_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamptz,
UNIQUE (user_id, name)
);