mabel/migrations/20230628223219_create-base.up.sql

48 lines
1.2 KiB
MySQL
Raw Normal View History

2023-06-30 13:02:20 +00:00
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; -- noqa: RF05
2023-06-29 12:08:59 +00:00
CREATE TABLE users (
2023-07-13 15:43:05 +00:00
id UUID PRIMARY KEY,
2023-06-30 13:02:20 +00:00
name VARCHAR UNIQUE NOT NULL,
email VARCHAR,
password VARCHAR,
display_name VARCHAR,
bio TEXT,
roles UUID [] NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now(),
modified_at TIMESTAMP,
deleted_at TIMESTAMP
2023-06-29 12:08:59 +00:00
);
CREATE TABLE sites (
2023-07-13 15:43:05 +00:00
id UUID PRIMARY KEY,
2023-06-30 13:02:20 +00:00
owner UUID NOT NULL REFERENCES users (id) ON DELETE CASCADE,
name VARCHAR UNIQUE NOT NULL,
title VARCHAR NOT NULL,
description TEXT,
created_at TIMESTAMP NOT NULL DEFAULT now(),
modified_at TIMESTAMP,
deleted_at TIMESTAMP
2023-06-29 12:08:59 +00:00
);
CREATE TABLE pages (
2023-07-13 15:43:05 +00:00
id UUID PRIMARY KEY,
2023-06-30 13:02:20 +00:00
site UUID NOT NULL REFERENCES sites (id) ON DELETE CASCADE,
author UUID REFERENCES users (id) ON DELETE SET NULL,
slug VARCHAR NOT NULL,
title VARCHAR NOT NULL,
description TEXT,
tags VARCHAR [] NOT NULL,
blocks JSONB NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now(),
modified_at TIMESTAMP,
deleted_at TIMESTAMP
2023-06-29 12:08:59 +00:00
);
CREATE TABLE audit (
2023-06-30 13:02:20 +00:00
actor UUID REFERENCES users (id) ON DELETE SET NULL,
object UUID,
action VARCHAR NOT NULL,
data JSONB,
created_at TIMESTAMP
);