(feat) Server is now running
Added DB schemas that are needed for the basics. Signed-off-by: Louis Hollingworth <louis@hollingworth.nl>
This commit is contained in:
parent
b330bea46d
commit
cf80d4b70d
11 changed files with 111 additions and 24 deletions
|
|
@ -6,11 +6,12 @@
|
|||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||
|
||||
CREATE TABLE users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
username VARCHAR NOT NULL,
|
||||
epost VARCHAR NOT NULL,
|
||||
pass VARCHAR NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW()
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
main_fedi TEXT
|
||||
);
|
||||
SELECT diesel_manage_updated_at('users');
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ CREATE TABLE posts (
|
|||
title VARCHAR NOT NULL,
|
||||
body TEXT NOT NULL,
|
||||
published BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
author INTEGER NOT NULL REFERENCES users(id),
|
||||
user_id UUID NOT NULL REFERENCES users(id),
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ CREATE TABLE blogs (
|
|||
name VARCHAR NOT NULL,
|
||||
description TEXT NOT NULL,
|
||||
url TEXT NOT NULL,
|
||||
owner INTEGER NOT NULL REFERENCES users(id),
|
||||
user_id UUID NOT NULL REFERENCES users(id),
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
|
|
|||
8
migrations/2023-10-17-164429_posts_add_blog_ref/down.sql
Normal file
8
migrations/2023-10-17-164429_posts_add_blog_ref/down.sql
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
-- SPDX-FileCopyrightText: 2023 Louis Hollingworth <louis@hollingworth.nl>
|
||||
--
|
||||
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
-- This file should undo anything in `up.sql`
|
||||
|
||||
ALTER TABLE posts
|
||||
DROP COLUMN blog_id;
|
||||
8
migrations/2023-10-17-164429_posts_add_blog_ref/up.sql
Normal file
8
migrations/2023-10-17-164429_posts_add_blog_ref/up.sql
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
-- SPDX-FileCopyrightText: 2023 Louis Hollingworth <louis@hollingworth.nl>
|
||||
--
|
||||
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
-- Your SQL goes here
|
||||
|
||||
ALTER TABLE posts
|
||||
ADD COLUMN blog_id INTEGER NOT NULL REFERENCES blogs(id);
|
||||
Loading…
Add table
Add a link
Reference in a new issue