From 7868024a88ff7a456014c8c489c098d1527a6db4 Mon Sep 17 00:00:00 2001 From: Dasa122 Date: Tue, 17 Nov 2026 14:55:02 +0100 Subject: [PATCH 01/13] feat(chronos): add the site_theme_schedule table --- .../migrations/0030_small_the_hunter.sql | 12 + .../migrations/meta/0030_snapshot.json | 4891 +++++++++++++++++ .../database/migrations/meta/_journal.json | 7 + apps/chronos/src/modules/theme/schema.ts | 25 +- 4 files changed, 4933 insertions(+), 2 deletions(-) create mode 100644 apps/chronos/src/database/migrations/0030_small_the_hunter.sql create mode 100644 apps/chronos/src/database/migrations/meta/0030_snapshot.json diff --git a/apps/chronos/src/database/migrations/0030_small_the_hunter.sql b/apps/chronos/src/database/migrations/0030_small_the_hunter.sql new file mode 100644 index 00000000..160d1883 --- /dev/null +++ b/apps/chronos/src/database/migrations/0030_small_the_hunter.sql @@ -0,0 +1,12 @@ +CREATE TABLE "site_theme_schedule" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "theme" text NOT NULL, + "start_month" integer NOT NULL, + "start_day" integer NOT NULL, + "end_month" integer NOT NULL, + "end_day" integer NOT NULL, + "updated_at" timestamp DEFAULT now() NOT NULL, + "updated_by" uuid +); +--> statement-breakpoint +ALTER TABLE "site_theme_schedule" ADD CONSTRAINT "site_theme_schedule_updated_by_user_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action; \ No newline at end of file diff --git a/apps/chronos/src/database/migrations/meta/0030_snapshot.json b/apps/chronos/src/database/migrations/meta/0030_snapshot.json new file mode 100644 index 00000000..c5f059d5 --- /dev/null +++ b/apps/chronos/src/database/migrations/meta/0030_snapshot.json @@ -0,0 +1,4891 @@ +{ + "id": "e0836727-e650-4d0d-93b3-b761814869fe", + "prevId": "b8f94643-c8b1-4154-931a-b1bccd10d7f9", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.apikey": { + "name": "apikey", + "schema": "", + "columns": { + "config_id": { + "name": "config_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'default'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "pg_catalog.gen_random_uuid()" + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_refill_at": { + "name": "last_refill_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_request": { + "name": "last_request", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "permissions": { + "name": "permissions", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "prefix": { + "name": "prefix", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rate_limit_enabled": { + "name": "rate_limit_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "rate_limit_max": { + "name": "rate_limit_max", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "rate_limit_time_window": { + "name": "rate_limit_time_window", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "reference_id": { + "name": "reference_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refill_amount": { + "name": "refill_amount", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "refill_interval": { + "name": "refill_interval", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "remaining": { + "name": "remaining", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "request_count": { + "name": "request_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "start": { + "name": "start", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "apikey_config_id_idx": { + "name": "apikey_config_id_idx", + "columns": [ + { + "expression": "config_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "apikey_key_idx": { + "name": "apikey_key_idx", + "columns": [ + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "apikey_reference_id_idx": { + "name": "apikey_reference_id_idx", + "columns": [ + { + "expression": "reference_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.account": { + "name": "account", + "schema": "", + "columns": { + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "pg_catalog.gen_random_uuid()" + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "account_userId_idx": { + "name": "account_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "account_user_id_user_id_fk": { + "name": "account_user_id_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.session": { + "name": "session", + "schema": "", + "columns": { + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "pg_catalog.gen_random_uuid()" + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "session_userId_idx": { + "name": "session_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user": { + "name": "user", + "schema": "", + "columns": { + "cohort_id": { + "name": "cohort_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "pg_catalog.gen_random_uuid()" + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "nickname": { + "name": "nickname", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "roles": { + "name": "roles", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{\"user\"}'" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.verification": { + "name": "verification", + "schema": "", + "columns": { + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "pg_catalog.gen_random_uuid()" + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "verification_identifier_idx": { + "name": "verification_identifier_idx", + "columns": [ + { + "expression": "identifier", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.role": { + "name": "role", + "schema": "", + "columns": { + "can": { + "name": "can", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "role_name_unique": { + "name": "role_name_unique", + "nullsNotDistinct": false, + "columns": [ + "name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.activity_log": { + "name": "activity_log", + "schema": "", + "columns": { + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "activity_log_actor_id_idx": { + "name": "activity_log_actor_id_idx", + "columns": [ + { + "expression": "actor_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "activity_log_created_at_idx": { + "name": "activity_log_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "activity_log_entity_type_idx": { + "name": "activity_log_entity_type_idx", + "columns": [ + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "activity_log_actor_id_user_id_fk": { + "name": "activity_log_actor_id_user_id_fk", + "tableFrom": "activity_log", + "tableTo": "user", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.bug_report": { + "name": "bug_report", + "schema": "", + "columns": { + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "page": { + "name": "page", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reporter_email": { + "name": "reporter_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reporter_id": { + "name": "reporter_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "bug_report_status_idx": { + "name": "bug_report_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "bug_report_reporter_id_user_id_fk": { + "name": "bug_report_reporter_id_user_id_fk", + "tableFrom": "bug_report", + "tableTo": "user", + "columnsFrom": [ + "reporter_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.audit_log": { + "name": "audit_log", + "schema": "", + "columns": { + "button_pressed": { + "name": "button_pressed", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "card_data": { + "name": "card_data", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "card_id": { + "name": "card_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "device_id": { + "name": "device_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "result": { + "name": "result", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "audit_log_card_id_card_id_fk": { + "name": "audit_log_card_id_card_id_fk", + "tableFrom": "audit_log", + "tableTo": "card", + "columnsFrom": [ + "card_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "audit_log_device_id_device_id_fk": { + "name": "audit_log_device_id_device_id_fk", + "tableFrom": "audit_log", + "tableTo": "device", + "columnsFrom": [ + "device_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "audit_log_user_id_user_id_fk": { + "name": "audit_log_user_id_user_id_fk", + "tableFrom": "audit_log", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.card": { + "name": "card", + "schema": "", + "columns": { + "card_uid": { + "name": "card_uid", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "frozen": { + "name": "frozen", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "card_user_id_user_id_fk": { + "name": "card_user_id_user_id_fk", + "tableFrom": "card", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "card_card_uid_unique": { + "name": "card_card_uid_unique", + "nullsNotDistinct": false, + "columns": [ + "card_uid" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.card_device": { + "name": "card_device", + "schema": "", + "columns": { + "card_id": { + "name": "card_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "device_id": { + "name": "device_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "card_device_card_id_idx": { + "name": "card_device_card_id_idx", + "columns": [ + { + "expression": "card_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "card_device_device_id_idx": { + "name": "card_device_device_id_idx", + "columns": [ + { + "expression": "device_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "card_device_card_id_card_id_fk": { + "name": "card_device_card_id_card_id_fk", + "tableFrom": "card_device", + "tableTo": "card", + "columnsFrom": [ + "card_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "card_device_device_id_device_id_fk": { + "name": "card_device_device_id_device_id_fk", + "tableFrom": "card_device", + "tableTo": "device", + "columnsFrom": [ + "device_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "card_device_card_id_device_id_pk": { + "name": "card_device_card_id_device_id_pk", + "columns": [ + "card_id", + "device_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.device": { + "name": "device", + "schema": "", + "columns": { + "api_token": { + "name": "api_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "last_reset_reason": { + "name": "last_reset_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "device_api_token_unique": { + "name": "device_api_token_unique", + "nullsNotDistinct": false, + "columns": [ + "api_token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.device_health": { + "name": "device_health", + "schema": "", + "columns": { + "device_id": { + "name": "device_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "device_meta": { + "name": "device_meta", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "device_health_device_id_device_id_fk": { + "name": "device_health_device_id_device_id_fk", + "tableFrom": "device_health", + "tableTo": "device", + "columnsFrom": [ + "device_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.kiosk": { + "name": "kiosk", + "schema": "", + "columns": { + "app_version": { + "name": "app_version", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "config": { + "name": "config", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_seen_ip": { + "name": "last_seen_ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "machine_id": { + "name": "machine_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "kiosk_machine_id_unique": { + "name": "kiosk_machine_id_unique", + "nullsNotDistinct": false, + "columns": [ + "machine_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.navigator_corridor": { + "name": "navigator_corridor", + "schema": "", + "columns": { + "barrier_free": { + "name": "barrier_free", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "building_id": { + "name": "building_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "is_outdoor": { + "name": "is_outdoor", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "storey": { + "name": "storey", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "x1": { + "name": "x1", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "x2": { + "name": "x2", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "y1": { + "name": "y1", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "y2": { + "name": "y2", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "navigator_corridor_building_id_idx": { + "name": "navigator_corridor_building_id_idx", + "columns": [ + { + "expression": "building_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "navigator_corridor_building_id_building_id_fk": { + "name": "navigator_corridor_building_id_building_id_fk", + "tableFrom": "navigator_corridor", + "tableTo": "building", + "columnsFrom": [ + "building_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.navigator_lift": { + "name": "navigator_lift", + "schema": "", + "columns": { + "building_id": { + "name": "building_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "max_storey": { + "name": "max_storey", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "min_storey": { + "name": "min_storey", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "navigator_lift_building_id_idx": { + "name": "navigator_lift_building_id_idx", + "columns": [ + { + "expression": "building_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "navigator_lift_building_id_building_id_fk": { + "name": "navigator_lift_building_id_building_id_fk", + "tableFrom": "navigator_lift", + "tableTo": "building", + "columnsFrom": [ + "building_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.navigator_stair": { + "name": "navigator_stair", + "schema": "", + "columns": { + "building_id": { + "name": "building_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "max_storey": { + "name": "max_storey", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "min_storey": { + "name": "min_storey", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rotation": { + "name": "rotation", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "navigator_stair_building_id_idx": { + "name": "navigator_stair_building_id_idx", + "columns": [ + { + "expression": "building_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "navigator_stair_building_id_building_id_fk": { + "name": "navigator_stair_building_id_building_id_fk", + "tableFrom": "navigator_stair", + "tableTo": "building", + "columnsFrom": [ + "building_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.navigator_translation": { + "name": "navigator_translation", + "schema": "", + "columns": { + "lang_key": { + "name": "lang_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text_key": { + "name": "text_key", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "navigator_translation_lang_key_text_key_pk": { + "name": "navigator_translation_lang_key_text_key_pk", + "columns": [ + "lang_key", + "text_key" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.announcement": { + "name": "announcement", + "schema": "", + "columns": { + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "highlighted": { + "name": "highlighted", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "image_byte_size": { + "name": "image_byte_size", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "image_content_type": { + "name": "image_content_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "image_key": { + "name": "image_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "image_updated_at": { + "name": "image_updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "kiosk_only": { + "name": "kiosk_only", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "valid_from": { + "name": "valid_from", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "valid_until": { + "name": "valid_until", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "announcement_author_id_user_id_fk": { + "name": "announcement_author_id_user_id_fk", + "tableFrom": "announcement", + "tableTo": "user", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "announcement_image_complete": { + "name": "announcement_image_complete", + "value": "(\"announcement\".\"image_key\" IS NULL) = (\"announcement\".\"image_content_type\" IS NULL)\n AND (\"announcement\".\"image_key\" IS NULL) = (\"announcement\".\"image_byte_size\" IS NULL)\n AND (\"announcement\".\"image_key\" IS NULL) = (\"announcement\".\"image_updated_at\" IS NULL)" + } + }, + "isRLSEnabled": false + }, + "public.announcement_cohort_mtm": { + "name": "announcement_cohort_mtm", + "schema": "", + "columns": { + "announcement_id": { + "name": "announcement_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cohort_id": { + "name": "cohort_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "announcement_cohort_mtm_announcement_id_idx": { + "name": "announcement_cohort_mtm_announcement_id_idx", + "columns": [ + { + "expression": "announcement_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "announcement_cohort_mtm_cohort_id_idx": { + "name": "announcement_cohort_mtm_cohort_id_idx", + "columns": [ + { + "expression": "cohort_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "announcement_cohort_mtm_announcement_id_announcement_id_fk": { + "name": "announcement_cohort_mtm_announcement_id_announcement_id_fk", + "tableFrom": "announcement_cohort_mtm", + "tableTo": "announcement", + "columnsFrom": [ + "announcement_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "announcement_cohort_mtm_cohort_id_cohort_id_fk": { + "name": "announcement_cohort_mtm_cohort_id_cohort_id_fk", + "tableFrom": "announcement_cohort_mtm", + "tableTo": "cohort", + "columnsFrom": [ + "cohort_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "announcement_cohort_mtm_announcement_id_cohort_id_pk": { + "name": "announcement_cohort_mtm_announcement_id_cohort_id_pk", + "columns": [ + "announcement_id", + "cohort_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.announcement_kiosk_mtm": { + "name": "announcement_kiosk_mtm", + "schema": "", + "columns": { + "announcement_id": { + "name": "announcement_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kiosk_id": { + "name": "kiosk_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "announcement_kiosk_mtm_announcement_id_idx": { + "name": "announcement_kiosk_mtm_announcement_id_idx", + "columns": [ + { + "expression": "announcement_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "announcement_kiosk_mtm_kiosk_id_idx": { + "name": "announcement_kiosk_mtm_kiosk_id_idx", + "columns": [ + { + "expression": "kiosk_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "announcement_kiosk_mtm_announcement_id_announcement_id_fk": { + "name": "announcement_kiosk_mtm_announcement_id_announcement_id_fk", + "tableFrom": "announcement_kiosk_mtm", + "tableTo": "announcement", + "columnsFrom": [ + "announcement_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "announcement_kiosk_mtm_kiosk_id_kiosk_id_fk": { + "name": "announcement_kiosk_mtm_kiosk_id_kiosk_id_fk", + "tableFrom": "announcement_kiosk_mtm", + "tableTo": "kiosk", + "columnsFrom": [ + "kiosk_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "announcement_kiosk_mtm_announcement_id_kiosk_id_pk": { + "name": "announcement_kiosk_mtm_announcement_id_kiosk_id_pk", + "columns": [ + "announcement_id", + "kiosk_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.blog_post": { + "name": "blog_post", + "schema": "", + "columns": { + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "published_at": { + "name": "published_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "blog_post_author_id_user_id_fk": { + "name": "blog_post_author_id_user_id_fk", + "tableFrom": "blog_post", + "tableTo": "user", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "blog_post_slug_unique": { + "name": "blog_post_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.system_message": { + "name": "system_message", + "schema": "", + "columns": { + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "valid_from": { + "name": "valid_from", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "valid_until": { + "name": "valid_until", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "system_message_author_id_user_id_fk": { + "name": "system_message_author_id_user_id_fk", + "tableFrom": "system_message", + "tableTo": "user", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.system_message_cohort_mtm": { + "name": "system_message_cohort_mtm", + "schema": "", + "columns": { + "cohort_id": { + "name": "cohort_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "system_message_id": { + "name": "system_message_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "system_message_cohort_mtm_system_message_id_idx": { + "name": "system_message_cohort_mtm_system_message_id_idx", + "columns": [ + { + "expression": "system_message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "system_message_cohort_mtm_cohort_id_idx": { + "name": "system_message_cohort_mtm_cohort_id_idx", + "columns": [ + { + "expression": "cohort_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "system_message_cohort_mtm_cohort_id_cohort_id_fk": { + "name": "system_message_cohort_mtm_cohort_id_cohort_id_fk", + "tableFrom": "system_message_cohort_mtm", + "tableTo": "cohort", + "columnsFrom": [ + "cohort_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "system_message_cohort_mtm_system_message_id_system_message_id_fk": { + "name": "system_message_cohort_mtm_system_message_id_system_message_id_fk", + "tableFrom": "system_message_cohort_mtm", + "tableTo": "system_message", + "columnsFrom": [ + "system_message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "system_message_cohort_mtm_system_message_id_cohort_id_pk": { + "name": "system_message_cohort_mtm_system_message_id_cohort_id_pk", + "columns": [ + "system_message_id", + "cohort_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.fcm_token": { + "name": "fcm_token", + "schema": "", + "columns": { + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "device_info": { + "name": "device_info", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "fcm_token_user_id_token_unique": { + "name": "fcm_token_user_id_token_unique", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "fcm_token_user_id_user_id_fk": { + "name": "fcm_token_user_id_user_id_fk", + "tableFrom": "fcm_token", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notification": { + "name": "notification", + "schema": "", + "columns": { + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "read": { + "name": "read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "notification_user_id_created_at_idx": { + "name": "notification_user_id_created_at_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": false, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_created_at_idx": { + "name": "notification_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notification_user_id_user_id_fk": { + "name": "notification_user_id_user_id_fk", + "tableFrom": "notification", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_preferences": { + "name": "user_preferences", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "color_scheme": { + "name": "color_scheme", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'default'" + }, + "language": { + "name": "language", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'hu'" + }, + "notification_preferences": { + "name": "notification_preferences", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"announcement\":true,\"blogPost\":false,\"channelsEnabled\":true,\"doorlockCardUsed\":false,\"movedLesson\":true,\"substitution\":true,\"systemMessage\":true}'::jsonb" + }, + "site_theme_acknowledged": { + "name": "site_theme_acknowledged", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "site_theme_enabled": { + "name": "site_theme_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "theme": { + "name": "theme", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'system'" + }, + "timetable_class_colors": { + "name": "timetable_class_colors", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "timetable_group_display": { + "name": "timetable_group_display", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'highlight'" + }, + "timetable_view": { + "name": "timetable_view", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'class'" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_preferences_user_id_user_id_fk": { + "name": "user_preferences_user_id_user_id_fk", + "tableFrom": "user_preferences", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_preferences_user_id_unique": { + "name": "user_preferences_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.site_theme": { + "name": "site_theme", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "default": "'default'" + }, + "theme": { + "name": "theme", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'default'" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "site_theme_updated_by_user_id_fk": { + "name": "site_theme_updated_by_user_id_fk", + "tableFrom": "site_theme", + "tableTo": "user", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.site_theme_schedule": { + "name": "site_theme_schedule", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "theme": { + "name": "theme", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start_month": { + "name": "start_month", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "start_day": { + "name": "start_day", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "end_month": { + "name": "end_month", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "end_day": { + "name": "end_day", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "site_theme_schedule_updated_by_user_id_fk": { + "name": "site_theme_schedule_updated_by_user_id_fk", + "tableFrom": "site_theme_schedule", + "tableTo": "user", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.building": { + "name": "building", + "schema": "", + "columns": { + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "mapped": { + "name": "mapped", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.classroom": { + "name": "classroom", + "schema": "", + "columns": { + "building_id": { + "name": "building_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "capacity": { + "name": "capacity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "mapped": { + "name": "mapped", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rotation": { + "name": "rotation", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "short": { + "name": "short", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "size_x": { + "name": "size_x", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 6 + }, + "size_y": { + "name": "size_y", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 6 + }, + "size_z": { + "name": "size_z", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 3 + }, + "storey": { + "name": "storey", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "type_id": { + "name": "type_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "classroom_building_id_idx": { + "name": "classroom_building_id_idx", + "columns": [ + { + "expression": "building_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "classroom_type_id_idx": { + "name": "classroom_type_id_idx", + "columns": [ + { + "expression": "type_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "classroom_building_id_building_id_fk": { + "name": "classroom_building_id_building_id_fk", + "tableFrom": "classroom", + "tableTo": "building", + "columnsFrom": [ + "building_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "classroom_type_id_classroom_type_id_fk": { + "name": "classroom_type_id_classroom_type_id_fk", + "tableFrom": "classroom", + "tableTo": "classroom_type", + "columnsFrom": [ + "type_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.classroom_type": { + "name": "classroom_type", + "schema": "", + "columns": { + "colorhex": { + "name": "colorhex", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.cohort": { + "name": "cohort", + "schema": "", + "columns": { + "classroom_ids": { + "name": "classroom_ids", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "short": { + "name": "short", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "teacher_id": { + "name": "teacher_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "timetable_id": { + "name": "timetable_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "cohort_teacher_id_teacher_id_fk": { + "name": "cohort_teacher_id_teacher_id_fk", + "tableFrom": "cohort", + "tableTo": "teacher", + "columnsFrom": [ + "teacher_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cohort_timetable_id_timetable_id_fk": { + "name": "cohort_timetable_id_timetable_id_fk", + "tableFrom": "cohort", + "tableTo": "timetable", + "columnsFrom": [ + "timetable_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.group": { + "name": "group", + "schema": "", + "columns": { + "cohort_id": { + "name": "cohort_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "division_tag": { + "name": "division_tag", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "entire_class": { + "name": "entire_class", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "student_count": { + "name": "student_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "teacher_id": { + "name": "teacher_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "group_cohort_id_cohort_id_fk": { + "name": "group_cohort_id_cohort_id_fk", + "tableFrom": "group", + "tableTo": "cohort", + "columnsFrom": [ + "cohort_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "group_teacher_id_teacher_id_fk": { + "name": "group_teacher_id_teacher_id_fk", + "tableFrom": "group", + "tableTo": "teacher", + "columnsFrom": [ + "teacher_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.cohort_timetable_mtm": { + "name": "cohort_timetable_mtm", + "schema": "", + "columns": { + "cohort_id": { + "name": "cohort_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "timetable_id": { + "name": "timetable_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "cohort_timetable_mtm_timetable_id_idx": { + "name": "cohort_timetable_mtm_timetable_id_idx", + "columns": [ + { + "expression": "timetable_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cohort_timetable_mtm_cohort_id_cohort_id_fk": { + "name": "cohort_timetable_mtm_cohort_id_cohort_id_fk", + "tableFrom": "cohort_timetable_mtm", + "tableTo": "cohort", + "columnsFrom": [ + "cohort_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cohort_timetable_mtm_timetable_id_timetable_id_fk": { + "name": "cohort_timetable_mtm_timetable_id_timetable_id_fk", + "tableFrom": "cohort_timetable_mtm", + "tableTo": "timetable", + "columnsFrom": [ + "timetable_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "cohort_timetable_mtm_cohort_id_timetable_id_pk": { + "name": "cohort_timetable_mtm_cohort_id_timetable_id_pk", + "columns": [ + "cohort_id", + "timetable_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.day_definition": { + "name": "day_definition", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "days": { + "name": "days", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "short": { + "name": "short", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.lesson": { + "name": "lesson", + "schema": "", + "columns": { + "classroom_ids": { + "name": "classroom_ids", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "day_definition_id": { + "name": "day_definition_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "group_ids": { + "name": "group_ids", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "period_id": { + "name": "period_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "periods_per_week": { + "name": "periods_per_week", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "subject_id": { + "name": "subject_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "teacher_ids": { + "name": "teacher_ids", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "term_definition_id": { + "name": "term_definition_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "timetable_id": { + "name": "timetable_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "weeks_definition_id": { + "name": "weeks_definition_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "lesson_day_definition_id_day_definition_id_fk": { + "name": "lesson_day_definition_id_day_definition_id_fk", + "tableFrom": "lesson", + "tableTo": "day_definition", + "columnsFrom": [ + "day_definition_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "lesson_period_id_period_id_fk": { + "name": "lesson_period_id_period_id_fk", + "tableFrom": "lesson", + "tableTo": "period", + "columnsFrom": [ + "period_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "lesson_subject_id_subject_id_fk": { + "name": "lesson_subject_id_subject_id_fk", + "tableFrom": "lesson", + "tableTo": "subject", + "columnsFrom": [ + "subject_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "lesson_term_definition_id_term_definition_id_fk": { + "name": "lesson_term_definition_id_term_definition_id_fk", + "tableFrom": "lesson", + "tableTo": "term_definition", + "columnsFrom": [ + "term_definition_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "lesson_timetable_id_timetable_id_fk": { + "name": "lesson_timetable_id_timetable_id_fk", + "tableFrom": "lesson", + "tableTo": "timetable", + "columnsFrom": [ + "timetable_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "lesson_weeks_definition_id_week_definition_id_fk": { + "name": "lesson_weeks_definition_id_week_definition_id_fk", + "tableFrom": "lesson", + "tableTo": "week_definition", + "columnsFrom": [ + "weeks_definition_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.lesson_cohort_mtm": { + "name": "lesson_cohort_mtm", + "schema": "", + "columns": { + "cohort_id": { + "name": "cohort_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "lesson_id": { + "name": "lesson_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "lesson_cohort_mtm_cohort_id_cohort_id_fk": { + "name": "lesson_cohort_mtm_cohort_id_cohort_id_fk", + "tableFrom": "lesson_cohort_mtm", + "tableTo": "cohort", + "columnsFrom": [ + "cohort_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "lesson_cohort_mtm_lesson_id_lesson_id_fk": { + "name": "lesson_cohort_mtm_lesson_id_lesson_id_fk", + "tableFrom": "lesson_cohort_mtm", + "tableTo": "lesson", + "columnsFrom": [ + "lesson_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "lesson_cohort_mtm_lesson_id_cohort_id_pk": { + "name": "lesson_cohort_mtm_lesson_id_cohort_id_pk", + "columns": [ + "lesson_id", + "cohort_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.moved_lesson": { + "name": "moved_lesson", + "schema": "", + "columns": { + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "manual_cohort_ids": { + "name": "manual_cohort_ids", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "manual_source_room_id": { + "name": "manual_source_room_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "manual_subject_id": { + "name": "manual_subject_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "manual_teacher_ids": { + "name": "manual_teacher_ids", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "room": { + "name": "room", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "starting_day": { + "name": "starting_day", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "starting_period": { + "name": "starting_period", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "moved_lesson_manual_source_room_id_classroom_id_fk": { + "name": "moved_lesson_manual_source_room_id_classroom_id_fk", + "tableFrom": "moved_lesson", + "tableTo": "classroom", + "columnsFrom": [ + "manual_source_room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "moved_lesson_manual_subject_id_subject_id_fk": { + "name": "moved_lesson_manual_subject_id_subject_id_fk", + "tableFrom": "moved_lesson", + "tableTo": "subject", + "columnsFrom": [ + "manual_subject_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "moved_lesson_room_classroom_id_fk": { + "name": "moved_lesson_room_classroom_id_fk", + "tableFrom": "moved_lesson", + "tableTo": "classroom", + "columnsFrom": [ + "room" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "moved_lesson_starting_day_day_definition_id_fk": { + "name": "moved_lesson_starting_day_day_definition_id_fk", + "tableFrom": "moved_lesson", + "tableTo": "day_definition", + "columnsFrom": [ + "starting_day" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "moved_lesson_starting_period_period_id_fk": { + "name": "moved_lesson_starting_period_period_id_fk", + "tableFrom": "moved_lesson", + "tableTo": "period", + "columnsFrom": [ + "starting_period" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.moved_lesson_lesson_mtm": { + "name": "moved_lesson_lesson_mtm", + "schema": "", + "columns": { + "lesson_id": { + "name": "lesson_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "moved_lesson_id": { + "name": "moved_lesson_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "moved_lesson_lesson_mtm_lesson_id_lesson_id_fk": { + "name": "moved_lesson_lesson_mtm_lesson_id_lesson_id_fk", + "tableFrom": "moved_lesson_lesson_mtm", + "tableTo": "lesson", + "columnsFrom": [ + "lesson_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "moved_lesson_lesson_mtm_moved_lesson_id_moved_lesson_id_fk": { + "name": "moved_lesson_lesson_mtm_moved_lesson_id_moved_lesson_id_fk", + "tableFrom": "moved_lesson_lesson_mtm", + "tableTo": "moved_lesson", + "columnsFrom": [ + "moved_lesson_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "moved_lesson_lesson_mtm_lesson_id_moved_lesson_id_pk": { + "name": "moved_lesson_lesson_mtm_lesson_id_moved_lesson_id_pk", + "columns": [ + "lesson_id", + "moved_lesson_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.period": { + "name": "period", + "schema": "", + "columns": { + "end_time": { + "name": "end_time", + "type": "time", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "period": { + "name": "period", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "start_time": { + "name": "start_time", + "type": "time", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.subject": { + "name": "subject", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "short": { + "name": "short", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.substitution": { + "name": "substitution", + "schema": "", + "columns": { + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "substituter": { + "name": "substituter", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "substitution_substituter_teacher_id_fk": { + "name": "substitution_substituter_teacher_id_fk", + "tableFrom": "substitution", + "tableTo": "teacher", + "columnsFrom": [ + "substituter" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.substitution_lesson_mtm": { + "name": "substitution_lesson_mtm", + "schema": "", + "columns": { + "lesson_id": { + "name": "lesson_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "substitution_id": { + "name": "substitution_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "substitution_lesson_mtm_lesson_id_lesson_id_fk": { + "name": "substitution_lesson_mtm_lesson_id_lesson_id_fk", + "tableFrom": "substitution_lesson_mtm", + "tableTo": "lesson", + "columnsFrom": [ + "lesson_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "substitution_lesson_mtm_substitution_id_substitution_id_fk": { + "name": "substitution_lesson_mtm_substitution_id_substitution_id_fk", + "tableFrom": "substitution_lesson_mtm", + "tableTo": "substitution", + "columnsFrom": [ + "substitution_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "substitution_lesson_mtm_lesson_id_substitution_id_pk": { + "name": "substitution_lesson_mtm_lesson_id_substitution_id_pk", + "columns": [ + "lesson_id", + "substitution_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.teacher": { + "name": "teacher", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "gender": { + "name": "gender", + "type": "bit(1)", + "primaryKey": false, + "notNull": false + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "short": { + "name": "short", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "teacher_user_id_user_id_fk": { + "name": "teacher_user_id_user_id_fk", + "tableFrom": "teacher", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.term_definition": { + "name": "term_definition", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "short": { + "name": "short", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "terms": { + "name": "terms", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.timetable": { + "name": "timetable", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "valid_from": { + "name": "valid_from", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "valid_to": { + "name": "valid_to", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_group": { + "name": "user_group", + "schema": "", + "columns": { + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "user_group_user_id_idx": { + "name": "user_group_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_group_group_id_idx": { + "name": "user_group_group_id_idx", + "columns": [ + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_group_group_id_group_id_fk": { + "name": "user_group_group_id_group_id_fk", + "tableFrom": "user_group", + "tableTo": "group", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_group_user_id_user_id_fk": { + "name": "user_group_user_id_user_id_fk", + "tableFrom": "user_group", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "user_group_group_id_user_id_pk": { + "name": "user_group_group_id_user_id_pk", + "columns": [ + "group_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.week_definition": { + "name": "week_definition", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "short": { + "name": "short", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "weeks": { + "name": "weeks", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.wifi_auth_log": { + "name": "wifi_auth_log", + "schema": "", + "columns": { + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "wifi_auth_log_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "mac_address": { + "name": "mac_address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "nas_ip_address": { + "name": "nas_ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "nas_mac_address": { + "name": "nas_mac_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "result": { + "name": "result", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "timestamp": { + "name": "timestamp", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "wifi_user_id": { + "name": "wifi_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "wifi_auth_log_timestamp_idx": { + "name": "wifi_auth_log_timestamp_idx", + "columns": [ + { + "expression": "timestamp", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "wifi_auth_log_username_idx": { + "name": "wifi_auth_log_username_idx", + "columns": [ + { + "expression": "username", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "wifi_auth_log_mac_address_idx": { + "name": "wifi_auth_log_mac_address_idx", + "columns": [ + { + "expression": "mac_address", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "wifi_auth_log_wifi_user_id_wifi_user_id_fk": { + "name": "wifi_auth_log_wifi_user_id_wifi_user_id_fk", + "tableFrom": "wifi_auth_log", + "tableTo": "wifi_user", + "columnsFrom": [ + "wifi_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.wifi_device": { + "name": "wifi_device", + "schema": "", + "columns": { + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "banned": { + "name": "banned", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "last_active_at": { + "name": "last_active_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "mac_address": { + "name": "mac_address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "nickname": { + "name": "nickname", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reported_hostname": { + "name": "reported_hostname", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "wifi_user_id": { + "name": "wifi_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "wifi_device_mac_address_idx": { + "name": "wifi_device_mac_address_idx", + "columns": [ + { + "expression": "mac_address", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "wifi_device_wifi_user_id_idx": { + "name": "wifi_device_wifi_user_id_idx", + "columns": [ + { + "expression": "wifi_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "wifi_device_wifi_user_id_wifi_user_id_fk": { + "name": "wifi_device_wifi_user_id_wifi_user_id_fk", + "tableFrom": "wifi_device", + "tableTo": "wifi_user", + "columnsFrom": [ + "wifi_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "wifi_device_mac_address_unique": { + "name": "wifi_device_mac_address_unique", + "nullsNotDistinct": false, + "columns": [ + "mac_address" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.wifi_nas": { + "name": "wifi_nas", + "schema": "", + "columns": { + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mac_address": { + "name": "mac_address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "wifi_nas_mac_address_idx": { + "name": "wifi_nas_mac_address_idx", + "columns": [ + { + "expression": "mac_address", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "wifi_nas_ip_address_idx": { + "name": "wifi_nas_ip_address_idx", + "columns": [ + { + "expression": "ip_address", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "wifi_nas_mac_address_unique": { + "name": "wifi_nas_mac_address_unique", + "nullsNotDistinct": false, + "columns": [ + "mac_address" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.wifi_role_speed_profile": { + "name": "wifi_role_speed_profile", + "schema": "", + "columns": { + "priority": { + "name": "priority", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "role_name": { + "name": "role_name", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "speed_profile_id": { + "name": "speed_profile_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "wifi_role_speed_profile_role_name_idx": { + "name": "wifi_role_speed_profile_role_name_idx", + "columns": [ + { + "expression": "role_name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "wifi_role_speed_profile_speed_profile_id_wifi_speed_profile_id_fk": { + "name": "wifi_role_speed_profile_speed_profile_id_wifi_speed_profile_id_fk", + "tableFrom": "wifi_role_speed_profile", + "tableTo": "wifi_speed_profile", + "columnsFrom": [ + "speed_profile_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.wifi_speed_profile": { + "name": "wifi_speed_profile", + "schema": "", + "columns": { + "download_speed_mbps": { + "name": "download_speed_mbps", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "is_wlan_default": { + "name": "is_wlan_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "synced_at": { + "name": "synced_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "upload_speed_mbps": { + "name": "upload_speed_mbps", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.wifi_user": { + "name": "wifi_user", + "schema": "", + "columns": { + "allowed_mac_addresses": { + "name": "allowed_mac_addresses", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "banned": { + "name": "banned", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "encrypted_password": { + "name": "encrypted_password", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "salt": { + "name": "salt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "speed_profile_id": { + "name": "speed_profile_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "wifi_user_username_idx": { + "name": "wifi_user_username_idx", + "columns": [ + { + "expression": "username", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "wifi_user_user_id_idx": { + "name": "wifi_user_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "wifi_user_created_by_user_id_fk": { + "name": "wifi_user_created_by_user_id_fk", + "tableFrom": "wifi_user", + "tableTo": "user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "wifi_user_user_id_user_id_fk": { + "name": "wifi_user_user_id_user_id_fk", + "tableFrom": "wifi_user", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "wifi_user_username_unique": { + "name": "wifi_user_username_unique", + "nullsNotDistinct": false, + "columns": [ + "username" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/chronos/src/database/migrations/meta/_journal.json b/apps/chronos/src/database/migrations/meta/_journal.json index c77ecc8f..9a8f9911 100644 --- a/apps/chronos/src/database/migrations/meta/_journal.json +++ b/apps/chronos/src/database/migrations/meta/_journal.json @@ -211,6 +211,13 @@ "when": 1793877105560, "tag": "0029_overconfident_justice", "breakpoints": true + }, + { + "idx": 30, + "version": "7", + "when": 1794923699389, + "tag": "0030_small_the_hunter", + "breakpoints": true } ] } \ No newline at end of file diff --git a/apps/chronos/src/modules/theme/schema.ts b/apps/chronos/src/modules/theme/schema.ts index 0547cb0b..7220a99a 100644 --- a/apps/chronos/src/modules/theme/schema.ts +++ b/apps/chronos/src/modules/theme/schema.ts @@ -1,4 +1,4 @@ -import { pgTable, text, timestamp, uuid } from 'drizzle-orm/pg-core'; +import { integer, pgTable, text, timestamp, uuid } from 'drizzle-orm/pg-core'; import { user } from '#database/schema/authentication'; /** @@ -16,4 +16,25 @@ export const siteTheme = pgTable('site_theme', { }), }); -export const themeSchema = { siteTheme }; +/** + * Admin-editable annual windows that override the manually pinned skin while + * they are in season. A window is a pair of month/day pairs — no year, no cron + * — and `GET /theme` resolves it against today's wall clock on every request. + * `theme` stays plain text like `site_theme.theme`; the API layer narrows it to + * the `siteThemeIds` enum. Easter is not a row: it is a movable feast, so it + * lives in code (`utils/schedule.ts`) and wins over every row. + */ +export const siteThemeSchedule = pgTable('site_theme_schedule', { + id: uuid('id').primaryKey().defaultRandom(), + theme: text('theme').notNull(), + startMonth: integer('start_month').notNull(), + startDay: integer('start_day').notNull(), + endMonth: integer('end_month').notNull(), + endDay: integer('end_day').notNull(), + updatedAt: timestamp('updated_at').notNull().defaultNow(), + updatedBy: uuid('updated_by').references(() => user.id, { + onDelete: 'set null', + }), +}); + +export const themeSchema = { siteTheme, siteThemeSchedule }; From 146013784c59994abfa48e7a4ad1d2721a0770bf Mon Sep 17 00:00:00 2001 From: Dasa122 Date: Tue, 17 Nov 2026 14:57:21 +0100 Subject: [PATCH 02/13] feat(theme): resolve the seasonal skin from an admin schedule --- apps/chronos/openapi/chronos-openapi.json | 1127 +++++++++++++++++ apps/chronos/package.json | 2 +- apps/chronos/src/modules/theme/_router.ts | 15 +- apps/chronos/src/modules/theme/index.ts | 310 ++++- .../src/modules/theme/utils/schedule.test.ts | 155 +++ .../src/modules/theme/utils/schedule.ts | 156 +++ packages/api/src/contract/theme.ts | 74 +- packages/api/src/domains/theme.ts | 42 + 8 files changed, 1874 insertions(+), 7 deletions(-) create mode 100644 apps/chronos/src/modules/theme/utils/schedule.test.ts create mode 100644 apps/chronos/src/modules/theme/utils/schedule.ts diff --git a/apps/chronos/openapi/chronos-openapi.json b/apps/chronos/openapi/chronos-openapi.json index 614e9699..b1520f68 100644 --- a/apps/chronos/openapi/chronos-openapi.json +++ b/apps/chronos/openapi/chronos-openapi.json @@ -35679,6 +35679,1133 @@ ] } }, + "/theme/schedule": { + "post": { + "operationId": "postThemeSchedule", + "description": "Add an annual window to the theme schedule. Windows may not overlap.", + "tags": [ + "Theme" + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "endDay": { + "type": "integer", + "minimum": 1, + "maximum": 31 + }, + "endMonth": { + "type": "integer", + "minimum": 1, + "maximum": 12 + }, + "startDay": { + "type": "integer", + "minimum": 1, + "maximum": 31 + }, + "startMonth": { + "type": "integer", + "minimum": 1, + "maximum": 12 + }, + "theme": { + "enum": [ + "default", + "newYear", + "valentines", + "march15", + "easter", + "summer", + "halloween", + "christmas" + ], + "type": "string" + } + }, + "required": [ + "endDay", + "endMonth", + "startDay", + "startMonth", + "theme" + ] + } + } + } + }, + "responses": { + "201": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "active": { + "type": "boolean", + "description": "True when today (in the school's time zone) falls inside this row's annual window. Computed per request, not stored." + }, + "endDay": { + "type": "integer", + "minimum": 1, + "maximum": 31 + }, + "endMonth": { + "type": "integer", + "minimum": 1, + "maximum": 12 + }, + "id": { + "type": "string", + "format": "uuid" + }, + "startDay": { + "type": "integer", + "minimum": 1, + "maximum": 31 + }, + "startMonth": { + "type": "integer", + "minimum": 1, + "maximum": 12 + }, + "theme": { + "enum": [ + "default", + "newYear", + "valentines", + "march15", + "easter", + "summer", + "halloween", + "christmas" + ], + "type": "string" + } + }, + "required": [ + "active", + "endDay", + "endMonth", + "id", + "startDay", + "startMonth", + "theme" + ] + } + } + } + }, + "400": { + "description": "400", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "401": { + "description": "401", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "403": { + "description": "403", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "404": { + "description": "404", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "409": { + "description": "409", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "429": { + "description": "429", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "500": { + "description": "500", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + } + }, + "security": [ + { + "sessionAuth": [] + } + ] + }, + "get": { + "operationId": "getThemeSchedule", + "description": "List the theme schedule, earliest window first, with the row active today flagged.", + "tags": [ + "Theme" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "active": { + "type": "boolean", + "description": "True when today (in the school's time zone) falls inside this row's annual window. Computed per request, not stored." + }, + "endDay": { + "type": "integer", + "minimum": 1, + "maximum": 31 + }, + "endMonth": { + "type": "integer", + "minimum": 1, + "maximum": 12 + }, + "id": { + "type": "string", + "format": "uuid" + }, + "startDay": { + "type": "integer", + "minimum": 1, + "maximum": 31 + }, + "startMonth": { + "type": "integer", + "minimum": 1, + "maximum": 12 + }, + "theme": { + "enum": [ + "default", + "newYear", + "valentines", + "march15", + "easter", + "summer", + "halloween", + "christmas" + ], + "type": "string" + } + }, + "required": [ + "active", + "endDay", + "endMonth", + "id", + "startDay", + "startMonth", + "theme" + ] + } + }, + "total": { + "type": "number" + } + }, + "required": [ + "items", + "total" + ] + } + } + } + }, + "400": { + "description": "400", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "401": { + "description": "401", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "403": { + "description": "403", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "404": { + "description": "404", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "409": { + "description": "409", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "429": { + "description": "429", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "500": { + "description": "500", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + } + }, + "security": [ + { + "sessionAuth": [] + } + ] + } + }, + "/theme/schedule/{id}": { + "delete": { + "operationId": "deleteThemeSchedule", + "description": "Remove an annual window from the theme schedule.", + "tags": [ + "Theme" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "uuid" + } + }, + "required": [ + "id" + ] + } + } + } + }, + "400": { + "description": "400", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "401": { + "description": "401", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "403": { + "description": "403", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "404": { + "description": "404", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "409": { + "description": "409", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "429": { + "description": "429", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "500": { + "description": "500", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + } + }, + "security": [ + { + "sessionAuth": [] + } + ] + }, + "patch": { + "operationId": "patchThemeSchedule", + "description": "Edit an annual window of the theme schedule. The merged window may not overlap another row.", + "tags": [ + "Theme" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "requestBody": { + "required": false, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "endDay": { + "type": "integer", + "minimum": 1, + "maximum": 31 + }, + "endMonth": { + "type": "integer", + "minimum": 1, + "maximum": 12 + }, + "startDay": { + "type": "integer", + "minimum": 1, + "maximum": 31 + }, + "startMonth": { + "type": "integer", + "minimum": 1, + "maximum": 12 + }, + "theme": { + "enum": [ + "default", + "newYear", + "valentines", + "march15", + "easter", + "summer", + "halloween", + "christmas" + ], + "type": "string" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "active": { + "type": "boolean", + "description": "True when today (in the school's time zone) falls inside this row's annual window. Computed per request, not stored." + }, + "endDay": { + "type": "integer", + "minimum": 1, + "maximum": 31 + }, + "endMonth": { + "type": "integer", + "minimum": 1, + "maximum": 12 + }, + "id": { + "type": "string", + "format": "uuid" + }, + "startDay": { + "type": "integer", + "minimum": 1, + "maximum": 31 + }, + "startMonth": { + "type": "integer", + "minimum": 1, + "maximum": 12 + }, + "theme": { + "enum": [ + "default", + "newYear", + "valentines", + "march15", + "easter", + "summer", + "halloween", + "christmas" + ], + "type": "string" + } + }, + "required": [ + "active", + "endDay", + "endMonth", + "id", + "startDay", + "startMonth", + "theme" + ] + } + } + } + }, + "400": { + "description": "400", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "401": { + "description": "401", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "403": { + "description": "403", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "404": { + "description": "404", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "409": { + "description": "409", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "429": { + "description": "429", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + }, + "500": { + "description": "500", + "content": { + "application/json": { + "schema": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + }, + "required": [ + "code", + "message", + "status" + ], + "type": "object" + } + } + } + } + }, + "security": [ + { + "sessionAuth": [] + } + ] + } + }, "/timetable/timetables/cleanup-orphaned-cohorts": { "post": { "operationId": "postTimetableTimetablesCleanupOrphanedCohorts", diff --git a/apps/chronos/package.json b/apps/chronos/package.json index f6099e09..5f1b9970 100644 --- a/apps/chronos/package.json +++ b/apps/chronos/package.json @@ -11,7 +11,7 @@ "db:import-navigator": "bun --bun src/database/scripts/import-navigator.ts", "db:reset": "bun run ./src/database/scripts/reset.ts", "openapi:check": "bun run scripts/check-openapi.ts", - "test": "bun test ./src/utils/time-zone.test.ts ./src/utils/date.test.ts", + "test": "bun test --isolate ./src/utils ./src/modules/theme", "openapi:generate": "bun run scripts/generate-openapi.ts", "build": "bun run build.ts", "typecheck": "tsc" diff --git a/apps/chronos/src/modules/theme/_router.ts b/apps/chronos/src/modules/theme/_router.ts index 3f70cff1..2943711b 100644 --- a/apps/chronos/src/modules/theme/_router.ts +++ b/apps/chronos/src/modules/theme/_router.ts @@ -1,6 +1,19 @@ -import { getSiteTheme, updateSiteTheme } from '#modules/theme/index'; +import { + createThemeSchedule, + deleteThemeSchedule, + getSiteTheme, + listThemeSchedule, + updateSiteTheme, + updateThemeSchedule, +} from '#modules/theme/index'; export const themeRouter = { get: getSiteTheme, + schedule: { + create: createThemeSchedule, + delete: deleteThemeSchedule, + list: listThemeSchedule, + update: updateThemeSchedule, + }, update: updateSiteTheme, }; diff --git a/apps/chronos/src/modules/theme/index.ts b/apps/chronos/src/modules/theme/index.ts index 3981b285..b16890cd 100644 --- a/apps/chronos/src/modules/theme/index.ts +++ b/apps/chronos/src/modules/theme/index.ts @@ -1,20 +1,135 @@ import { type SiteTheme, siteThemeSchema } from '@filcdev/api/domains/theme'; import { permissions } from '@filcdev/api/permissions'; import { getLogger } from '@logtape/logtape'; -import { eq } from 'drizzle-orm'; +import { eq, ne } from 'drizzle-orm'; import { db } from '#database'; import { requireAuthorization } from '#middleware/auth'; import { recordActivity } from '#modules/activity-log/utils/record'; -import { siteTheme } from '#modules/theme/schema'; +import { siteTheme, siteThemeSchedule } from '#modules/theme/schema'; +import { + activeThemeFor, + type CalendarDay, + isRealMonthDay, + windowContains, + windowsOverlap, +} from '#modules/theme/utils/schedule'; import { base } from '#orpc'; +import { env } from '#utils/environment'; +import { badRequest, conflict, notFound } from '#utils/http'; +import { getZonedDateTimeParts } from '#utils/time-zone'; const logger = getLogger(['chronos', 'theme']); +type ScheduleRow = typeof siteThemeSchedule.$inferSelect; + +/** Today as the school's wall clock sees it — the date every window is measured + * against. `CHRONOS_TIME_ZONE` is configuration, not UTC, because "is it + * Christmas yet" is a local-calendar question. */ +const todayInSchoolTimeZone = (): CalendarDay => { + const { day, month, year } = getZonedDateTimeParts(new Date(), env.timeZone); + + return { day: Number(day), month: Number(month), year: Number(year) }; +}; + +/** The columns the resolver needs, in a stable order for log readability. */ +const scheduleWindowColumns = { + endDay: siteThemeSchedule.endDay, + endMonth: siteThemeSchedule.endMonth, + id: siteThemeSchedule.id, + startDay: siteThemeSchedule.startDay, + startMonth: siteThemeSchedule.startMonth, + theme: siteThemeSchedule.theme, +}; + +/** + * One row of the table, as every schedule endpoint answers it: the stored + * columns plus `active`, computed against today. + * + * The column is plain text and the writers restrict it to the enum, so the + * stored value *should* be a known skin. Narrow it anyway, the way `GET /theme` + * does, so one bad row (a manual edit, a future writer that forgets the enum) + * degrades to the default skin instead of failing the response schema. + */ +const toScheduleItem = ( + row: ScheduleRow, + today: CalendarDay, + requestId?: string +) => { + const theme = siteThemeSchema.catch('default').parse(row.theme); + + if (theme !== row.theme) { + logger.warning( + 'theme schedule row is not a known skin, reporting default', + { + id: row.id, + requestId, + stored: row.theme, + } + ); + } + + return { + active: windowContains(row, today.month, today.day), + endDay: row.endDay, + endMonth: row.endMonth, + id: row.id, + startDay: row.startDay, + startMonth: row.startMonth, + theme, + }; +}; + +/** `start`/`end` of a window, rejected when either is not a real calendar day. */ +const assertRealWindow = (window: { + endDay: number; + endMonth: number; + startDay: number; + startMonth: number; +}) => { + if (!isRealMonthDay(window.startMonth, window.startDay)) { + throw badRequest( + `The window start ${window.startMonth}-${window.startDay} is not a real date` + ); + } + if (!isRealMonthDay(window.endMonth, window.endDay)) { + throw badRequest( + `The window end ${window.endMonth}-${window.endDay} is not a real date` + ); + } +}; + /** * The one row the table holds, or the default when it has never been set. * Readable without a session because signed-out visitors render the skin. + * + * The annual schedule is resolved here, per request, in three steps: Easter + * (code), then the row whose window contains today, then the manually pinned + * value. There is no cron job and no stored "current theme" — a schedule change + * takes effect on the next read. */ export const getSiteTheme = base.theme.get.handler(async ({ context }) => { + const today = todayInSchoolTimeZone(); + const rows = await db.select(scheduleWindowColumns).from(siteThemeSchedule); + const scheduled = activeThemeFor(rows, today); + + if (scheduled !== null) { + const parsed = siteThemeSchema.safeParse(scheduled); + + if (parsed.success) { + logger.debug('site theme read', { + requestId: context.requestId, + source: 'schedule', + theme: parsed.data, + }); + return { theme: parsed.data }; + } + + logger.warning( + 'scheduled theme is not a known skin, serving the manual pick', + { requestId: context.requestId, stored: scheduled } + ); + } + const [row] = await db .select({ theme: siteTheme.theme }) .from(siteTheme) @@ -35,7 +150,11 @@ export const getSiteTheme = base.theme.get.handler(async ({ context }) => { }); } - logger.debug('site theme read', { requestId: context.requestId, theme }); + logger.debug('site theme read', { + requestId: context.requestId, + source: 'manual', + theme, + }); return { theme }; }); @@ -87,3 +206,188 @@ export const updateSiteTheme = base.theme.update return { theme: row.theme as SiteTheme }; }); + +/** The schedule, earliest window first, each row flagged when active today. */ +export const listThemeSchedule = base.theme.schedule.list + .use(requireAuthorization(permissions.siteThemeManage)) + .handler(async ({ context }) => { + const today = todayInSchoolTimeZone(); + const rows = await db + .select() + .from(siteThemeSchedule) + .orderBy(siteThemeSchedule.startMonth, siteThemeSchedule.startDay); + + const items = rows.map((row) => + toScheduleItem(row, today, context.requestId) + ); + + logger.debug('theme schedule listed', { + active: items.filter((item) => item.active).length, + requestId: context.requestId, + total: items.length, + userId: context.user?.id, + }); + + return { items, total: items.length }; + }); + +export const createThemeSchedule = base.theme.schedule.create + .use(requireAuthorization(permissions.siteThemeManage)) + .handler(async ({ context, input }) => { + assertRealWindow(input); + + const siblings = await db + .select(scheduleWindowColumns) + .from(siteThemeSchedule); + const overlapping = siblings.find((sibling) => + windowsOverlap(sibling, input) + ); + + if (overlapping) { + logger.warning('theme schedule window rejected: overlaps another row', { + candidate: input, + conflictingId: overlapping.id, + requestId: context.requestId, + userId: context.user?.id, + }); + throw conflict( + 'This window overlaps another scheduled window. Windows must not overlap.' + ); + } + + const [row] = await db + .insert(siteThemeSchedule) + .values({ ...input, updatedBy: context.user?.id }) + .returning(); + + logger.info('theme schedule window created', { + end: `${row.endMonth}-${row.endDay}`, + id: row.id, + requestId: context.requestId, + start: `${row.startMonth}-${row.startDay}`, + theme: row.theme, + userId: context.user?.id, + }); + + await recordActivity(context, { + action: 'create', + entityId: row.id, + entityType: 'site-theme-schedule', + metadata: { after: row }, + }); + + return toScheduleItem(row, todayInSchoolTimeZone(), context.requestId); + }); + +export const updateThemeSchedule = base.theme.schedule.update + .use(requireAuthorization(permissions.siteThemeManage)) + .handler(async ({ context, input }) => { + const { id, ...patch } = input; + + const [existing] = await db + .select() + .from(siteThemeSchedule) + .where(eq(siteThemeSchedule.id, id)) + .limit(1); + + if (!existing) { + logger.debug('theme schedule window not found', { + id, + requestId: context.requestId, + }); + throw notFound('Theme schedule window not found'); + } + + const merged = { + endDay: patch.endDay ?? existing.endDay, + endMonth: patch.endMonth ?? existing.endMonth, + startDay: patch.startDay ?? existing.startDay, + startMonth: patch.startMonth ?? existing.startMonth, + theme: patch.theme ?? existing.theme, + }; + + assertRealWindow(merged); + + const siblings = await db + .select(scheduleWindowColumns) + .from(siteThemeSchedule) + .where(ne(siteThemeSchedule.id, id)); + const overlapping = siblings.find((sibling) => + windowsOverlap(sibling, merged) + ); + + if (overlapping) { + logger.warning('theme schedule window rejected: overlaps another row', { + candidate: merged, + conflictingId: overlapping.id, + id, + requestId: context.requestId, + userId: context.user?.id, + }); + throw conflict( + 'This window overlaps another scheduled window. Windows must not overlap.' + ); + } + + const [row] = await db + .update(siteThemeSchedule) + .set({ ...merged, updatedAt: new Date(), updatedBy: context.user?.id }) + .where(eq(siteThemeSchedule.id, id)) + .returning(); + + logger.info('theme schedule window updated', { + after: merged, + before: { + end: `${existing.endMonth}-${existing.endDay}`, + start: `${existing.startMonth}-${existing.startDay}`, + theme: existing.theme, + }, + id, + requestId: context.requestId, + userId: context.user?.id, + }); + + await recordActivity(context, { + action: 'update', + entityId: id, + entityType: 'site-theme-schedule', + metadata: { after: row, before: existing }, + }); + + return toScheduleItem(row, todayInSchoolTimeZone(), context.requestId); + }); + +export const deleteThemeSchedule = base.theme.schedule.delete + .use(requireAuthorization(permissions.siteThemeManage)) + .handler(async ({ context, input }) => { + const [row] = await db + .delete(siteThemeSchedule) + .where(eq(siteThemeSchedule.id, input.id)) + .returning(); + + if (!row) { + logger.debug('theme schedule window not found for delete', { + id: input.id, + requestId: context.requestId, + }); + throw notFound('Theme schedule window not found'); + } + + logger.info('theme schedule window deleted', { + end: `${row.endMonth}-${row.endDay}`, + id: row.id, + requestId: context.requestId, + start: `${row.startMonth}-${row.startDay}`, + theme: row.theme, + userId: context.user?.id, + }); + + await recordActivity(context, { + action: 'delete', + entityId: row.id, + entityType: 'site-theme-schedule', + metadata: { before: row }, + }); + + return { id: row.id }; + }); diff --git a/apps/chronos/src/modules/theme/utils/schedule.test.ts b/apps/chronos/src/modules/theme/utils/schedule.test.ts new file mode 100644 index 00000000..3142f91c --- /dev/null +++ b/apps/chronos/src/modules/theme/utils/schedule.test.ts @@ -0,0 +1,155 @@ +import { describe, expect, test } from 'bun:test'; +import { + activeThemeFor, + easterSunday, + easterWindowContains, + isRealMonthDay, + windowContains, + windowsOverlap, +} from '#modules/theme/utils/schedule'; + +const window = ( + startMonth: number, + startDay: number, + endMonth: number, + endDay: number +) => ({ endDay, endMonth, startDay, startMonth }); + +describe('windowContains', () => { + const halloween = window(10, 25, 11, 2); + + test('is true inside the window', () => { + expect(windowContains(halloween, 10, 28)).toBe(true); + }); + + test('includes both boundary days', () => { + expect(windowContains(halloween, 10, 25)).toBe(true); + expect(windowContains(halloween, 11, 2)).toBe(true); + }); + + test('is false outside the window', () => { + expect(windowContains(halloween, 10, 24)).toBe(false); + expect(windowContains(halloween, 11, 3)).toBe(false); + }); + + test('supports a window that wraps the year end', () => { + const newYear = window(12, 28, 1, 2); + + expect(windowContains(newYear, 12, 31)).toBe(true); + expect(windowContains(newYear, 1, 1)).toBe(true); + expect(windowContains(newYear, 1, 3)).toBe(false); + expect(windowContains(newYear, 12, 27)).toBe(false); + }); + + test('contains exactly its day for a single-day window', () => { + const oneDay = window(3, 15, 3, 15); + + expect(windowContains(oneDay, 3, 15)).toBe(true); + expect(windowContains(oneDay, 3, 14)).toBe(false); + expect(windowContains(oneDay, 3, 16)).toBe(false); + }); +}); + +describe('easterSunday', () => { + test('matches the Gregorian computus for 2024–2027', () => { + expect(easterSunday(2024)).toEqual({ day: 31, month: 3 }); + expect(easterSunday(2025)).toEqual({ day: 20, month: 4 }); + expect(easterSunday(2026)).toEqual({ day: 5, month: 4 }); + expect(easterSunday(2027)).toEqual({ day: 28, month: 3 }); + }); +}); + +describe('easterWindowContains', () => { + // Easter Sunday 2026 is 5 April, so the window is 29 March – 6 April. + test('starts a week before Easter Sunday', () => { + expect(easterWindowContains(2026, 3, 29)).toBe(true); + expect(easterWindowContains(2026, 3, 28)).toBe(false); + }); + + test('runs through Easter Monday', () => { + expect(easterWindowContains(2026, 4, 5)).toBe(true); + expect(easterWindowContains(2026, 4, 6)).toBe(true); + expect(easterWindowContains(2026, 4, 7)).toBe(false); + }); + + test('crosses the month boundary between March and April', () => { + expect(easterWindowContains(2026, 3, 31)).toBe(true); + expect(easterWindowContains(2026, 4, 1)).toBe(true); + }); +}); + +describe('windowsOverlap', () => { + test('is false for disjoint windows', () => { + expect(windowsOverlap(window(10, 1, 10, 31), window(12, 1, 12, 31))).toBe( + false + ); + }); + + test('is true for identical windows', () => { + expect(windowsOverlap(window(10, 1, 10, 31), window(10, 1, 10, 31))).toBe( + true + ); + }); + + test('is true when a wrapping window crosses another', () => { + expect(windowsOverlap(window(12, 28, 1, 2), window(1, 1, 1, 10))).toBe( + true + ); + }); + + test('is true when one window contains the other', () => { + expect(windowsOverlap(window(12, 1, 12, 31), window(12, 24, 12, 26))).toBe( + true + ); + }); + + test('is false for windows touching without sharing a day', () => { + expect(windowsOverlap(window(10, 1, 10, 31), window(11, 1, 11, 30))).toBe( + false + ); + }); +}); + +describe('activeThemeFor', () => { + const easterRow = { + ...window(3, 29, 4, 6), + theme: 'summer', + }; + const halloweenRow = { + ...window(10, 25, 11, 2), + theme: 'halloween', + }; + const rows = [easterRow, halloweenRow]; + + test('Easter wins over a row with the same window', () => { + expect(activeThemeFor(rows, { day: 5, month: 4, year: 2026 })).toBe( + 'easter' + ); + }); + + test('returns the containing row’s theme', () => { + expect(activeThemeFor(rows, { day: 31, month: 10, year: 2026 })).toBe( + 'halloween' + ); + }); + + test('returns null when nothing is in season', () => { + expect(activeThemeFor(rows, { day: 15, month: 7, year: 2026 })).toBeNull(); + expect(activeThemeFor([], { day: 15, month: 7, year: 2026 })).toBeNull(); + }); +}); + +describe('isRealMonthDay', () => { + test('accepts real days, including 29 February', () => { + expect(isRealMonthDay(1, 31)).toBe(true); + expect(isRealMonthDay(2, 29)).toBe(true); + expect(isRealMonthDay(12, 31)).toBe(true); + }); + + test('rejects impossible days', () => { + expect(isRealMonthDay(2, 30)).toBe(false); + expect(isRealMonthDay(4, 31)).toBe(false); + expect(isRealMonthDay(13, 1)).toBe(false); + expect(isRealMonthDay(1, 0)).toBe(false); + }); +}); diff --git a/apps/chronos/src/modules/theme/utils/schedule.ts b/apps/chronos/src/modules/theme/utils/schedule.ts new file mode 100644 index 00000000..fe1972bf --- /dev/null +++ b/apps/chronos/src/modules/theme/utils/schedule.ts @@ -0,0 +1,156 @@ +/** + * The one piece of theme-selection logic the backend owns: which skin is in + * season today. + * + * Deliberately pure — no database, no logger, no app imports — because it runs + * inside `GET /theme`, the endpoint in every visitor's first paint. The caller + * loads the schedule rows and supplies today's wall-clock date in the school's + * time zone. + * + * Resolution order: + * 1. Easter (movable, so code rather than a row) — wins over every row. + * 2. The schedule row whose annual window contains today. + * 3. Nothing in season — the caller falls back to the manually pinned skin. + */ + +/** A month/day pair without a year; `annual` windows repeat every year. */ +export type AnnualWindow = { + startMonth: number; + startDay: number; + endMonth: number; + endDay: number; +}; + +/** A schedule row: its window plus the skin it selects. */ +export type ScheduledWindow = AnnualWindow & { theme: string }; + +/** A calendar day, as the school's wall clock sees it. */ +export type CalendarDay = { year: number; month: number; day: number }; + +/** + * The skin Easter selects. There is no row for it: Easter Sunday moves between + * 22 March and 25 April, which a month/day pair cannot express. + */ +const EASTER_THEME = 'easter'; + +/** Days in each month of a leap year, so 29 February is representable. */ +const DAYS_IN_MONTH = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; + +/** `MMDD` as one number, so a window is a plain range comparison. */ +const ordinal = (month: number, day: number): number => month * 100 + day; + +const isLeapYear = (year: number): boolean => + (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; + +/** 1-based day of the year; the basis for offsets around a movable feast. */ +const dayOfYear = (year: number, month: number, day: number): number => { + let total = day; + for (let m = 1; m < month; m += 1) { + total += DAYS_IN_MONTH[m - 1] + (m === 2 && isLeapYear(year) ? 1 : 0); + } + return total; +}; + +/** True when `month`/`day` is a real calendar day (29 February is accepted). */ +export const isRealMonthDay = (month: number, day: number): boolean => { + const max = DAYS_IN_MONTH[month - 1]; + return max !== undefined && day >= 1 && day <= max; +}; + +/** + * Inclusive containment, wrap-around aware: `12-28 → 01-02` contains 31 + * December and 1 January, and a single-day window (`start === end`) contains + * exactly that day. + */ +export const windowContains = ( + window: AnnualWindow, + month: number, + day: number +): boolean => { + const start = ordinal(window.startMonth, window.startDay); + const end = ordinal(window.endMonth, window.endDay); + const today = ordinal(month, day); + + return start <= end + ? today >= start && today <= end + : today >= start || today <= end; +}; + +/** + * Gregorian Easter Sunday (Meeus/Jones/Butcher). Valid for any year in the + * 1583–4099 range the algorithm is defined for, which is every year the school + * will care about. + */ +export const easterSunday = (year: number): { month: number; day: number } => { + const a = year % 19; + const b = Math.floor(year / 100); + const c = year % 100; + const d = Math.floor(b / 4); + const e = b % 4; + const f = Math.floor((b + 8) / 25); + const g = Math.floor((b - f + 1) / 3); + const h = (19 * a + b - d - g + 15) % 30; + const i = Math.floor(c / 4); + const k = c % 4; + const l = (32 + 2 * e + 2 * i - h - k) % 7; + const m = Math.floor((a + 11 * h + 22 * l) / 451); + const month = Math.floor((h + l - 7 * m + 114) / 31); + const day = ((h + l - 7 * m + 114) % 31) + 1; + + return { day, month }; +}; + +/** + * Easter's window: the week before Easter Sunday through Easter Monday. The + * Easter date never falls near a year boundary (22 March – 25 April), so the + * window cannot wrap and a day-of-year offset is exact. + */ +export const easterWindowContains = ( + year: number, + month: number, + day: number +): boolean => { + const easter = easterSunday(year); + const offset = + dayOfYear(year, month, day) - dayOfYear(year, easter.month, easter.day); + + return offset >= -7 && offset <= 1; +}; + +/** + * The skin for `today`, or null when nothing is in season and the caller should + * use the manually pinned one. Easter wins over any row, so a row overlapping + * it never shadows the feast. + */ +export const activeThemeFor = ( + rows: readonly ScheduledWindow[], + today: CalendarDay +): string | null => { + if (easterWindowContains(today.year, today.month, today.day)) { + return EASTER_THEME; + } + + const row = rows.find((candidate) => + windowContains(candidate, today.month, today.day) + ); + + return row?.theme ?? null; +}; + +/** + * Whether two annual windows share at least one calendar day. A day-by-day scan + * over a leap year is the obviously-correct implementation — windows are + * month/day ranges that may wrap the year end, and this is a handful of rows on + * an admin write path, not a hot loop. + */ +export const windowsOverlap = (a: AnnualWindow, b: AnnualWindow): boolean => { + for (let month = 1; month <= 12; month += 1) { + for (let day = 1; day <= DAYS_IN_MONTH[month - 1]; day += 1) { + if (windowContains(a, month, day) && windowContains(b, month, day)) { + return true; + } + } + } + + return false; +}; diff --git a/packages/api/src/contract/theme.ts b/packages/api/src/contract/theme.ts index c0c55b82..36a03479 100644 --- a/packages/api/src/contract/theme.ts +++ b/packages/api/src/contract/theme.ts @@ -1,15 +1,28 @@ import { oc } from '@orpc/contract'; +import z from 'zod'; +import { listResponse } from '../domains/list'; import { + createThemeScheduleSchema, siteThemeResponseSchema, + themeScheduleIdSchema, + themeScheduleItemSchema, updateSiteThemeSchema, + updateThemeScheduleSchema, } from '../domains/theme'; import { filcRoute } from './route'; +const THEME_TAGS = ['Theme']; + /** * The site-wide seasonal skin, applied on top of the per-user light/dark * setting. It is a single value for the whole site, so `get` is public: * signed-out visitors render it, so no session is required. `update` is * admin-only. + * + * `schedule` is the admin-editable annual calendar on top of that one value: + * while a window is in season its theme wins over the manual pick. Resolution + * happens inside `get` on every request — there is no scheduled job — so the + * schedule endpoints only edit rows. */ export const themeContract = { get: oc @@ -20,10 +33,67 @@ export const themeContract = { method: 'GET', operationId: 'getTheme', path: '/theme', - tags: ['Theme'], + tags: THEME_TAGS, }) ) .output(siteThemeResponseSchema), + schedule: { + create: oc + .route( + filcRoute({ + auth: true, + description: + 'Add an annual window to the theme schedule. Windows may not overlap.', + method: 'POST', + operationId: 'postThemeSchedule', + path: '/theme/schedule', + successStatus: 201, + tags: THEME_TAGS, + }) + ) + .input(createThemeScheduleSchema) + .output(themeScheduleItemSchema), + delete: oc + .route( + filcRoute({ + auth: true, + description: 'Remove an annual window from the theme schedule.', + method: 'DELETE', + operationId: 'deleteThemeSchedule', + path: '/theme/schedule/{id}', + tags: THEME_TAGS, + }) + ) + .input(themeScheduleIdSchema) + .output(z.object({ id: z.uuid() })), + list: oc + .route( + filcRoute({ + auth: true, + description: + 'List the theme schedule, earliest window first, with the row active today flagged.', + method: 'GET', + operationId: 'getThemeSchedule', + path: '/theme/schedule', + tags: THEME_TAGS, + }) + ) + .output(listResponse(themeScheduleItemSchema)), + update: oc + .route( + filcRoute({ + auth: true, + description: + 'Edit an annual window of the theme schedule. The merged window may not overlap another row.', + method: 'PATCH', + operationId: 'patchThemeSchedule', + path: '/theme/schedule/{id}', + tags: THEME_TAGS, + }) + ) + .input(updateThemeScheduleSchema) + .output(themeScheduleItemSchema), + }, update: oc .route( filcRoute({ @@ -32,7 +102,7 @@ export const themeContract = { method: 'PATCH', operationId: 'patchTheme', path: '/theme', - tags: ['Theme'], + tags: THEME_TAGS, }) ) .input(updateSiteThemeSchema) diff --git a/packages/api/src/domains/theme.ts b/packages/api/src/domains/theme.ts index 5b80a59e..19b3b432 100644 --- a/packages/api/src/domains/theme.ts +++ b/packages/api/src/domains/theme.ts @@ -54,3 +54,45 @@ export const siteThemeResponseSchema = z.object({ theme: siteThemeSchema }); /** Payload for an admin setting the site-wide theme. */ export const updateSiteThemeSchema = z.object({ theme: siteThemeSchema }); + +/** An annual schedule window is a month/day pair without a year, so 1–12 and + * 1–31 are the wire bounds; the backend rejects impossible pairs (31 April). */ +export const monthSchema = z.number().int().min(1).max(12); +export const daySchema = z.number().int().min(1).max(31); + +/** + * A row of the admin-editable annual schedule: while the window is in season, + * its theme overrides the manually pinned `site_theme.theme`. `active` is + * computed server-side against today's wall clock (`env.timeZone`) on every + * read — it is not stored and never editable. + */ +export const themeScheduleItemSchema = z.object({ + active: z + .boolean() + .describe( + "True when today (in the school's time zone) falls inside this row's annual window. Computed per request, not stored." + ), + endDay: daySchema, + endMonth: monthSchema, + id: z.uuid(), + startDay: daySchema, + startMonth: monthSchema, + theme: siteThemeSchema, +}); + +/** Payload for adding a schedule window. Windows must not overlap. */ +export const createThemeScheduleSchema = z.object({ + endDay: daySchema, + endMonth: monthSchema, + startDay: daySchema, + startMonth: monthSchema, + theme: siteThemeSchema, +}); + +/** Partial edit of one schedule window; `id` rides in the path. */ +export const updateThemeScheduleSchema = createThemeScheduleSchema + .partial() + .extend({ id: z.uuid() }); + +/** Path/query input of the endpoints that address one schedule row. */ +export const themeScheduleIdSchema = z.object({ id: z.uuid() }); From baa6ca66f5a5a844fdc795aef42d362597dac59c Mon Sep 17 00:00:00 2001 From: Dasa122 Date: Tue, 17 Nov 2026 15:00:53 +0100 Subject: [PATCH 03/13] feat(iris): edit the theme schedule from the admin picker --- apps/iris/public/locales/en/translation.json | 27 ++ apps/iris/public/locales/hu/translation.json | 27 ++ .../src/components/admin/theme-catalog.ts | 82 +++++ .../admin/theme-schedule-dialog.tsx | 300 ++++++++++++++++++ .../components/admin/theme-schedule-panel.tsx | 143 +++++++++ apps/iris/src/hooks/site-theme.ts | 102 +++++- apps/iris/src/routes/_private/admin/theme.tsx | 78 ++--- 7 files changed, 702 insertions(+), 57 deletions(-) create mode 100644 apps/iris/src/components/admin/theme-catalog.ts create mode 100644 apps/iris/src/components/admin/theme-schedule-dialog.tsx create mode 100644 apps/iris/src/components/admin/theme-schedule-panel.tsx diff --git a/apps/iris/public/locales/en/translation.json b/apps/iris/public/locales/en/translation.json index 2baed0aa..c57bb674 100644 --- a/apps/iris/public/locales/en/translation.json +++ b/apps/iris/public/locales/en/translation.json @@ -217,6 +217,33 @@ "saveError": "Failed to update the site theme", "previewLabel": "Preview", "currentTheme": "Current theme", + "schedule": { + "title": "Scheduled skins", + "description": "Windows that switch the skin automatically while they are in season. Easter always wins during its week; otherwise a window here overrides the manual pick above.", + "add": "Add window", + "edit": "Edit window", + "delete": "Delete window", + "save": "Save window", + "empty": "No scheduled windows yet.", + "active": "Active now", + "theme": "Skin", + "start": "Starts", + "end": "Ends", + "startMonth": "Start month", + "startDay": "Start day", + "endMonth": "End month", + "endDay": "End day", + "hint": "A window may wrap the year end (for example 12-28 → 01-02). Windows must not overlap; Easter's week is set in code and always wins.", + "override": "{{theme}} is scheduled until {{window}}, so it overrides the manual pick until that window ends.", + "deleteConfirmTitle": "Delete this window?", + "deleteConfirmDescription": "{{theme}} will no longer apply automatically between {{window}}.", + "overlapError": "This window overlaps another scheduled window.", + "saveError": "Failed to save the window", + "created": "Window added", + "updated": "Window updated", + "deleted": "Window deleted", + "deleteError": "Failed to delete the window" + }, "notice": { "title": "New theme: {{name}}", "description": "The school turned on the {{name}} theme for everyone. Want to keep it, or switch it off for good?", diff --git a/apps/iris/public/locales/hu/translation.json b/apps/iris/public/locales/hu/translation.json index 23a34e42..9917460c 100644 --- a/apps/iris/public/locales/hu/translation.json +++ b/apps/iris/public/locales/hu/translation.json @@ -199,6 +199,33 @@ "saveError": "Nem sikerült frissíteni a webhelytémát", "previewLabel": "Előnézet", "currentTheme": "Jelenlegi téma", + "schedule": { + "title": "Ütemezett témák", + "description": "Időszakok, amelyekben a téma automatikusan átvált. Húsvét hete mindig nyer; azon kívül az itteni időszak felülírja a fenti kézi választást.", + "add": "Időszak hozzáadása", + "edit": "Időszak szerkesztése", + "delete": "Időszak törlése", + "save": "Időszak mentése", + "empty": "Még nincs ütemezett időszak.", + "active": "Most aktív", + "theme": "Téma", + "start": "Kezdete", + "end": "Vége", + "startMonth": "Kezdő hónap", + "startDay": "Kezdő nap", + "endMonth": "Záró hónap", + "endDay": "Záró nap", + "hint": "Az időszak átnyúlhat az év végén (például 12-28 → 01-02). Az időszakok nem fedhetik egymást; Húsvét hete a kódban van, és mindig nyer.", + "override": "{{window}} között a(z) {{theme}} van ütemezve, ezért az felülírja a kézi választást az időszak végéig.", + "deleteConfirmTitle": "Törlöd ezt az időszakot?", + "deleteConfirmDescription": "{{window}} között a(z) {{theme}} többé nem érvényesül automatikusan.", + "overlapError": "Ez az időszak átfed egy másik ütemezett időszakkal.", + "saveError": "Nem sikerült menteni az időszakot", + "created": "Időszak hozzáadva", + "updated": "Időszak frissítve", + "deleted": "Időszak törölve", + "deleteError": "Nem sikerült törölni az időszakot" + }, "notice": { "title": "Új téma: {{name}}", "description": "Az iskola bekapcsolta mindenkinek a(z) {{name}} témát. Maradhat, vagy kikapcsoljuk neked véglegesen?", diff --git a/apps/iris/src/components/admin/theme-catalog.ts b/apps/iris/src/components/admin/theme-catalog.ts new file mode 100644 index 00000000..6d909836 --- /dev/null +++ b/apps/iris/src/components/admin/theme-catalog.ts @@ -0,0 +1,82 @@ +import { type SiteTheme, siteThemeIds } from '@filcdev/api/domains/theme'; +import type { ThemeScheduleItem } from '@/hooks/site-theme'; +import { formatLocalizedDate } from '@/utils/date-locale'; + +/** + * The label keys for each skin, keyed by the contract's id list. Declaring it + * as a `Record` is what makes a new skin a compile error until it + * is named in both locales, instead of a missing card at runtime. + * + * Shared by the admin picker and the schedule dialog, so a schedule row is + * named with the same copy as its card. + */ +export const THEME_COPY: Record< + SiteTheme, + { descriptionKey: string; nameKey: string } +> = { + christmas: { + descriptionKey: 'siteTheme.christmas.description', + nameKey: 'siteTheme.christmas.name', + }, + default: { + descriptionKey: 'siteTheme.default.description', + nameKey: 'siteTheme.default.name', + }, + easter: { + descriptionKey: 'siteTheme.easter.description', + nameKey: 'siteTheme.easter.name', + }, + halloween: { + descriptionKey: 'siteTheme.halloween.description', + nameKey: 'siteTheme.halloween.name', + }, + march15: { + descriptionKey: 'siteTheme.march15.description', + nameKey: 'siteTheme.march15.name', + }, + newYear: { + descriptionKey: 'siteTheme.newYear.description', + nameKey: 'siteTheme.newYear.name', + }, + summer: { + descriptionKey: 'siteTheme.summer.description', + nameKey: 'siteTheme.summer.name', + }, + valentines: { + descriptionKey: 'siteTheme.valentines.description', + nameKey: 'siteTheme.valentines.name', + }, +}; + +/** One entry per skin, in the contract's order (which is the calendar's). */ +export const THEMES = siteThemeIds.map((id) => ({ id, ...THEME_COPY[id] })); + +export type ThemeOption = (typeof THEMES)[number]; + +/** + * One month/day in the reader's language. A leap year keeps 29 February + * representable, since a window may legitimately end there. + */ +const formatMonthDay = ( + month: number, + day: number, + language: string | undefined +): string => + formatLocalizedDate(new Date(2024, month - 1, day), language, { + day: 'numeric', + month: 'short', + }); + +/** A schedule row's window as `start → end`, both ends in the reader's locale. */ +export const windowText = ( + item: Pick< + ThemeScheduleItem, + 'startMonth' | 'startDay' | 'endMonth' | 'endDay' + >, + language: string | undefined +): string => + `${formatMonthDay(item.startMonth, item.startDay, language)} → ${formatMonthDay( + item.endMonth, + item.endDay, + language + )}`; diff --git a/apps/iris/src/components/admin/theme-schedule-dialog.tsx b/apps/iris/src/components/admin/theme-schedule-dialog.tsx new file mode 100644 index 00000000..caf292c8 --- /dev/null +++ b/apps/iris/src/components/admin/theme-schedule-dialog.tsx @@ -0,0 +1,300 @@ +import type { SiteTheme } from '@filcdev/api/domains/theme'; +import { Button } from '@filcdev/ui/components/button'; +import { + Dialog, + DialogContent, + DialogFooter, + DialogHeader, + DialogTitle, +} from '@filcdev/ui/components/dialog'; +import { Field, FieldLabel } from '@filcdev/ui/components/field'; +import { + Select, + SelectTrigger, + SelectValue, +} from '@filcdev/ui/components/select'; +import { Spinner } from '@filcdev/ui/components/spinner'; +import { useForm, useStore } from '@tanstack/react-form'; +import { useMemo } from 'react'; +import { useTranslation } from 'react-i18next'; +import type { BaseDialogProps } from '@/components/admin/admin.types'; +import { THEMES } from '@/components/admin/theme-catalog'; +import { + type ThemeScheduleItem, + useCreateThemeSchedule, + useUpdateThemeSchedule, +} from '@/hooks/site-theme'; +import { getIntlLocale } from '@/utils/date-locale'; + +/** A window is four month/day numbers plus the skin it selects. */ +type ThemeScheduleFormValues = { + theme: SiteTheme; + endMonth: number; + endDay: number; + startMonth: number; + startDay: number; +}; + +const MONTHS = Array.from({ length: 12 }, (_, index) => index + 1); + +/** Leap-free maximum each month can hold; 29 February stays representable. */ +const DAYS_IN_MONTH = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; + +const daysInMonth = (month: number): number => DAYS_IN_MONTH[month - 1] ?? 31; + +/** + * Defaults for a new window: a one-day window starting today. Nothing in here + * is random, so the dialog can seed `useForm` on mount and the parent's `key` + * is what discards edits between openings. + */ +function toFormValues( + item?: ThemeScheduleItem | null +): ThemeScheduleFormValues { + if (item) { + return { + endDay: item.endDay, + endMonth: item.endMonth, + startDay: item.startDay, + startMonth: item.startMonth, + theme: item.theme, + }; + } + + const today = new Date(); + + return { + endDay: today.getDate(), + endMonth: today.getMonth() + 1, + startDay: today.getDate(), + startMonth: today.getMonth() + 1, + theme: 'default', + }; +} + +type ThemeScheduleDialogProps = BaseDialogProps & { + item?: ThemeScheduleItem | null; +}; + +/** + * Create or edit one annual window of the theme schedule. The dialog owns its + * mutations and closes itself through `onSaved`, and the parent remounts it + * with a `key` per opening so `useForm` seeds from `defaultValues` once. + */ +export function ThemeScheduleDialog({ + item, + onOpenChange, + open, +}: ThemeScheduleDialogProps) { + const { i18n, t } = useTranslation(); + const close = () => onOpenChange(false); + const createSchedule = useCreateThemeSchedule({ onSaved: close }); + const updateSchedule = useUpdateThemeSchedule({ onSaved: close }); + + const defaultValues = useMemo(() => toFormValues(item), [item]); + const form = useForm({ + defaultValues, + onSubmit: ({ value }) => { + if (item) { + updateSchedule.mutate({ ...value, id: item.id }); + return; + } + createSchedule.mutate(value); + }, + }); + + const values = useStore(form.store, (state) => state.values); + const isPending = createSchedule.isPending || updateSchedule.isPending; + + const locale = getIntlLocale(i18n.language); + const monthName = (month: number) => + new Intl.DateTimeFormat(locale, { month: 'long' }).format( + new Date(2024, month - 1, 1) + ); + + const monthItems = MONTHS.map((month) => ({ + label: monthName(month), + value: String(month), + })); + const dayItems = (month: number) => + Array.from({ length: daysInMonth(month) }, (_, index) => ({ + label: String(index + 1), + value: String(index + 1), + })); + + const themeItems = THEMES.map((option) => ({ + label: t(option.nameKey), + value: option.id, + })); + + /** A shorter month must not leave the day select on an impossible day. */ + const changeMonth = ( + field: 'startMonth' | 'endMonth', + dayField: 'startDay' | 'endDay', + month: number + ) => { + form.setFieldValue(field, month); + const max = daysInMonth(month); + if (form.getFieldValue(dayField) > max) { + form.setFieldValue(dayField, max); + } + }; + + return ( + + + + + {item ? t('siteTheme.schedule.edit') : t('siteTheme.schedule.add')} + + + +
{ + event.preventDefault(); + form.handleSubmit(); + }} + > + + {(field) => ( + + {t('siteTheme.schedule.theme')} + + + )} + + +
+
+

+ {t('siteTheme.schedule.start')} +

+ + {(field) => ( + + )} + + + {(field) => ( + + )} + +
+ +
+

+ {t('siteTheme.schedule.end')} +

+ + {(field) => ( + + )} + + + {(field) => ( + + )} + +
+
+ +

+ {t('siteTheme.schedule.hint')} +

+ + + + + +
+
+
+ ); +} diff --git a/apps/iris/src/components/admin/theme-schedule-panel.tsx b/apps/iris/src/components/admin/theme-schedule-panel.tsx new file mode 100644 index 00000000..990c82b6 --- /dev/null +++ b/apps/iris/src/components/admin/theme-schedule-panel.tsx @@ -0,0 +1,143 @@ +import { Badge } from '@filcdev/ui/components/badge'; +import { Button } from '@filcdev/ui/components/button'; +import { Skeleton } from '@filcdev/ui/components/skeleton'; +import { Pencil, Plus, Trash } from 'lucide-react'; +import { useState } from 'react'; +import { useTranslation } from 'react-i18next'; +import { DeleteConfirmDialog } from '@/components/admin/delete-confirm-dialog'; +import { THEME_COPY, windowText } from '@/components/admin/theme-catalog'; +import { ThemeScheduleDialog } from '@/components/admin/theme-schedule-dialog'; +import { + type ThemeScheduleItem, + useDeleteThemeSchedule, + useThemeSchedule, +} from '@/hooks/site-theme'; + +/** + * The admin-editable annual schedule: the rows that override the manual skin + * while they are in season, plus their create/edit/delete flows. + * + * Owns its own query so the picker above does not have to thread the list + * down; React Query dedupes it against any other `theme.schedule.list` reader. + */ +export function ThemeSchedulePanel() { + const { i18n, t } = useTranslation(); + const scheduleQuery = useThemeSchedule(); + const [dialogOpen, setDialogOpen] = useState(false); + const [dialogItem, setDialogItem] = useState(null); + const [deleteTarget, setDeleteTarget] = useState( + null + ); + const deleteMutation = useDeleteThemeSchedule({ + onSaved: () => setDeleteTarget(null), + }); + + const items = scheduleQuery.data ?? []; + + const openCreate = () => { + setDialogItem(null); + setDialogOpen(true); + }; + + const openEdit = (item: ThemeScheduleItem) => { + setDialogItem(item); + setDialogOpen(true); + }; + + const renderRows = () => { + if (scheduleQuery.isLoading) { + return ; + } + + if (items.length === 0) { + return ( +

+ {t('siteTheme.schedule.empty')} +

+ ); + } + + return ( +
    + {items.map((item) => ( +
  • + + {t(THEME_COPY[item.theme].nameKey)} + + + {windowText(item, i18n.language)} + + {item.active && {t('siteTheme.schedule.active')}} +
    + + +
    +
  • + ))} +
+ ); + }; + + return ( +
+
+
+

+ {t('siteTheme.schedule.title')} +

+

+ {t('siteTheme.schedule.description')} +

+
+ +
+ + {renderRows()} + + + + setDeleteTarget(null)} + onConfirm={() => { + if (deleteTarget) { + deleteMutation.mutate({ id: deleteTarget.id }); + } + }} + onOpenChange={(open) => { + if (!open) { + setDeleteTarget(null); + } + }} + open={deleteTarget !== null} + pending={deleteMutation.isPending} + title={t('siteTheme.schedule.deleteConfirmTitle')} + /> +
+ ); +} diff --git a/apps/iris/src/hooks/site-theme.ts b/apps/iris/src/hooks/site-theme.ts index 20c8583c..f0f0eed8 100644 --- a/apps/iris/src/hooks/site-theme.ts +++ b/apps/iris/src/hooks/site-theme.ts @@ -1,7 +1,18 @@ +import { ERROR_CODE } from '@filcdev/api/errors'; +import { isDefinedError } from '@orpc/client'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; import { useTranslation } from 'react-i18next'; import { toast } from 'sonner'; -import { orpc } from '@/utils/orpc'; +import { type api, orpc } from '@/utils/orpc'; +import type { MutationCallbacks } from './types'; + +type ThemeScheduleList = Awaited< + ReturnType +>['items']; + +/** One annual window of the theme schedule, with `active` computed by the + * backend for today. */ +export type ThemeScheduleItem = ThemeScheduleList[number]; /** * The site-wide seasonal skin. Public (signed-out visitors render it) and read @@ -12,9 +23,27 @@ export function useSiteTheme() { return useQuery(orpc.theme.get.queryOptions({ staleTime: 5 * 60_000 })); } -/** Set the site-wide seasonal theme. The backend is admin-only. */ -export function useUpdateSiteTheme({ onSaved }: { onSaved?: () => void } = {}) { +/** + * `orpc.theme.key()` is the router-level prefix, so one invalidation covers + * `theme.get`, `theme.update` and the whole `theme.schedule` subtree: the + * picker's public read and the schedule list always agree. + */ +function useInvalidateTheme() { const queryClient = useQueryClient(); + return () => queryClient.invalidateQueries({ queryKey: orpc.theme.key() }); +} + +/** The admin-editable annual schedule, earliest window first. */ +export function useThemeSchedule() { + return useQuery({ + ...orpc.theme.schedule.list.queryOptions(), + select: (data) => data.items, + }); +} + +/** Set the site-wide seasonal theme. The backend is admin-only. */ +export function useUpdateSiteTheme({ onSaved }: MutationCallbacks = {}) { + const invalidate = useInvalidateTheme(); const { t } = useTranslation(); return useMutation( orpc.theme.update.mutationOptions({ @@ -22,12 +51,73 @@ export function useUpdateSiteTheme({ onSaved }: { onSaved?: () => void } = {}) { toast.error(t('siteTheme.saveError')); }, onSuccess: () => { - // A bare `.key()` matches every input of the procedure, so the public - // `useSiteTheme` cache is invalidated and re-reads the new value. - queryClient.invalidateQueries({ queryKey: orpc.theme.key() }); + invalidate(); toast.success(t('siteTheme.saved')); onSaved?.(); }, }) ); } + +/** Add an annual window. Windows may not overlap, so a CONFLICT gets the + * schedule's own message instead of the backend's English one. */ +export function useCreateThemeSchedule({ onSaved }: MutationCallbacks = {}) { + const invalidate = useInvalidateTheme(); + const { t } = useTranslation(); + return useMutation( + orpc.theme.schedule.create.mutationOptions({ + onError: (error) => { + toast.error( + isDefinedError(error) && error.code === ERROR_CODE.CONFLICT + ? t('siteTheme.schedule.overlapError') + : error.message || t('siteTheme.schedule.saveError') + ); + }, + onSuccess: () => { + invalidate(); + toast.success(t('siteTheme.schedule.created')); + onSaved?.(); + }, + }) + ); +} + +/** Edit an annual window; the merged window is overlap-checked server-side. */ +export function useUpdateThemeSchedule({ onSaved }: MutationCallbacks = {}) { + const invalidate = useInvalidateTheme(); + const { t } = useTranslation(); + return useMutation( + orpc.theme.schedule.update.mutationOptions({ + onError: (error) => { + toast.error( + isDefinedError(error) && error.code === ERROR_CODE.CONFLICT + ? t('siteTheme.schedule.overlapError') + : error.message || t('siteTheme.schedule.saveError') + ); + }, + onSuccess: () => { + invalidate(); + toast.success(t('siteTheme.schedule.updated')); + onSaved?.(); + }, + }) + ); +} + +/** Remove an annual window. */ +export function useDeleteThemeSchedule({ onSaved }: MutationCallbacks = {}) { + const invalidate = useInvalidateTheme(); + const { t } = useTranslation(); + return useMutation( + orpc.theme.schedule.delete.mutationOptions({ + onError: () => { + toast.error(t('siteTheme.schedule.deleteError')); + }, + onSuccess: () => { + invalidate(); + toast.success(t('siteTheme.schedule.deleted')); + onSaved?.(); + }, + }) + ); +} diff --git a/apps/iris/src/routes/_private/admin/theme.tsx b/apps/iris/src/routes/_private/admin/theme.tsx index 029b7521..f3981be6 100644 --- a/apps/iris/src/routes/_private/admin/theme.tsx +++ b/apps/iris/src/routes/_private/admin/theme.tsx @@ -1,4 +1,4 @@ -import { type SiteTheme, siteThemeIds } from '@filcdev/api/domains/theme'; +import type { SiteTheme } from '@filcdev/api/domains/theme'; import { permissions } from '@filcdev/api/permissions'; import { Badge } from '@filcdev/ui/components/badge'; import { Button } from '@filcdev/ui/components/button'; @@ -9,58 +9,21 @@ import { cn } from '@filcdev/ui/lib/utils'; import { createFileRoute } from '@tanstack/react-router'; import { useState } from 'react'; import { useTranslation } from 'react-i18next'; +import { + THEME_COPY, + THEMES, + type ThemeOption, + windowText, +} from '@/components/admin/theme-catalog'; +import { ThemeSchedulePanel } from '@/components/admin/theme-schedule-panel'; import { PermissionGuard } from '@/components/util/permission-guard'; -import { useSiteTheme, useUpdateSiteTheme } from '@/hooks/site-theme'; +import { + useSiteTheme, + useThemeSchedule, + useUpdateSiteTheme, +} from '@/hooks/site-theme'; import { orpc, prefetch } from '@/utils/orpc'; -/** - * The label keys for each skin, keyed by the contract's id list. Declaring it - * as a `Record` is what makes a new skin a compile error until it - * is named in both locales, instead of a missing card at runtime. - */ -const THEME_COPY: Record< - SiteTheme, - { descriptionKey: string; nameKey: string } -> = { - christmas: { - descriptionKey: 'siteTheme.christmas.description', - nameKey: 'siteTheme.christmas.name', - }, - default: { - descriptionKey: 'siteTheme.default.description', - nameKey: 'siteTheme.default.name', - }, - easter: { - descriptionKey: 'siteTheme.easter.description', - nameKey: 'siteTheme.easter.name', - }, - halloween: { - descriptionKey: 'siteTheme.halloween.description', - nameKey: 'siteTheme.halloween.name', - }, - march15: { - descriptionKey: 'siteTheme.march15.description', - nameKey: 'siteTheme.march15.name', - }, - newYear: { - descriptionKey: 'siteTheme.newYear.description', - nameKey: 'siteTheme.newYear.name', - }, - summer: { - descriptionKey: 'siteTheme.summer.description', - nameKey: 'siteTheme.summer.name', - }, - valentines: { - descriptionKey: 'siteTheme.valentines.description', - nameKey: 'siteTheme.valentines.name', - }, -}; - -/** One card per skin, in the contract's order (which is the calendar's). */ -const THEMES = siteThemeIds.map((id) => ({ id, ...THEME_COPY[id] })); - -type ThemeOption = (typeof THEMES)[number]; - export const Route = createFileRoute('/_private/admin/theme')({ component: () => ( @@ -75,14 +38,16 @@ export const Route = createFileRoute('/_private/admin/theme')({ }); function ThemePage() { - const { t } = useTranslation(); + const { i18n, t } = useTranslation(); const siteThemeQuery = useSiteTheme(); + const scheduleQuery = useThemeSchedule(); const activeTheme = siteThemeQuery.data?.theme ?? 'default'; const [selected, setSelected] = useState(activeTheme); const updateMutation = useUpdateSiteTheme(); const activeOption = THEMES.find((option) => option.id === activeTheme) ?? THEMES[0]; + const activeWindow = scheduleQuery.data?.find((item) => item.active); return (
@@ -113,6 +78,15 @@ function ThemePage() {
) : ( <> + {activeWindow && ( +

+ {t('siteTheme.schedule.override', { + theme: t(THEME_COPY[activeWindow.theme].nameKey), + window: windowText(activeWindow, i18n.language), + })} +

+ )} +
{THEMES.map((option) => ( + +
{t('siteTheme.currentTheme')}: {t(activeOption.nameKey)} From 924c6b790f3c8dc634fc14f09b471ae0e9b34bc2 Mon Sep 17 00:00:00 2001 From: Dasa122 Date: Tue, 17 Nov 2026 15:01:03 +0100 Subject: [PATCH 04/13] docs(theming): document how the seasonal skin is scheduled --- docs/theming.md | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/docs/theming.md b/docs/theming.md index 679ee8bb..fcfd928d 100644 --- a/docs/theming.md +++ b/docs/theming.md @@ -10,7 +10,7 @@ three calls, and owns no palette of its own. | --- | --- | --- | --- | | everyday light/dark | `packages/ui/src/styles/globals.css` | `:root` / `.dark` | next-themes | | the visitor's palette | `packages/ui/src/styles/schemes.css` | `data-color-scheme=""` | the visitor, in Settings → Appearance | -| the seasonal skin | `packages/ui/src/styles/themes.css` | `data-site-theme=""` | an admin, site-wide | +| the seasonal skin | `packages/ui/src/styles/themes.css` | `data-site-theme=""` | an admin, site-wide (manual pick or schedule) | | seasonal motifs (emoji) | `lib/site-theme-art.ts` + `components/site-theme-art.tsx` | same ids | the active skin | Every layer declares the same ~32 token names at the same specificity @@ -62,6 +62,37 @@ itself (`data-color-scheme` on the swatch), so no colours are copied into TS. Use the palette's published values rather than derived shades — that is the point of naming it after a known theme. +## Scheduled skins + +The site-wide skin is resolved on every request from two admin-owned sources: +the `site_theme` singleton row (`GET`/`PATCH /theme`) and the annual schedule +(`/theme/schedule`). A row of `site_theme_schedule` is a skin plus a window of +month/day pairs that repeats every year; the picker's "Scheduled skins" section +edits them. + +`GET /theme` resolves in this order: + +1. **Easter** — the one rule in code. Easter Sunday (Gregorian computus) −7 days + through +1 day, so Palm Sunday to Easter Monday. It wins over every row, + because a movable feast cannot be written as a month/day pair. +2. **An annual window containing today**, measured on the school's wall clock + (`CHRONOS_TIME_ZONE`, default `Europe/Budapest`). That row's skin is served. +3. **The manual pick** in `site_theme.theme` — the behaviour that predates the + schedule. + +A window may wrap the year end (`12-28 → 01-02`), and a one-day window +(`03-15 → 03-15`) is legal. Two rows may never share a day: create and update +answer `409 CONFLICT`, and the dialog only offers days the chosen month actually +has. Easter is not checked against rows — it is code, and it always wins. + +There is **no cron job and no stored "current skin"**. Resolution happens inside +`GET /theme`, so a schedule edit applies on the next request and a window +boundary flips as soon as the date does. + +Clients cache `GET /theme` for five minutes (`staleTime` in +`apps/iris/src/hooks/site-theme.ts`), so a tab left open can keep the previous +skin for up to that long after a boundary or an admin edit. + ## Subject colours come along for free The twelve timetable colours are `--class-hue-1…12` (hues only) mixed with From 45348db6001ee3fed6c86e47eee8a4de33937fad Mon Sep 17 00:00:00 2001 From: Dasa122 Date: Tue, 17 Nov 2026 15:18:21 +0100 Subject: [PATCH 05/13] fix(theme): serialise schedule writes and resolve the skin in one pure step --- apps/chronos/src/modules/theme/index.ts | 279 +++++++++++------- .../src/modules/theme/utils/schedule.test.ts | 127 +++++++- .../src/modules/theme/utils/schedule.ts | 76 ++++- 3 files changed, 362 insertions(+), 120 deletions(-) diff --git a/apps/chronos/src/modules/theme/index.ts b/apps/chronos/src/modules/theme/index.ts index b16890cd..a82eea3a 100644 --- a/apps/chronos/src/modules/theme/index.ts +++ b/apps/chronos/src/modules/theme/index.ts @@ -1,36 +1,32 @@ -import { type SiteTheme, siteThemeSchema } from '@filcdev/api/domains/theme'; +import { + daySchema, + monthSchema, + type SiteTheme, + siteThemeSchema, +} from '@filcdev/api/domains/theme'; import { permissions } from '@filcdev/api/permissions'; import { getLogger } from '@logtape/logtape'; -import { eq, ne } from 'drizzle-orm'; +import { eq, ne, sql } from 'drizzle-orm'; import { db } from '#database'; import { requireAuthorization } from '#middleware/auth'; import { recordActivity } from '#modules/activity-log/utils/record'; import { siteTheme, siteThemeSchedule } from '#modules/theme/schema'; import { - activeThemeFor, type CalendarDay, isRealMonthDay, + resolveTheme, + todayInTimeZone, windowContains, windowsOverlap, } from '#modules/theme/utils/schedule'; import { base } from '#orpc'; import { env } from '#utils/environment'; import { badRequest, conflict, notFound } from '#utils/http'; -import { getZonedDateTimeParts } from '#utils/time-zone'; const logger = getLogger(['chronos', 'theme']); type ScheduleRow = typeof siteThemeSchedule.$inferSelect; -/** Today as the school's wall clock sees it — the date every window is measured - * against. `CHRONOS_TIME_ZONE` is configuration, not UTC, because "is it - * Christmas yet" is a local-calendar question. */ -const todayInSchoolTimeZone = (): CalendarDay => { - const { day, month, year } = getZonedDateTimeParts(new Date(), env.timeZone); - - return { day: Number(day), month: Number(month), year: Number(year) }; -}; - /** The columns the resolver needs, in a stable order for log readability. */ const scheduleWindowColumns = { endDay: siteThemeSchedule.endDay, @@ -45,36 +41,44 @@ const scheduleWindowColumns = { * One row of the table, as every schedule endpoint answers it: the stored * columns plus `active`, computed against today. * - * The column is plain text and the writers restrict it to the enum, so the - * stored value *should* be a known skin. Narrow it anyway, the way `GET /theme` - * does, so one bad row (a manual edit, a future writer that forgets the enum) - * degrades to the default skin instead of failing the response schema. + * The columns are plain integers and text that the writers restrict to real + * dates and the skin enum, so the stored values *should* be valid. Narrow them + * anyway, the same way `GET /theme` narrows its theme: one hand-edited row + * (`start_month = 13`, an unknown skin) must degrade to a harmless window + * instead of failing the response schema and 500ing the admin list. */ const toScheduleItem = ( row: ScheduleRow, today: CalendarDay, requestId?: string ) => { + const window = { + endDay: daySchema.catch(1).parse(row.endDay), + endMonth: monthSchema.catch(1).parse(row.endMonth), + startDay: daySchema.catch(1).parse(row.startDay), + startMonth: monthSchema.catch(1).parse(row.startMonth), + }; const theme = siteThemeSchema.catch('default').parse(row.theme); - if (theme !== row.theme) { - logger.warning( - 'theme schedule row is not a known skin, reporting default', - { - id: row.id, - requestId, - stored: row.theme, - } - ); + const degraded = + theme !== row.theme || + window.endDay !== row.endDay || + window.endMonth !== row.endMonth || + window.startDay !== row.startDay || + window.startMonth !== row.startMonth; + + if (degraded) { + logger.warning('theme schedule row is out of range, degrading it', { + id: row.id, + requestId, + stored: row, + }); } return { - active: windowContains(row, today.month, today.day), - endDay: row.endDay, - endMonth: row.endMonth, + active: windowContains(window, today.month, today.day), + ...window, id: row.id, - startDay: row.startDay, - startMonth: row.startMonth, theme, }; }; @@ -99,8 +103,8 @@ const assertRealWindow = (window: { }; /** - * The one row the table holds, or the default when it has never been set. - * Readable without a session because signed-out visitors render the skin. + * The skin the site should wear today. Readable without a session because + * signed-out visitors render it. * * The annual schedule is resolved here, per request, in three steps: Easter * (code), then the row whose window contains today, then the manually pinned @@ -108,51 +112,43 @@ const assertRealWindow = (window: { * takes effect on the next read. */ export const getSiteTheme = base.theme.get.handler(async ({ context }) => { - const today = todayInSchoolTimeZone(); - const rows = await db.select(scheduleWindowColumns).from(siteThemeSchedule); - const scheduled = activeThemeFor(rows, today); - - if (scheduled !== null) { - const parsed = siteThemeSchema.safeParse(scheduled); - - if (parsed.success) { - logger.debug('site theme read', { - requestId: context.requestId, - source: 'schedule', - theme: parsed.data, - }); - return { theme: parsed.data }; - } - - logger.warning( - 'scheduled theme is not a known skin, serving the manual pick', - { requestId: context.requestId, stored: scheduled } - ); - } + const today = todayInTimeZone(new Date(), env.timeZone); - const [row] = await db + // Two reads on every first paint: the singleton manual row and the handful of + // schedule rows. Both are primary-key-sized, so they stay cheaper than any + // cache that could go stale between a window boundary and an admin edit. + const [stored] = await db .select({ theme: siteTheme.theme }) .from(siteTheme) .where(eq(siteTheme.id, 'default')) .limit(1); - - // The column is plain text and the only writer restricts it to the enum, so - // the stored value *should* be one of them. Narrow it anyway: this call is in - // every visitor's first paint, and one bad row (a manual edit, a future - // writer that forgets the enum) would otherwise fail the output schema and - // take the whole page down instead of falling back to the everyday look. - const theme = siteThemeSchema.catch('default').parse(row?.theme); - - if (row && theme !== row.theme) { - logger.warning('site theme row is not a known skin, serving the default', { + // Ordered so "the first matching row" is a stable answer even if a + // hand-edited row ever overlaps another. + const rows = await db + .select(scheduleWindowColumns) + .from(siteThemeSchedule) + .orderBy(siteThemeSchedule.startMonth, siteThemeSchedule.startDay); + + const resolved = resolveTheme(stored?.theme ?? 'default', rows, today); + + // Both sources are plain text and every writer restricts them to the enum, so + // the value *should* be a known skin. Narrow it anyway: this call is in every + // visitor's first paint, and one bad value (a manual edit, a future writer + // that forgets the enum) would otherwise fail the output schema and take the + // whole page down instead of falling back to the everyday look. + const theme = siteThemeSchema.catch('default').parse(resolved.theme); + + if (theme !== resolved.theme) { + logger.warning('site theme is not a known skin, serving the default', { requestId: context.requestId, - stored: row.theme, + source: resolved.source, + stored: resolved.theme, }); } logger.debug('site theme read', { requestId: context.requestId, - source: 'manual', + source: resolved.source, theme, }); @@ -211,7 +207,7 @@ export const updateSiteTheme = base.theme.update export const listThemeSchedule = base.theme.schedule.list .use(requireAuthorization(permissions.siteThemeManage)) .handler(async ({ context }) => { - const today = todayInSchoolTimeZone(); + const today = todayInTimeZone(new Date(), env.timeZone); const rows = await db .select() .from(siteThemeSchedule) @@ -236,29 +232,43 @@ export const createThemeSchedule = base.theme.schedule.create .handler(async ({ context, input }) => { assertRealWindow(input); - const siblings = await db - .select(scheduleWindowColumns) - .from(siteThemeSchedule); - const overlapping = siblings.find((sibling) => - windowsOverlap(sibling, input) - ); + const row = await db.transaction(async (tx) => { + // Serialise schedule writes: the overlap check and the insert have to see + // the same table, or two concurrent creates both pass the check and the + // invariant is gone. A row lock cannot do that — `select … for update` + // locks zero rows on an empty table, which is exactly the first two + // creates a school ever makes — so take a table lock in the mode that + // conflicts with INSERT/UPDATE/DELETE and leaves readers untouched. + await tx.execute( + sql`lock table site_theme_schedule in share row exclusive mode` + ); - if (overlapping) { - logger.warning('theme schedule window rejected: overlaps another row', { - candidate: input, - conflictingId: overlapping.id, - requestId: context.requestId, - userId: context.user?.id, - }); - throw conflict( - 'This window overlaps another scheduled window. Windows must not overlap.' + const siblings = await tx + .select(scheduleWindowColumns) + .from(siteThemeSchedule); + const overlapping = siblings.find((sibling) => + windowsOverlap(sibling, input) ); - } - const [row] = await db - .insert(siteThemeSchedule) - .values({ ...input, updatedBy: context.user?.id }) - .returning(); + if (overlapping) { + logger.warning('theme schedule window rejected: overlaps another row', { + candidate: input, + conflictingId: overlapping.id, + requestId: context.requestId, + userId: context.user?.id, + }); + throw conflict( + 'This window overlaps another scheduled window. Windows must not overlap.' + ); + } + + const [inserted] = await tx + .insert(siteThemeSchedule) + .values({ ...input, updatedBy: context.user?.id }) + .returning(); + + return inserted; + }); logger.info('theme schedule window created', { end: `${row.endMonth}-${row.endDay}`, @@ -276,7 +286,11 @@ export const createThemeSchedule = base.theme.schedule.create metadata: { after: row }, }); - return toScheduleItem(row, todayInSchoolTimeZone(), context.requestId); + return toScheduleItem( + row, + todayInTimeZone(new Date(), env.timeZone), + context.requestId + ); }); export const updateThemeSchedule = base.theme.schedule.update @@ -308,32 +322,75 @@ export const updateThemeSchedule = base.theme.schedule.update assertRealWindow(merged); - const siblings = await db - .select(scheduleWindowColumns) - .from(siteThemeSchedule) - .where(ne(siteThemeSchedule.id, id)); - const overlapping = siblings.find((sibling) => - windowsOverlap(sibling, merged) - ); - - if (overlapping) { - logger.warning('theme schedule window rejected: overlaps another row', { - candidate: merged, - conflictingId: overlapping.id, + // A PATCH that changes nothing is not a write: no row update, no activity + // entry, same answer as the stored row. + const unchanged = + merged.endDay === existing.endDay && + merged.endMonth === existing.endMonth && + merged.startDay === existing.startDay && + merged.startMonth === existing.startMonth && + merged.theme === existing.theme; + + if (unchanged) { + logger.debug('theme schedule window unchanged', { id, requestId: context.requestId, userId: context.user?.id, }); - throw conflict( - 'This window overlaps another scheduled window. Windows must not overlap.' + return toScheduleItem( + existing, + todayInTimeZone(new Date(), env.timeZone), + context.requestId ); } - const [row] = await db - .update(siteThemeSchedule) - .set({ ...merged, updatedAt: new Date(), updatedBy: context.user?.id }) - .where(eq(siteThemeSchedule.id, id)) - .returning(); + const row = await db.transaction(async (tx) => { + // Same table lock as create: the merged window is checked against a table + // no other write can modify until this transaction ends. + await tx.execute( + sql`lock table site_theme_schedule in share row exclusive mode` + ); + + const siblings = await tx + .select(scheduleWindowColumns) + .from(siteThemeSchedule) + .where(ne(siteThemeSchedule.id, id)); + const overlapping = siblings.find((sibling) => + windowsOverlap(sibling, merged) + ); + + if (overlapping) { + logger.warning('theme schedule window rejected: overlaps another row', { + candidate: merged, + conflictingId: overlapping.id, + id, + requestId: context.requestId, + userId: context.user?.id, + }); + throw conflict( + 'This window overlaps another scheduled window. Windows must not overlap.' + ); + } + + const [updated] = await tx + .update(siteThemeSchedule) + .set({ ...merged, updatedAt: new Date(), updatedBy: context.user?.id }) + .where(eq(siteThemeSchedule.id, id)) + .returning(); + + return updated; + }); + + // The row can disappear between the read above and this write; `returning` + // is empty then, and dereferencing it would be a 500 instead of the 404 the + // caller's next attempt would get anyway. + if (!row) { + logger.debug('theme schedule window vanished during update', { + id, + requestId: context.requestId, + }); + throw notFound('Theme schedule window not found'); + } logger.info('theme schedule window updated', { after: merged, @@ -354,7 +411,11 @@ export const updateThemeSchedule = base.theme.schedule.update metadata: { after: row, before: existing }, }); - return toScheduleItem(row, todayInSchoolTimeZone(), context.requestId); + return toScheduleItem( + row, + todayInTimeZone(new Date(), env.timeZone), + context.requestId + ); }); export const deleteThemeSchedule = base.theme.schedule.delete diff --git a/apps/chronos/src/modules/theme/utils/schedule.test.ts b/apps/chronos/src/modules/theme/utils/schedule.test.ts index 3142f91c..45747ae0 100644 --- a/apps/chronos/src/modules/theme/utils/schedule.test.ts +++ b/apps/chronos/src/modules/theme/utils/schedule.test.ts @@ -4,6 +4,8 @@ import { easterSunday, easterWindowContains, isRealMonthDay, + resolveTheme, + todayInTimeZone, windowContains, windowsOverlap, } from '#modules/theme/utils/schedule'; @@ -76,6 +78,33 @@ describe('easterWindowContains', () => { expect(easterWindowContains(2026, 3, 31)).toBe(true); expect(easterWindowContains(2026, 4, 1)).toBe(true); }); + + // Easter Sunday 2024 is 31 March, so the window straddles a leap February: + // 24 March – 1 April. + test('is exact across the end of a leap February (2024)', () => { + expect(easterWindowContains(2024, 3, 24)).toBe(true); + expect(easterWindowContains(2024, 4, 1)).toBe(true); + expect(easterWindowContains(2024, 3, 23)).toBe(false); + expect(easterWindowContains(2024, 4, 2)).toBe(false); + }); + + // Easter Sunday 2027 is 28 March, the earliest it gets in this decade: + // window 21 March – 29 March. + test('holds for an early Easter (2027-03-28)', () => { + expect(easterWindowContains(2027, 3, 21)).toBe(true); + expect(easterWindowContains(2027, 3, 29)).toBe(true); + expect(easterWindowContains(2027, 3, 20)).toBe(false); + expect(easterWindowContains(2027, 3, 30)).toBe(false); + }); + + // Easter Sunday 2038 is 25 April, the latest date the computus can produce: + // window 18 April – 26 April. + test('holds for the latest possible Easter (2038-04-25)', () => { + expect(easterWindowContains(2038, 4, 18)).toBe(true); + expect(easterWindowContains(2038, 4, 26)).toBe(true); + expect(easterWindowContains(2038, 4, 17)).toBe(false); + expect(easterWindowContains(2038, 4, 27)).toBe(false); + }); }); describe('windowsOverlap', () => { @@ -97,6 +126,21 @@ describe('windowsOverlap', () => { ); }); + test('is false for two wrapping windows that do not meet', () => { + expect(windowsOverlap(window(12, 28, 1, 2), window(1, 5, 1, 20))).toBe( + false + ); + }); + + test('handles one-day windows', () => { + expect(windowsOverlap(window(3, 15, 3, 15), window(3, 15, 3, 15))).toBe( + true + ); + expect(windowsOverlap(window(3, 15, 3, 15), window(3, 16, 3, 16))).toBe( + false + ); + }); + test('is true when one window contains the other', () => { expect(windowsOverlap(window(12, 1, 12, 31), window(12, 24, 12, 26))).toBe( true @@ -137,15 +181,94 @@ describe('activeThemeFor', () => { expect(activeThemeFor(rows, { day: 15, month: 7, year: 2026 })).toBeNull(); expect(activeThemeFor([], { day: 15, month: 7, year: 2026 })).toBeNull(); }); + + // The API rejects overlapping rows, but a hand-edited one can still overlap: + // the answer is "the first match in the order the caller supplied", which is + // what makes the served skin deterministic instead of luck-of-the-scan. + test('returns the first matching row when two contain today', () => { + const christmas = { ...window(12, 1, 12, 31), theme: 'christmas' }; + const spooky = { ...window(12, 24, 12, 26), theme: 'halloween' }; + const today = { day: 25, month: 12, year: 2026 }; + + expect(activeThemeFor([christmas, spooky], today)).toBe('christmas'); + expect(activeThemeFor([spooky, christmas], today)).toBe('halloween'); + }); +}); + +describe('todayInTimeZone', () => { + test('reads the wall-clock day of the zone, not the instant’s UTC day', () => { + // 23:30 UTC on 31 December is already 00:30 on 1 January in Budapest. + const instant = new Date('2026-12-31T23:30:00Z'); + + expect(todayInTimeZone(instant, 'Europe/Budapest')).toEqual({ + day: 1, + month: 1, + year: 2027, + }); + expect(todayInTimeZone(instant, 'America/New_York')).toEqual({ + day: 31, + month: 12, + year: 2026, + }); + }); +}); + +describe('resolveTheme', () => { + const easterRow = { ...window(3, 29, 4, 6), theme: 'summer' }; + const halloween = { ...window(10, 25, 11, 2), theme: 'halloween' }; + + test('Easter beats a row that contains today', () => { + expect( + resolveTheme('christmas', [easterRow], { + day: 31, + month: 3, + year: 2026, + }) + ).toEqual({ source: 'schedule', theme: 'easter' }); + }); + + test('a containing row beats the stored theme', () => { + expect( + resolveTheme('christmas', [halloween], { + day: 31, + month: 10, + year: 2026, + }) + ).toEqual({ source: 'schedule', theme: 'halloween' }); + }); + + test('no match returns the stored theme as manual', () => { + expect( + resolveTheme('christmas', [halloween], { + day: 15, + month: 7, + year: 2026, + }) + ).toEqual({ source: 'manual', theme: 'christmas' }); + }); + + test('a row naming the stored theme still reports the schedule', () => { + expect( + resolveTheme('halloween', [halloween], { + day: 31, + month: 10, + year: 2026, + }) + ).toEqual({ source: 'schedule', theme: 'halloween' }); + }); }); describe('isRealMonthDay', () => { - test('accepts real days, including 29 February', () => { + test('accepts days every year has', () => { expect(isRealMonthDay(1, 31)).toBe(true); - expect(isRealMonthDay(2, 29)).toBe(true); + expect(isRealMonthDay(2, 28)).toBe(true); expect(isRealMonthDay(12, 31)).toBe(true); }); + test('rejects 29 February, which an annual window cannot mean', () => { + expect(isRealMonthDay(2, 29)).toBe(false); + }); + test('rejects impossible days', () => { expect(isRealMonthDay(2, 30)).toBe(false); expect(isRealMonthDay(4, 31)).toBe(false); diff --git a/apps/chronos/src/modules/theme/utils/schedule.ts b/apps/chronos/src/modules/theme/utils/schedule.ts index fe1972bf..61d438f9 100644 --- a/apps/chronos/src/modules/theme/utils/schedule.ts +++ b/apps/chronos/src/modules/theme/utils/schedule.ts @@ -4,13 +4,12 @@ * * Deliberately pure — no database, no logger, no app imports — because it runs * inside `GET /theme`, the endpoint in every visitor's first paint. The caller - * loads the schedule rows and supplies today's wall-clock date in the school's - * time zone. + * loads the schedule rows and the stored manual value, and supplies the date. * * Resolution order: * 1. Easter (movable, so code rather than a row) — wins over every row. * 2. The schedule row whose annual window contains today. - * 3. Nothing in season — the caller falls back to the manually pinned skin. + * 3. Nothing in season — the manually pinned skin. */ /** A month/day pair without a year; `annual` windows repeat every year. */ @@ -27,14 +26,26 @@ export type ScheduledWindow = AnnualWindow & { theme: string }; /** A calendar day, as the school's wall clock sees it. */ export type CalendarDay = { year: number; month: number; day: number }; +/** Where the skin `GET /theme` serves came from. */ +export type ThemeResolution = { + source: 'schedule' | 'manual'; + theme: string; +}; + /** * The skin Easter selects. There is no row for it: Easter Sunday moves between * 22 March and 25 April, which a month/day pair cannot express. */ const EASTER_THEME = 'easter'; -/** Days in each month of a leap year, so 29 February is representable. */ -const DAYS_IN_MONTH = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; +/** + * Days in each month of a **non-leap** year. An annual window has to mean the + * same thing every year, so 29 February is not a representable window day — + * a window ending `02-29` would otherwise stop a day early in three years of + * four. `isRealMonthDay` rejects it; the leap day is handled where it belongs, + * in `dayOfYear`. + */ +const DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; /** `MMDD` as one number, so a window is a plain range comparison. */ const ordinal = (month: number, day: number): number => month * 100 + day; @@ -42,7 +53,11 @@ const ordinal = (month: number, day: number): number => month * 100 + day; const isLeapYear = (year: number): boolean => (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; -/** 1-based day of the year; the basis for offsets around a movable feast. */ +/** + * 1-based day of the year; the basis for offsets around a movable feast. The + * base table is the non-leap one, so February gains its extra day exactly once + * when the year is a leap year. + */ const dayOfYear = (year: number, month: number, day: number): number => { let total = day; for (let m = 1; m < month; m += 1) { @@ -51,12 +66,34 @@ const dayOfYear = (year: number, month: number, day: number): number => { return total; }; -/** True when `month`/`day` is a real calendar day (29 February is accepted). */ +/** True when `month`/`day` is a date every year has (29 February is rejected). */ export const isRealMonthDay = (month: number, day: number): boolean => { const max = DAYS_IN_MONTH[month - 1]; return max !== undefined && day >= 1 && day <= max; }; +/** + * Today as `timeZone`'s wall clock sees it — the date every window is measured + * against. `CHRONOS_TIME_ZONE` is configuration, not UTC, because "is it + * Christmas yet" is a local-calendar question. + * + * Parts rather than `toISOString()`: the instant is not the calendar day, and + * the zone's offset is what turns one into the other. + */ +export const todayInTimeZone = (date: Date, timeZone: string): CalendarDay => { + const parts = new Intl.DateTimeFormat('en-US', { + day: 'numeric', + month: 'numeric', + timeZone, + year: 'numeric', + }).formatToParts(date); + + const part = (type: Intl.DateTimeFormatPartTypes): number => + Number(parts.find((candidate) => candidate.type === type)?.value); + + return { day: part('day'), month: part('month'), year: part('year') }; +}; + /** * Inclusive containment, wrap-around aware: `12-28 → 01-02` contains 31 * December and 1 January, and a single-day window (`start === end`) contains @@ -120,7 +157,8 @@ export const easterWindowContains = ( /** * The skin for `today`, or null when nothing is in season and the caller should * use the manually pinned one. Easter wins over any row, so a row overlapping - * it never shadows the feast. + * it never shadows the feast. Between rows the first match wins, which is why + * the caller reads them in a stable order. */ export const activeThemeFor = ( rows: readonly ScheduledWindow[], @@ -137,9 +175,29 @@ export const activeThemeFor = ( return row?.theme ?? null; }; +/** + * The whole rule, in one place: Easter, then a containing row, then the stored + * manual value. `source` says which step answered, so the caller can log it. + * + * A row that names the same skin as the manual pick still reports `schedule`: + * the schedule is what put it there, and that is what an admin debugging a + * surprising skin needs to see. + */ +export const resolveTheme = ( + storedTheme: string, + rows: readonly ScheduledWindow[], + today: CalendarDay +): ThemeResolution => { + const scheduled = activeThemeFor(rows, today); + + return scheduled === null + ? { source: 'manual', theme: storedTheme } + : { source: 'schedule', theme: scheduled }; +}; + /** * Whether two annual windows share at least one calendar day. A day-by-day scan - * over a leap year is the obviously-correct implementation — windows are + * over a non-leap year is the obviously-correct implementation — windows are * month/day ranges that may wrap the year end, and this is a handful of rows on * an admin write path, not a hot loop. */ From 960461f1db26b0c37ac0eafeede7a269ab848773 Mon Sep 17 00:00:00 2001 From: Dasa122 Date: Tue, 17 Nov 2026 15:18:32 +0100 Subject: [PATCH 06/13] fix(api): name the id-addressed theme schedule operations ById --- apps/chronos/openapi/chronos-openapi.json | 4 ++-- packages/api/src/contract/theme.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/chronos/openapi/chronos-openapi.json b/apps/chronos/openapi/chronos-openapi.json index b1520f68..10eed754 100644 --- a/apps/chronos/openapi/chronos-openapi.json +++ b/apps/chronos/openapi/chronos-openapi.json @@ -36266,7 +36266,7 @@ }, "/theme/schedule/{id}": { "delete": { - "operationId": "deleteThemeSchedule", + "operationId": "deleteThemeScheduleById", "description": "Remove an annual window from the theme schedule.", "tags": [ "Theme" @@ -36492,7 +36492,7 @@ ] }, "patch": { - "operationId": "patchThemeSchedule", + "operationId": "patchThemeScheduleById", "description": "Edit an annual window of the theme schedule. The merged window may not overlap another row.", "tags": [ "Theme" diff --git a/packages/api/src/contract/theme.ts b/packages/api/src/contract/theme.ts index 36a03479..ea88452e 100644 --- a/packages/api/src/contract/theme.ts +++ b/packages/api/src/contract/theme.ts @@ -59,7 +59,7 @@ export const themeContract = { auth: true, description: 'Remove an annual window from the theme schedule.', method: 'DELETE', - operationId: 'deleteThemeSchedule', + operationId: 'deleteThemeScheduleById', path: '/theme/schedule/{id}', tags: THEME_TAGS, }) @@ -86,7 +86,7 @@ export const themeContract = { description: 'Edit an annual window of the theme schedule. The merged window may not overlap another row.', method: 'PATCH', - operationId: 'patchThemeSchedule', + operationId: 'patchThemeScheduleById', path: '/theme/schedule/{id}', tags: THEME_TAGS, }) From 7f5c09ed34bf3ae2e36b01fb0d5095282bdc87ff Mon Sep 17 00:00:00 2001 From: Dasa122 Date: Tue, 17 Nov 2026 15:20:23 +0100 Subject: [PATCH 07/13] fix(iris): keep the schedule dialog's days honest and its copy precise --- apps/iris/public/locales/en/translation.json | 6 +++--- apps/iris/public/locales/hu/translation.json | 6 +++--- .../admin/theme-schedule-dialog.tsx | 20 +++++++++++++------ .../components/admin/theme-schedule-panel.tsx | 4 ++-- apps/iris/src/routes/_private/admin/theme.tsx | 11 ++++++---- 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/apps/iris/public/locales/en/translation.json b/apps/iris/public/locales/en/translation.json index c57bb674..29fe9a70 100644 --- a/apps/iris/public/locales/en/translation.json +++ b/apps/iris/public/locales/en/translation.json @@ -219,13 +219,13 @@ "currentTheme": "Current theme", "schedule": { "title": "Scheduled skins", - "description": "Windows that switch the skin automatically while they are in season. Easter always wins during its week; otherwise a window here overrides the manual pick above.", + "description": "Windows that switch the skin automatically while they are in season. A window overrides the manual pick above; Easter's own week takes precedence over every window, including one that covers it.", "add": "Add window", "edit": "Edit window", "delete": "Delete window", "save": "Save window", "empty": "No scheduled windows yet.", - "active": "Active now", + "active": "In season", "theme": "Skin", "start": "Starts", "end": "Ends", @@ -233,7 +233,7 @@ "startDay": "Start day", "endMonth": "End month", "endDay": "End day", - "hint": "A window may wrap the year end (for example 12-28 → 01-02). Windows must not overlap; Easter's week is set in code and always wins.", + "hint": "A window may wrap the year end: if the start is after the end it runs forward through the new year (05-20 → 05-10 is 20 May to 10 May of the next year), and a single day is a valid window. Windows must not overlap; Easter's week is set in code and always wins.", "override": "{{theme}} is scheduled until {{window}}, so it overrides the manual pick until that window ends.", "deleteConfirmTitle": "Delete this window?", "deleteConfirmDescription": "{{theme}} will no longer apply automatically between {{window}}.", diff --git a/apps/iris/public/locales/hu/translation.json b/apps/iris/public/locales/hu/translation.json index 9917460c..5a5e7b7d 100644 --- a/apps/iris/public/locales/hu/translation.json +++ b/apps/iris/public/locales/hu/translation.json @@ -201,13 +201,13 @@ "currentTheme": "Jelenlegi téma", "schedule": { "title": "Ütemezett témák", - "description": "Időszakok, amelyekben a téma automatikusan átvált. Húsvét hete mindig nyer; azon kívül az itteni időszak felülírja a fenti kézi választást.", + "description": "Időszakok, amelyekben a téma automatikusan átvált. Az itteni időszak felülírja a fenti kézi választást; Húsvét hete viszont minden időszakot megelőz, még azt is, amelyik lefedi.", "add": "Időszak hozzáadása", "edit": "Időszak szerkesztése", "delete": "Időszak törlése", "save": "Időszak mentése", "empty": "Még nincs ütemezett időszak.", - "active": "Most aktív", + "active": "Szezonban", "theme": "Téma", "start": "Kezdete", "end": "Vége", @@ -215,7 +215,7 @@ "startDay": "Kezdő nap", "endMonth": "Záró hónap", "endDay": "Záró nap", - "hint": "Az időszak átnyúlhat az év végén (például 12-28 → 01-02). Az időszakok nem fedhetik egymást; Húsvét hete a kódban van, és mindig nyer.", + "hint": "Az időszak átnyúlhat az év végén: ha a kezdés később van, mint a vége, az időszak átvisz a következő évre (a 05-20 → 05-10 május 20-tól a következő év május 10-ig tart), és az egynapos időszak is érvényes. Az időszakok nem fedhetik egymást; Húsvét hete a kódban van, és mindig nyer.", "override": "{{window}} között a(z) {{theme}} van ütemezve, ezért az felülírja a kézi választást az időszak végéig.", "deleteConfirmTitle": "Törlöd ezt az időszakot?", "deleteConfirmDescription": "{{window}} között a(z) {{theme}} többé nem érvényesül automatikusan.", diff --git a/apps/iris/src/components/admin/theme-schedule-dialog.tsx b/apps/iris/src/components/admin/theme-schedule-dialog.tsx index caf292c8..61489e66 100644 --- a/apps/iris/src/components/admin/theme-schedule-dialog.tsx +++ b/apps/iris/src/components/admin/theme-schedule-dialog.tsx @@ -37,8 +37,12 @@ type ThemeScheduleFormValues = { const MONTHS = Array.from({ length: 12 }, (_, index) => index + 1); -/** Leap-free maximum each month can hold; 29 February stays representable. */ -const DAYS_IN_MONTH = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; +/** + * The days each month offers. February stops at 28: a window repeats every + * year, so 29 February would name a day that exists in only one year in four. + * The backend rejects it for the same reason. + */ +const DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; const daysInMonth = (month: number): number => DAYS_IN_MONTH[month - 1] ?? 31; @@ -61,12 +65,16 @@ function toFormValues( } const today = new Date(); + const month = today.getMonth() + 1; + // Never seed a day the month's select does not offer — 29 February is not a + // valid window day, so a leap-day "today" becomes the 28th. + const day = Math.min(today.getDate(), daysInMonth(month)); return { - endDay: today.getDate(), - endMonth: today.getMonth() + 1, - startDay: today.getDate(), - startMonth: today.getMonth() + 1, + endDay: day, + endMonth: month, + startDay: day, + startMonth: month, theme: 'default', }; } diff --git a/apps/iris/src/components/admin/theme-schedule-panel.tsx b/apps/iris/src/components/admin/theme-schedule-panel.tsx index 990c82b6..f289c47f 100644 --- a/apps/iris/src/components/admin/theme-schedule-panel.tsx +++ b/apps/iris/src/components/admin/theme-schedule-panel.tsx @@ -70,7 +70,7 @@ export function ThemeSchedulePanel() { {item.active && {t('siteTheme.schedule.active')}}
- + From 6ccbd018f74951204c6806edbd4d3a8f433cc9dc Mon Sep 17 00:00:00 2001 From: Dasa122 Date: Tue, 17 Nov 2026 18:02:03 +0100 Subject: [PATCH 12/13] fix(iris): drop the Easter precedence sentence from the schedule description The behaviour is unchanged; only the schedule description copy lost the Easter clause, in both languages. --- apps/iris/public/locales/en/translation.json | 2 +- apps/iris/public/locales/hu/translation.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/iris/public/locales/en/translation.json b/apps/iris/public/locales/en/translation.json index 29fe9a70..0fbf2973 100644 --- a/apps/iris/public/locales/en/translation.json +++ b/apps/iris/public/locales/en/translation.json @@ -219,7 +219,7 @@ "currentTheme": "Current theme", "schedule": { "title": "Scheduled skins", - "description": "Windows that switch the skin automatically while they are in season. A window overrides the manual pick above; Easter's own week takes precedence over every window, including one that covers it.", + "description": "Windows that switch the skin automatically while they are in season. A window overrides the manual pick above.", "add": "Add window", "edit": "Edit window", "delete": "Delete window", diff --git a/apps/iris/public/locales/hu/translation.json b/apps/iris/public/locales/hu/translation.json index 5a5e7b7d..7a1747e6 100644 --- a/apps/iris/public/locales/hu/translation.json +++ b/apps/iris/public/locales/hu/translation.json @@ -201,7 +201,7 @@ "currentTheme": "Jelenlegi téma", "schedule": { "title": "Ütemezett témák", - "description": "Időszakok, amelyekben a téma automatikusan átvált. Az itteni időszak felülírja a fenti kézi választást; Húsvét hete viszont minden időszakot megelőz, még azt is, amelyik lefedi.", + "description": "Időszakok, amelyekben a téma automatikusan átvált. Az itteni időszak felülírja a fenti kézi választást.", "add": "Időszak hozzáadása", "edit": "Időszak szerkesztése", "delete": "Időszak törlése", From 8f337155aa94a8a0c9da1c4470ffc16507346a50 Mon Sep 17 00:00:00 2001 From: Dasa122 Date: Tue, 17 Nov 2026 21:04:48 +0100 Subject: [PATCH 13/13] chore(chronos): re-emit the theme schedule migration as 0031 --- .../migrations/0031_typical_trish_tilby.sql | 12 + .../migrations/meta/0031_snapshot.json | 4907 +++++++++++++++++ .../database/migrations/meta/_journal.json | 7 + 3 files changed, 4926 insertions(+) create mode 100644 apps/chronos/src/database/migrations/0031_typical_trish_tilby.sql create mode 100644 apps/chronos/src/database/migrations/meta/0031_snapshot.json diff --git a/apps/chronos/src/database/migrations/0031_typical_trish_tilby.sql b/apps/chronos/src/database/migrations/0031_typical_trish_tilby.sql new file mode 100644 index 00000000..160d1883 --- /dev/null +++ b/apps/chronos/src/database/migrations/0031_typical_trish_tilby.sql @@ -0,0 +1,12 @@ +CREATE TABLE "site_theme_schedule" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "theme" text NOT NULL, + "start_month" integer NOT NULL, + "start_day" integer NOT NULL, + "end_month" integer NOT NULL, + "end_day" integer NOT NULL, + "updated_at" timestamp DEFAULT now() NOT NULL, + "updated_by" uuid +); +--> statement-breakpoint +ALTER TABLE "site_theme_schedule" ADD CONSTRAINT "site_theme_schedule_updated_by_user_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action; \ No newline at end of file diff --git a/apps/chronos/src/database/migrations/meta/0031_snapshot.json b/apps/chronos/src/database/migrations/meta/0031_snapshot.json new file mode 100644 index 00000000..4658cc74 --- /dev/null +++ b/apps/chronos/src/database/migrations/meta/0031_snapshot.json @@ -0,0 +1,4907 @@ +{ + "id": "a26be74f-6418-4dc9-a33d-3e3a4a5706fa", + "prevId": "cf219c1a-199e-4136-884f-78015650ee33", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.apikey": { + "name": "apikey", + "schema": "", + "columns": { + "config_id": { + "name": "config_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'default'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "pg_catalog.gen_random_uuid()" + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_refill_at": { + "name": "last_refill_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_request": { + "name": "last_request", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "permissions": { + "name": "permissions", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "prefix": { + "name": "prefix", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rate_limit_enabled": { + "name": "rate_limit_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "rate_limit_max": { + "name": "rate_limit_max", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "rate_limit_time_window": { + "name": "rate_limit_time_window", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "reference_id": { + "name": "reference_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refill_amount": { + "name": "refill_amount", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "refill_interval": { + "name": "refill_interval", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "remaining": { + "name": "remaining", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "request_count": { + "name": "request_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "start": { + "name": "start", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "apikey_config_id_idx": { + "name": "apikey_config_id_idx", + "columns": [ + { + "expression": "config_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "apikey_key_idx": { + "name": "apikey_key_idx", + "columns": [ + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "apikey_reference_id_idx": { + "name": "apikey_reference_id_idx", + "columns": [ + { + "expression": "reference_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.account": { + "name": "account", + "schema": "", + "columns": { + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "pg_catalog.gen_random_uuid()" + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "account_userId_idx": { + "name": "account_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "account_user_id_user_id_fk": { + "name": "account_user_id_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.session": { + "name": "session", + "schema": "", + "columns": { + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "pg_catalog.gen_random_uuid()" + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "session_userId_idx": { + "name": "session_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user": { + "name": "user", + "schema": "", + "columns": { + "cohort_id": { + "name": "cohort_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "pg_catalog.gen_random_uuid()" + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "nickname": { + "name": "nickname", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "roles": { + "name": "roles", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{\"user\"}'" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.verification": { + "name": "verification", + "schema": "", + "columns": { + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "pg_catalog.gen_random_uuid()" + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "verification_identifier_idx": { + "name": "verification_identifier_idx", + "columns": [ + { + "expression": "identifier", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.role": { + "name": "role", + "schema": "", + "columns": { + "can": { + "name": "can", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "role_name_unique": { + "name": "role_name_unique", + "nullsNotDistinct": false, + "columns": [ + "name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.activity_log": { + "name": "activity_log", + "schema": "", + "columns": { + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "activity_log_actor_id_idx": { + "name": "activity_log_actor_id_idx", + "columns": [ + { + "expression": "actor_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "activity_log_created_at_idx": { + "name": "activity_log_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "activity_log_entity_type_idx": { + "name": "activity_log_entity_type_idx", + "columns": [ + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "activity_log_actor_id_user_id_fk": { + "name": "activity_log_actor_id_user_id_fk", + "tableFrom": "activity_log", + "tableTo": "user", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.bug_report": { + "name": "bug_report", + "schema": "", + "columns": { + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "page": { + "name": "page", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reporter_email": { + "name": "reporter_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reporter_id": { + "name": "reporter_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "bug_report_status_idx": { + "name": "bug_report_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "bug_report_reporter_id_user_id_fk": { + "name": "bug_report_reporter_id_user_id_fk", + "tableFrom": "bug_report", + "tableTo": "user", + "columnsFrom": [ + "reporter_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.audit_log": { + "name": "audit_log", + "schema": "", + "columns": { + "button_pressed": { + "name": "button_pressed", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "card_data": { + "name": "card_data", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "card_id": { + "name": "card_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "device_id": { + "name": "device_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "result": { + "name": "result", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "audit_log_card_id_card_id_fk": { + "name": "audit_log_card_id_card_id_fk", + "tableFrom": "audit_log", + "tableTo": "card", + "columnsFrom": [ + "card_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "audit_log_device_id_device_id_fk": { + "name": "audit_log_device_id_device_id_fk", + "tableFrom": "audit_log", + "tableTo": "device", + "columnsFrom": [ + "device_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "audit_log_user_id_user_id_fk": { + "name": "audit_log_user_id_user_id_fk", + "tableFrom": "audit_log", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.card": { + "name": "card", + "schema": "", + "columns": { + "card_uid": { + "name": "card_uid", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "frozen": { + "name": "frozen", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "card_user_id_user_id_fk": { + "name": "card_user_id_user_id_fk", + "tableFrom": "card", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "card_card_uid_unique": { + "name": "card_card_uid_unique", + "nullsNotDistinct": false, + "columns": [ + "card_uid" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.card_device": { + "name": "card_device", + "schema": "", + "columns": { + "card_id": { + "name": "card_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "device_id": { + "name": "device_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "card_device_card_id_idx": { + "name": "card_device_card_id_idx", + "columns": [ + { + "expression": "card_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "card_device_device_id_idx": { + "name": "card_device_device_id_idx", + "columns": [ + { + "expression": "device_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "card_device_card_id_card_id_fk": { + "name": "card_device_card_id_card_id_fk", + "tableFrom": "card_device", + "tableTo": "card", + "columnsFrom": [ + "card_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "card_device_device_id_device_id_fk": { + "name": "card_device_device_id_device_id_fk", + "tableFrom": "card_device", + "tableTo": "device", + "columnsFrom": [ + "device_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "card_device_card_id_device_id_pk": { + "name": "card_device_card_id_device_id_pk", + "columns": [ + "card_id", + "device_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.device": { + "name": "device", + "schema": "", + "columns": { + "api_token": { + "name": "api_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "last_reset_reason": { + "name": "last_reset_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "device_api_token_unique": { + "name": "device_api_token_unique", + "nullsNotDistinct": false, + "columns": [ + "api_token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.device_health": { + "name": "device_health", + "schema": "", + "columns": { + "device_id": { + "name": "device_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "device_meta": { + "name": "device_meta", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "device_health_device_id_device_id_fk": { + "name": "device_health_device_id_device_id_fk", + "tableFrom": "device_health", + "tableTo": "device", + "columnsFrom": [ + "device_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.kiosk": { + "name": "kiosk", + "schema": "", + "columns": { + "app_version": { + "name": "app_version", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "config": { + "name": "config", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_seen_ip": { + "name": "last_seen_ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "machine_id": { + "name": "machine_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "kiosk_machine_id_unique": { + "name": "kiosk_machine_id_unique", + "nullsNotDistinct": false, + "columns": [ + "machine_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.navigator_corridor": { + "name": "navigator_corridor", + "schema": "", + "columns": { + "barrier_free": { + "name": "barrier_free", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "building_id": { + "name": "building_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "is_outdoor": { + "name": "is_outdoor", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "storey": { + "name": "storey", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "x1": { + "name": "x1", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "x2": { + "name": "x2", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "y1": { + "name": "y1", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "y2": { + "name": "y2", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "navigator_corridor_building_id_idx": { + "name": "navigator_corridor_building_id_idx", + "columns": [ + { + "expression": "building_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "navigator_corridor_building_id_building_id_fk": { + "name": "navigator_corridor_building_id_building_id_fk", + "tableFrom": "navigator_corridor", + "tableTo": "building", + "columnsFrom": [ + "building_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.navigator_lift": { + "name": "navigator_lift", + "schema": "", + "columns": { + "building_id": { + "name": "building_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "max_storey": { + "name": "max_storey", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "min_storey": { + "name": "min_storey", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "navigator_lift_building_id_idx": { + "name": "navigator_lift_building_id_idx", + "columns": [ + { + "expression": "building_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "navigator_lift_building_id_building_id_fk": { + "name": "navigator_lift_building_id_building_id_fk", + "tableFrom": "navigator_lift", + "tableTo": "building", + "columnsFrom": [ + "building_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.navigator_stair": { + "name": "navigator_stair", + "schema": "", + "columns": { + "building_id": { + "name": "building_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "max_storey": { + "name": "max_storey", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "min_storey": { + "name": "min_storey", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rotation": { + "name": "rotation", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "navigator_stair_building_id_idx": { + "name": "navigator_stair_building_id_idx", + "columns": [ + { + "expression": "building_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "navigator_stair_building_id_building_id_fk": { + "name": "navigator_stair_building_id_building_id_fk", + "tableFrom": "navigator_stair", + "tableTo": "building", + "columnsFrom": [ + "building_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.navigator_translation": { + "name": "navigator_translation", + "schema": "", + "columns": { + "lang_key": { + "name": "lang_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text_key": { + "name": "text_key", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "navigator_translation_lang_key_text_key_pk": { + "name": "navigator_translation_lang_key_text_key_pk", + "columns": [ + "lang_key", + "text_key" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.announcement": { + "name": "announcement", + "schema": "", + "columns": { + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "highlighted": { + "name": "highlighted", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "image_byte_size": { + "name": "image_byte_size", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "image_content_type": { + "name": "image_content_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "image_key": { + "name": "image_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "image_updated_at": { + "name": "image_updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "kiosk_only": { + "name": "kiosk_only", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "valid_from": { + "name": "valid_from", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "valid_until": { + "name": "valid_until", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "announcement_author_id_user_id_fk": { + "name": "announcement_author_id_user_id_fk", + "tableFrom": "announcement", + "tableTo": "user", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "announcement_image_complete": { + "name": "announcement_image_complete", + "value": "(\"announcement\".\"image_key\" IS NULL) = (\"announcement\".\"image_content_type\" IS NULL)\n AND (\"announcement\".\"image_key\" IS NULL) = (\"announcement\".\"image_byte_size\" IS NULL)\n AND (\"announcement\".\"image_key\" IS NULL) = (\"announcement\".\"image_updated_at\" IS NULL)" + } + }, + "isRLSEnabled": false + }, + "public.announcement_cohort_mtm": { + "name": "announcement_cohort_mtm", + "schema": "", + "columns": { + "announcement_id": { + "name": "announcement_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cohort_id": { + "name": "cohort_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "announcement_cohort_mtm_announcement_id_idx": { + "name": "announcement_cohort_mtm_announcement_id_idx", + "columns": [ + { + "expression": "announcement_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "announcement_cohort_mtm_cohort_id_idx": { + "name": "announcement_cohort_mtm_cohort_id_idx", + "columns": [ + { + "expression": "cohort_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "announcement_cohort_mtm_announcement_id_announcement_id_fk": { + "name": "announcement_cohort_mtm_announcement_id_announcement_id_fk", + "tableFrom": "announcement_cohort_mtm", + "tableTo": "announcement", + "columnsFrom": [ + "announcement_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "announcement_cohort_mtm_cohort_id_cohort_id_fk": { + "name": "announcement_cohort_mtm_cohort_id_cohort_id_fk", + "tableFrom": "announcement_cohort_mtm", + "tableTo": "cohort", + "columnsFrom": [ + "cohort_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "announcement_cohort_mtm_announcement_id_cohort_id_pk": { + "name": "announcement_cohort_mtm_announcement_id_cohort_id_pk", + "columns": [ + "announcement_id", + "cohort_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.announcement_kiosk_mtm": { + "name": "announcement_kiosk_mtm", + "schema": "", + "columns": { + "announcement_id": { + "name": "announcement_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kiosk_id": { + "name": "kiosk_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "announcement_kiosk_mtm_announcement_id_idx": { + "name": "announcement_kiosk_mtm_announcement_id_idx", + "columns": [ + { + "expression": "announcement_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "announcement_kiosk_mtm_kiosk_id_idx": { + "name": "announcement_kiosk_mtm_kiosk_id_idx", + "columns": [ + { + "expression": "kiosk_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "announcement_kiosk_mtm_announcement_id_announcement_id_fk": { + "name": "announcement_kiosk_mtm_announcement_id_announcement_id_fk", + "tableFrom": "announcement_kiosk_mtm", + "tableTo": "announcement", + "columnsFrom": [ + "announcement_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "announcement_kiosk_mtm_kiosk_id_kiosk_id_fk": { + "name": "announcement_kiosk_mtm_kiosk_id_kiosk_id_fk", + "tableFrom": "announcement_kiosk_mtm", + "tableTo": "kiosk", + "columnsFrom": [ + "kiosk_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "announcement_kiosk_mtm_announcement_id_kiosk_id_pk": { + "name": "announcement_kiosk_mtm_announcement_id_kiosk_id_pk", + "columns": [ + "announcement_id", + "kiosk_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.blog_post": { + "name": "blog_post", + "schema": "", + "columns": { + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "published_at": { + "name": "published_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "blog_post_author_id_user_id_fk": { + "name": "blog_post_author_id_user_id_fk", + "tableFrom": "blog_post", + "tableTo": "user", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "blog_post_slug_unique": { + "name": "blog_post_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.system_message": { + "name": "system_message", + "schema": "", + "columns": { + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "valid_from": { + "name": "valid_from", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "valid_until": { + "name": "valid_until", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "system_message_author_id_user_id_fk": { + "name": "system_message_author_id_user_id_fk", + "tableFrom": "system_message", + "tableTo": "user", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.system_message_cohort_mtm": { + "name": "system_message_cohort_mtm", + "schema": "", + "columns": { + "cohort_id": { + "name": "cohort_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "system_message_id": { + "name": "system_message_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "system_message_cohort_mtm_system_message_id_idx": { + "name": "system_message_cohort_mtm_system_message_id_idx", + "columns": [ + { + "expression": "system_message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "system_message_cohort_mtm_cohort_id_idx": { + "name": "system_message_cohort_mtm_cohort_id_idx", + "columns": [ + { + "expression": "cohort_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "system_message_cohort_mtm_cohort_id_cohort_id_fk": { + "name": "system_message_cohort_mtm_cohort_id_cohort_id_fk", + "tableFrom": "system_message_cohort_mtm", + "tableTo": "cohort", + "columnsFrom": [ + "cohort_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "system_message_cohort_mtm_system_message_id_system_message_id_fk": { + "name": "system_message_cohort_mtm_system_message_id_system_message_id_fk", + "tableFrom": "system_message_cohort_mtm", + "tableTo": "system_message", + "columnsFrom": [ + "system_message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "system_message_cohort_mtm_system_message_id_cohort_id_pk": { + "name": "system_message_cohort_mtm_system_message_id_cohort_id_pk", + "columns": [ + "system_message_id", + "cohort_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.fcm_token": { + "name": "fcm_token", + "schema": "", + "columns": { + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "device_info": { + "name": "device_info", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "fcm_token_user_id_token_unique": { + "name": "fcm_token_user_id_token_unique", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "fcm_token_user_id_user_id_fk": { + "name": "fcm_token_user_id_user_id_fk", + "tableFrom": "fcm_token", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notification": { + "name": "notification", + "schema": "", + "columns": { + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "read": { + "name": "read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "notification_user_id_created_at_idx": { + "name": "notification_user_id_created_at_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": false, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_created_at_idx": { + "name": "notification_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notification_user_id_user_id_fk": { + "name": "notification_user_id_user_id_fk", + "tableFrom": "notification", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_preferences": { + "name": "user_preferences", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "color_scheme": { + "name": "color_scheme", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'default'" + }, + "language": { + "name": "language", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'hu'" + }, + "notification_preferences": { + "name": "notification_preferences", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"announcement\":true,\"blogPost\":false,\"channelsEnabled\":true,\"doorlockCardUsed\":false,\"movedLesson\":true,\"substitution\":true,\"systemMessage\":true}'::jsonb" + }, + "site_theme_acknowledged": { + "name": "site_theme_acknowledged", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "site_theme_enabled": { + "name": "site_theme_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "theme": { + "name": "theme", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'system'" + }, + "timetable_class_colors": { + "name": "timetable_class_colors", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "timetable_group_display": { + "name": "timetable_group_display", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'highlight'" + }, + "timetable_view": { + "name": "timetable_view", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'class'" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_preferences_user_id_user_id_fk": { + "name": "user_preferences_user_id_user_id_fk", + "tableFrom": "user_preferences", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_preferences_user_id_unique": { + "name": "user_preferences_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.site_theme": { + "name": "site_theme", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "default": "'default'" + }, + "theme": { + "name": "theme", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'default'" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "site_theme_updated_by_user_id_fk": { + "name": "site_theme_updated_by_user_id_fk", + "tableFrom": "site_theme", + "tableTo": "user", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.site_theme_schedule": { + "name": "site_theme_schedule", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "theme": { + "name": "theme", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start_month": { + "name": "start_month", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "start_day": { + "name": "start_day", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "end_month": { + "name": "end_month", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "end_day": { + "name": "end_day", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "site_theme_schedule_updated_by_user_id_fk": { + "name": "site_theme_schedule_updated_by_user_id_fk", + "tableFrom": "site_theme_schedule", + "tableTo": "user", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.building": { + "name": "building", + "schema": "", + "columns": { + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "mapped": { + "name": "mapped", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.classroom": { + "name": "classroom", + "schema": "", + "columns": { + "building_id": { + "name": "building_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "capacity": { + "name": "capacity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "mapped": { + "name": "mapped", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rotation": { + "name": "rotation", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "short": { + "name": "short", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "size_x": { + "name": "size_x", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 6 + }, + "size_y": { + "name": "size_y", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 6 + }, + "size_z": { + "name": "size_z", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 3 + }, + "storey": { + "name": "storey", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "type_id": { + "name": "type_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "classroom_building_id_idx": { + "name": "classroom_building_id_idx", + "columns": [ + { + "expression": "building_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "classroom_type_id_idx": { + "name": "classroom_type_id_idx", + "columns": [ + { + "expression": "type_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "classroom_building_id_building_id_fk": { + "name": "classroom_building_id_building_id_fk", + "tableFrom": "classroom", + "tableTo": "building", + "columnsFrom": [ + "building_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "classroom_type_id_classroom_type_id_fk": { + "name": "classroom_type_id_classroom_type_id_fk", + "tableFrom": "classroom", + "tableTo": "classroom_type", + "columnsFrom": [ + "type_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.classroom_type": { + "name": "classroom_type", + "schema": "", + "columns": { + "colorhex": { + "name": "colorhex", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.cohort": { + "name": "cohort", + "schema": "", + "columns": { + "classroom_ids": { + "name": "classroom_ids", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "short": { + "name": "short", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "teacher_id": { + "name": "teacher_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "timetable_id": { + "name": "timetable_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "cohort_teacher_id_teacher_id_fk": { + "name": "cohort_teacher_id_teacher_id_fk", + "tableFrom": "cohort", + "tableTo": "teacher", + "columnsFrom": [ + "teacher_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cohort_timetable_id_timetable_id_fk": { + "name": "cohort_timetable_id_timetable_id_fk", + "tableFrom": "cohort", + "tableTo": "timetable", + "columnsFrom": [ + "timetable_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.group": { + "name": "group", + "schema": "", + "columns": { + "cohort_id": { + "name": "cohort_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "division_tag": { + "name": "division_tag", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "entire_class": { + "name": "entire_class", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "student_count": { + "name": "student_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "teacher_id": { + "name": "teacher_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "group_cohort_id_cohort_id_fk": { + "name": "group_cohort_id_cohort_id_fk", + "tableFrom": "group", + "tableTo": "cohort", + "columnsFrom": [ + "cohort_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "group_teacher_id_teacher_id_fk": { + "name": "group_teacher_id_teacher_id_fk", + "tableFrom": "group", + "tableTo": "teacher", + "columnsFrom": [ + "teacher_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.cohort_timetable_mtm": { + "name": "cohort_timetable_mtm", + "schema": "", + "columns": { + "cohort_id": { + "name": "cohort_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "timetable_id": { + "name": "timetable_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "cohort_timetable_mtm_timetable_id_idx": { + "name": "cohort_timetable_mtm_timetable_id_idx", + "columns": [ + { + "expression": "timetable_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cohort_timetable_mtm_cohort_id_cohort_id_fk": { + "name": "cohort_timetable_mtm_cohort_id_cohort_id_fk", + "tableFrom": "cohort_timetable_mtm", + "tableTo": "cohort", + "columnsFrom": [ + "cohort_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cohort_timetable_mtm_timetable_id_timetable_id_fk": { + "name": "cohort_timetable_mtm_timetable_id_timetable_id_fk", + "tableFrom": "cohort_timetable_mtm", + "tableTo": "timetable", + "columnsFrom": [ + "timetable_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "cohort_timetable_mtm_cohort_id_timetable_id_pk": { + "name": "cohort_timetable_mtm_cohort_id_timetable_id_pk", + "columns": [ + "cohort_id", + "timetable_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.day_definition": { + "name": "day_definition", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "days": { + "name": "days", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "short": { + "name": "short", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.lesson": { + "name": "lesson", + "schema": "", + "columns": { + "classroom_ids": { + "name": "classroom_ids", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "day_definition_id": { + "name": "day_definition_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "group_ids": { + "name": "group_ids", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "period_id": { + "name": "period_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "periods_per_week": { + "name": "periods_per_week", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "subject_id": { + "name": "subject_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "teacher_ids": { + "name": "teacher_ids", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "term_definition_id": { + "name": "term_definition_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "timetable_id": { + "name": "timetable_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "weeks_definition_id": { + "name": "weeks_definition_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "lesson_day_definition_id_day_definition_id_fk": { + "name": "lesson_day_definition_id_day_definition_id_fk", + "tableFrom": "lesson", + "tableTo": "day_definition", + "columnsFrom": [ + "day_definition_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "lesson_period_id_period_id_fk": { + "name": "lesson_period_id_period_id_fk", + "tableFrom": "lesson", + "tableTo": "period", + "columnsFrom": [ + "period_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "lesson_subject_id_subject_id_fk": { + "name": "lesson_subject_id_subject_id_fk", + "tableFrom": "lesson", + "tableTo": "subject", + "columnsFrom": [ + "subject_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "lesson_term_definition_id_term_definition_id_fk": { + "name": "lesson_term_definition_id_term_definition_id_fk", + "tableFrom": "lesson", + "tableTo": "term_definition", + "columnsFrom": [ + "term_definition_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "lesson_timetable_id_timetable_id_fk": { + "name": "lesson_timetable_id_timetable_id_fk", + "tableFrom": "lesson", + "tableTo": "timetable", + "columnsFrom": [ + "timetable_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "lesson_weeks_definition_id_week_definition_id_fk": { + "name": "lesson_weeks_definition_id_week_definition_id_fk", + "tableFrom": "lesson", + "tableTo": "week_definition", + "columnsFrom": [ + "weeks_definition_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.lesson_cohort_mtm": { + "name": "lesson_cohort_mtm", + "schema": "", + "columns": { + "cohort_id": { + "name": "cohort_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "lesson_id": { + "name": "lesson_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "lesson_cohort_mtm_cohort_id_cohort_id_fk": { + "name": "lesson_cohort_mtm_cohort_id_cohort_id_fk", + "tableFrom": "lesson_cohort_mtm", + "tableTo": "cohort", + "columnsFrom": [ + "cohort_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "lesson_cohort_mtm_lesson_id_lesson_id_fk": { + "name": "lesson_cohort_mtm_lesson_id_lesson_id_fk", + "tableFrom": "lesson_cohort_mtm", + "tableTo": "lesson", + "columnsFrom": [ + "lesson_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "lesson_cohort_mtm_lesson_id_cohort_id_pk": { + "name": "lesson_cohort_mtm_lesson_id_cohort_id_pk", + "columns": [ + "lesson_id", + "cohort_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.moved_lesson": { + "name": "moved_lesson", + "schema": "", + "columns": { + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "manual_cohort_ids": { + "name": "manual_cohort_ids", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "manual_source_room_id": { + "name": "manual_source_room_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "manual_subject_id": { + "name": "manual_subject_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "manual_teacher_ids": { + "name": "manual_teacher_ids", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "room": { + "name": "room", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "starting_day": { + "name": "starting_day", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "starting_period": { + "name": "starting_period", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "moved_lesson_manual_source_room_id_classroom_id_fk": { + "name": "moved_lesson_manual_source_room_id_classroom_id_fk", + "tableFrom": "moved_lesson", + "tableTo": "classroom", + "columnsFrom": [ + "manual_source_room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "moved_lesson_manual_subject_id_subject_id_fk": { + "name": "moved_lesson_manual_subject_id_subject_id_fk", + "tableFrom": "moved_lesson", + "tableTo": "subject", + "columnsFrom": [ + "manual_subject_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "moved_lesson_room_classroom_id_fk": { + "name": "moved_lesson_room_classroom_id_fk", + "tableFrom": "moved_lesson", + "tableTo": "classroom", + "columnsFrom": [ + "room" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "moved_lesson_starting_day_day_definition_id_fk": { + "name": "moved_lesson_starting_day_day_definition_id_fk", + "tableFrom": "moved_lesson", + "tableTo": "day_definition", + "columnsFrom": [ + "starting_day" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "moved_lesson_starting_period_period_id_fk": { + "name": "moved_lesson_starting_period_period_id_fk", + "tableFrom": "moved_lesson", + "tableTo": "period", + "columnsFrom": [ + "starting_period" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.moved_lesson_lesson_mtm": { + "name": "moved_lesson_lesson_mtm", + "schema": "", + "columns": { + "lesson_id": { + "name": "lesson_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "moved_lesson_id": { + "name": "moved_lesson_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "moved_lesson_lesson_mtm_lesson_id_lesson_id_fk": { + "name": "moved_lesson_lesson_mtm_lesson_id_lesson_id_fk", + "tableFrom": "moved_lesson_lesson_mtm", + "tableTo": "lesson", + "columnsFrom": [ + "lesson_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "moved_lesson_lesson_mtm_moved_lesson_id_moved_lesson_id_fk": { + "name": "moved_lesson_lesson_mtm_moved_lesson_id_moved_lesson_id_fk", + "tableFrom": "moved_lesson_lesson_mtm", + "tableTo": "moved_lesson", + "columnsFrom": [ + "moved_lesson_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "moved_lesson_lesson_mtm_lesson_id_moved_lesson_id_pk": { + "name": "moved_lesson_lesson_mtm_lesson_id_moved_lesson_id_pk", + "columns": [ + "lesson_id", + "moved_lesson_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.period": { + "name": "period", + "schema": "", + "columns": { + "end_time": { + "name": "end_time", + "type": "time", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "period": { + "name": "period", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "start_time": { + "name": "start_time", + "type": "time", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.subject": { + "name": "subject", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "short": { + "name": "short", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.substitution": { + "name": "substitution", + "schema": "", + "columns": { + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "substituter": { + "name": "substituter", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "substitution_substituter_teacher_id_fk": { + "name": "substitution_substituter_teacher_id_fk", + "tableFrom": "substitution", + "tableTo": "teacher", + "columnsFrom": [ + "substituter" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.substitution_lesson_mtm": { + "name": "substitution_lesson_mtm", + "schema": "", + "columns": { + "lesson_id": { + "name": "lesson_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "substitution_id": { + "name": "substitution_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "substitution_lesson_mtm_lesson_id_lesson_id_fk": { + "name": "substitution_lesson_mtm_lesson_id_lesson_id_fk", + "tableFrom": "substitution_lesson_mtm", + "tableTo": "lesson", + "columnsFrom": [ + "lesson_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "substitution_lesson_mtm_substitution_id_substitution_id_fk": { + "name": "substitution_lesson_mtm_substitution_id_substitution_id_fk", + "tableFrom": "substitution_lesson_mtm", + "tableTo": "substitution", + "columnsFrom": [ + "substitution_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "substitution_lesson_mtm_lesson_id_substitution_id_pk": { + "name": "substitution_lesson_mtm_lesson_id_substitution_id_pk", + "columns": [ + "lesson_id", + "substitution_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.teacher": { + "name": "teacher", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "gender": { + "name": "gender", + "type": "bit(1)", + "primaryKey": false, + "notNull": false + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "short": { + "name": "short", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "teacher_user_id_idx": { + "name": "teacher_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "teacher_user_id_user_id_fk": { + "name": "teacher_user_id_user_id_fk", + "tableFrom": "teacher", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.term_definition": { + "name": "term_definition", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "short": { + "name": "short", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "terms": { + "name": "terms", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.timetable": { + "name": "timetable", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "valid_from": { + "name": "valid_from", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "valid_to": { + "name": "valid_to", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_group": { + "name": "user_group", + "schema": "", + "columns": { + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "user_group_user_id_idx": { + "name": "user_group_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_group_group_id_idx": { + "name": "user_group_group_id_idx", + "columns": [ + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_group_group_id_group_id_fk": { + "name": "user_group_group_id_group_id_fk", + "tableFrom": "user_group", + "tableTo": "group", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_group_user_id_user_id_fk": { + "name": "user_group_user_id_user_id_fk", + "tableFrom": "user_group", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "user_group_group_id_user_id_pk": { + "name": "user_group_group_id_user_id_pk", + "columns": [ + "group_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.week_definition": { + "name": "week_definition", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "short": { + "name": "short", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "weeks": { + "name": "weeks", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.wifi_auth_log": { + "name": "wifi_auth_log", + "schema": "", + "columns": { + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "wifi_auth_log_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "mac_address": { + "name": "mac_address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "nas_ip_address": { + "name": "nas_ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "nas_mac_address": { + "name": "nas_mac_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "result": { + "name": "result", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "timestamp": { + "name": "timestamp", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "wifi_user_id": { + "name": "wifi_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "wifi_auth_log_timestamp_idx": { + "name": "wifi_auth_log_timestamp_idx", + "columns": [ + { + "expression": "timestamp", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "wifi_auth_log_username_idx": { + "name": "wifi_auth_log_username_idx", + "columns": [ + { + "expression": "username", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "wifi_auth_log_mac_address_idx": { + "name": "wifi_auth_log_mac_address_idx", + "columns": [ + { + "expression": "mac_address", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "wifi_auth_log_wifi_user_id_wifi_user_id_fk": { + "name": "wifi_auth_log_wifi_user_id_wifi_user_id_fk", + "tableFrom": "wifi_auth_log", + "tableTo": "wifi_user", + "columnsFrom": [ + "wifi_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.wifi_device": { + "name": "wifi_device", + "schema": "", + "columns": { + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "banned": { + "name": "banned", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "last_active_at": { + "name": "last_active_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "mac_address": { + "name": "mac_address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "nickname": { + "name": "nickname", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reported_hostname": { + "name": "reported_hostname", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "wifi_user_id": { + "name": "wifi_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "wifi_device_mac_address_idx": { + "name": "wifi_device_mac_address_idx", + "columns": [ + { + "expression": "mac_address", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "wifi_device_wifi_user_id_idx": { + "name": "wifi_device_wifi_user_id_idx", + "columns": [ + { + "expression": "wifi_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "wifi_device_wifi_user_id_wifi_user_id_fk": { + "name": "wifi_device_wifi_user_id_wifi_user_id_fk", + "tableFrom": "wifi_device", + "tableTo": "wifi_user", + "columnsFrom": [ + "wifi_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "wifi_device_mac_address_unique": { + "name": "wifi_device_mac_address_unique", + "nullsNotDistinct": false, + "columns": [ + "mac_address" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.wifi_nas": { + "name": "wifi_nas", + "schema": "", + "columns": { + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mac_address": { + "name": "mac_address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "wifi_nas_mac_address_idx": { + "name": "wifi_nas_mac_address_idx", + "columns": [ + { + "expression": "mac_address", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "wifi_nas_ip_address_idx": { + "name": "wifi_nas_ip_address_idx", + "columns": [ + { + "expression": "ip_address", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "wifi_nas_mac_address_unique": { + "name": "wifi_nas_mac_address_unique", + "nullsNotDistinct": false, + "columns": [ + "mac_address" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.wifi_role_speed_profile": { + "name": "wifi_role_speed_profile", + "schema": "", + "columns": { + "priority": { + "name": "priority", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "role_name": { + "name": "role_name", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "speed_profile_id": { + "name": "speed_profile_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "wifi_role_speed_profile_role_name_idx": { + "name": "wifi_role_speed_profile_role_name_idx", + "columns": [ + { + "expression": "role_name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "wifi_role_speed_profile_speed_profile_id_wifi_speed_profile_id_fk": { + "name": "wifi_role_speed_profile_speed_profile_id_wifi_speed_profile_id_fk", + "tableFrom": "wifi_role_speed_profile", + "tableTo": "wifi_speed_profile", + "columnsFrom": [ + "speed_profile_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.wifi_speed_profile": { + "name": "wifi_speed_profile", + "schema": "", + "columns": { + "download_speed_mbps": { + "name": "download_speed_mbps", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "is_wlan_default": { + "name": "is_wlan_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "synced_at": { + "name": "synced_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "upload_speed_mbps": { + "name": "upload_speed_mbps", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.wifi_user": { + "name": "wifi_user", + "schema": "", + "columns": { + "allowed_mac_addresses": { + "name": "allowed_mac_addresses", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "banned": { + "name": "banned", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "encrypted_password": { + "name": "encrypted_password", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "salt": { + "name": "salt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "speed_profile_id": { + "name": "speed_profile_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "wifi_user_username_idx": { + "name": "wifi_user_username_idx", + "columns": [ + { + "expression": "username", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "wifi_user_user_id_idx": { + "name": "wifi_user_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "wifi_user_created_by_user_id_fk": { + "name": "wifi_user_created_by_user_id_fk", + "tableFrom": "wifi_user", + "tableTo": "user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "wifi_user_user_id_user_id_fk": { + "name": "wifi_user_user_id_user_id_fk", + "tableFrom": "wifi_user", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "wifi_user_username_unique": { + "name": "wifi_user_username_unique", + "nullsNotDistinct": false, + "columns": [ + "username" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/chronos/src/database/migrations/meta/_journal.json b/apps/chronos/src/database/migrations/meta/_journal.json index 0af11acf..5f934242 100644 --- a/apps/chronos/src/database/migrations/meta/_journal.json +++ b/apps/chronos/src/database/migrations/meta/_journal.json @@ -218,6 +218,13 @@ "when": 1794526024382, "tag": "0030_dizzy_talos", "breakpoints": true + }, + { + "idx": 31, + "version": "7", + "when": 1794945857568, + "tag": "0031_typical_trish_tilby", + "breakpoints": true } ] } \ No newline at end of file