Implement more tables, add more page templates, initial working db example
This commit is contained in:
@@ -13,6 +13,6 @@ CREATE TABLE IF NOT EXISTS users (
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
last_login_at TIMESTAMPTZ,
|
||||
|
||||
-- u128 bitfield for permissions
|
||||
permissions NUMERIC(39,0) NOT NULL DEFAULT 0
|
||||
-- i64 bitfield for permissions
|
||||
permissions BIGINT NOT NULL DEFAULT 0
|
||||
)
|
||||
|
||||
@@ -5,15 +5,15 @@ CREATE TABLE IF NOT EXISTS clients (
|
||||
first_name TEXT NOT NULL,
|
||||
last_name TEXT NOT NULL,
|
||||
|
||||
date_of_birth DATE,
|
||||
phone_number TEXT,
|
||||
gov_id_number TEXT,
|
||||
house_number TEXT,
|
||||
address_line TEXT,
|
||||
city TEXT,
|
||||
state TEXT,
|
||||
postal_code TEXT,
|
||||
country TEXT,
|
||||
date_of_birth DATE NOT NULL,
|
||||
phone_number TEXT NOT NULL,
|
||||
gov_id_number TEXT NOT NULL,
|
||||
house_number TEXT NOT NULL,
|
||||
address_line TEXT NOT NULL,
|
||||
city TEXT NOT NULL,
|
||||
state TEXT NOT NULL,
|
||||
postal_code TEXT NOT NULL,
|
||||
country TEXT NOT NULL,
|
||||
|
||||
worker_user_id BIGINT,
|
||||
|
||||
|
||||
@@ -2,5 +2,6 @@ CREATE TABLE IF NOT EXISTS inventory_catalog (
|
||||
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT,
|
||||
code TEXT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS service_catalog;
|
||||
7
migrations/2026-01-13-095853-0000_service_catalog/up.sql
Normal file
7
migrations/2026-01-13-095853-0000_service_catalog/up.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE IF NOT EXISTS service_catalog (
|
||||
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT,
|
||||
value_string TEXT,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
)
|
||||
@@ -0,0 +1,2 @@
|
||||
DROP TABLE IF EXISTS assigned_services;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
CREATE TABLE IF NOT EXISTS assigned_services (
|
||||
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||
client_id BIGINT NOT NULL,
|
||||
catalog_id BIGINT NOT NULL,
|
||||
|
||||
CONSTRAINT fk_client_id FOREIGN KEY (client_id) REFERENCES clients(id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_catalog_id FOREIGN KEY (catalog_id) REFERENCES service_catalog(id) ON DELETE CASCADE
|
||||
)
|
||||
@@ -1,3 +1,11 @@
|
||||
CREATE TABLE IF NOT EXISTS tickets (
|
||||
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY
|
||||
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||
title TEXT NOT NULL,
|
||||
description TEXT,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
service_id BIGINT NOT NULL,
|
||||
created_by_user_id BIGINT NOT NULL,
|
||||
|
||||
CONSTRAINT fk_service_id FOREIGN KEY (service_id) REFERENCES assigned_services(id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_user_id FOREIGN KEY (created_by_user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
)
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
DROP TABLE IF EXISTS services;
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
CREATE TABLE IF NOT EXISTS services (
|
||||
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
client_id BIGINT NOT NULL,
|
||||
|
||||
CONSTRAINT fk_client_id FOREIGN KEY (client_id) REFERENCES clients(id) ON DELETE CASCADE
|
||||
)
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS ticket_comments;
|
||||
11
migrations/2026-01-13-190735-0000_ticket_comments/up.sql
Normal file
11
migrations/2026-01-13-190735-0000_ticket_comments/up.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE IF NOT EXISTS ticket_comments (
|
||||
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||
user_id BIGINT NOT NULL,
|
||||
ticket_id BIGINT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
modified_at TIMESTAMPTZ,
|
||||
content TEXT,
|
||||
|
||||
CONSTRAINT fk_user_id FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_ticket_id FOREIGN KEY (ticket_id) REFERENCES tickets(id) ON DELETE CASCADE
|
||||
)
|
||||
1
migrations/2026-01-13-191646-0000_attachments/down.sql
Normal file
1
migrations/2026-01-13-191646-0000_attachments/down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS attachments;
|
||||
9
migrations/2026-01-13-191646-0000_attachments/up.sql
Normal file
9
migrations/2026-01-13-191646-0000_attachments/up.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE IF NOT EXISTS attachments (
|
||||
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||
user_id BIGINT NOT NULL,
|
||||
comment_id BIGINT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
-- stored in file storage by attachment id
|
||||
CONSTRAINT fk_user_id FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_comment_id FOREIGN KEY (comment_id) REFERENCES ticket_comments(id) ON DELETE CASCADE
|
||||
)
|
||||
Reference in New Issue
Block a user