database
This commit is contained in:
parent
b47bac67ca
commit
dda1fca264
4 changed files with 95 additions and 0 deletions
30
Femto.Database/Migrations/20250517195735_InitBlog.sql
Normal file
30
Femto.Database/Migrations/20250517195735_InitBlog.sql
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
-- Migration: InitBlog
|
||||||
|
-- Created at: 17/05/2025 19:57:35
|
||||||
|
|
||||||
|
|
||||||
|
CREATE SCHEMA blog;
|
||||||
|
|
||||||
|
CREATE TABLE blog.author
|
||||||
|
(
|
||||||
|
id uuid PRIMARY KEY,
|
||||||
|
username varchar(64) UNIQUE NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE blog.post
|
||||||
|
(
|
||||||
|
id uuid PRIMARY KEY,
|
||||||
|
content text NOT NULL,
|
||||||
|
posted_on timestamptz NOT NULL DEFAULT now(),
|
||||||
|
author_id uuid NOT NULL REFERENCES blog.author (id) on DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE blog.post_media
|
||||||
|
(
|
||||||
|
id uuid PRIMARY KEY,
|
||||||
|
post_id uuid NOT NULL REFERENCES blog.post (id) ON DELETE CASCADE,
|
||||||
|
url text NOT NULL,
|
||||||
|
type varchar(64),
|
||||||
|
width int,
|
||||||
|
height int,
|
||||||
|
ordering int NOT NULL
|
||||||
|
);
|
12
Femto.Database/Migrations/20250517195747_InitMedia.sql
Normal file
12
Femto.Database/Migrations/20250517195747_InitMedia.sql
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
-- Migration: InitMedia
|
||||||
|
-- Created at: 17/05/2025 19:57:47
|
||||||
|
|
||||||
|
CREATE SCHEMA media;
|
||||||
|
|
||||||
|
CREATE TABLE media.saved_blob
|
||||||
|
(
|
||||||
|
id uuid PRIMARY KEY,
|
||||||
|
uploaded_on timestamp DEFAULT now() NOT NULL,
|
||||||
|
type varchar(64) NOT NULL,
|
||||||
|
size int
|
||||||
|
);
|
20
Femto.Database/Migrations/20250517195751_InitAuthn.sql
Normal file
20
Femto.Database/Migrations/20250517195751_InitAuthn.sql
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
-- Migration: InitAuthn
|
||||||
|
-- Created at: 17/05/2025 19:57:51
|
||||||
|
|
||||||
|
CREATE SCHEMA authn;
|
||||||
|
|
||||||
|
CREATE TABLE authn.user_identity
|
||||||
|
(
|
||||||
|
id uuid PRIMARY KEY,
|
||||||
|
username text NOT NULL UNIQUE,
|
||||||
|
|
||||||
|
password_hash bytea,
|
||||||
|
password_salt bytea
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE authn.user_session
|
||||||
|
(
|
||||||
|
id varchar(256) PRIMARY KEY,
|
||||||
|
user_id uuid NOT NULL REFERENCES authn.user_identity (id) ON DELETE CASCADE,
|
||||||
|
expires timestamptz NOT NULL
|
||||||
|
);
|
33
Femto.Database/Migrations/20250517195800_InitOutboxes.sql
Normal file
33
Femto.Database/Migrations/20250517195800_InitOutboxes.sql
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
-- Migration: InitOutboxes
|
||||||
|
-- Created at: 17/05/2025 19:58:00
|
||||||
|
|
||||||
|
CREATE TABLE blog.outbox
|
||||||
|
(
|
||||||
|
|
||||||
|
id uuid PRIMARY KEY,
|
||||||
|
event_type text NOT NULL,
|
||||||
|
aggregate_id uuid NOT NULL,
|
||||||
|
payload text NOT NULL,
|
||||||
|
created_at timestamp DEFAULT now() NOT NULL,
|
||||||
|
processed_at timestamp,
|
||||||
|
next_retry_at timestamp,
|
||||||
|
retry_count int DEFAULT 0 NOT NULL,
|
||||||
|
last_error text,
|
||||||
|
status int DEFAULT 0 NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE authn.outbox
|
||||||
|
(
|
||||||
|
|
||||||
|
id uuid PRIMARY KEY,
|
||||||
|
event_type text NOT NULL,
|
||||||
|
aggregate_id uuid NOT NULL,
|
||||||
|
payload text NOT NULL,
|
||||||
|
created_at timestamp DEFAULT now() NOT NULL,
|
||||||
|
processed_at timestamp,
|
||||||
|
next_retry_at timestamp,
|
||||||
|
retry_count int DEFAULT 0 NOT NULL,
|
||||||
|
last_error text,
|
||||||
|
status int DEFAULT 0 NOT NULL
|
||||||
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue