Establishes the initial database schema using Drizzle ORM, replacing the prior placeholder. This migration introduces core entities like users, spaces, pages, access tokens, and their permissions, complete with relationships and constraints. Updates the authentication flow by securing the sign-in endpoint with JWT validation and extracting user details directly from the token via a new custom parameter decorator, improving user context handling. Integrates a new `Page` module, laying the groundwork for future page management capabilities.
500 lines
13 KiB
JSON
500 lines
13 KiB
JSON
{
|
|
"id": "00000000-0000-0000-0000-000000000000",
|
|
"prevId": "",
|
|
"version": "7",
|
|
"dialect": "postgresql",
|
|
"tables": {
|
|
"public.users": {
|
|
"name": "users",
|
|
"schema": "",
|
|
"columns": {
|
|
"user_id": {
|
|
"name": "user_id",
|
|
"type": "uuid",
|
|
"primaryKey": true,
|
|
"notNull": true,
|
|
"default": "gen_random_uuid()"
|
|
},
|
|
"entra_object_id": {
|
|
"name": "entra_object_id",
|
|
"type": "varchar(36)",
|
|
"primaryKey": false,
|
|
"notNull": true
|
|
},
|
|
"entra_tenant_id": {
|
|
"name": "entra_tenant_id",
|
|
"type": "varchar(36)",
|
|
"primaryKey": false,
|
|
"notNull": true
|
|
},
|
|
"email": {
|
|
"name": "email",
|
|
"type": "varchar(255)",
|
|
"primaryKey": false,
|
|
"notNull": true
|
|
},
|
|
"display_name": {
|
|
"name": "display_name",
|
|
"type": "varchar(255)",
|
|
"primaryKey": false,
|
|
"notNull": true
|
|
},
|
|
"is_system_admin": {
|
|
"name": "is_system_admin",
|
|
"type": "boolean",
|
|
"primaryKey": false,
|
|
"notNull": false,
|
|
"default": false
|
|
},
|
|
"is_active": {
|
|
"name": "is_active",
|
|
"type": "boolean",
|
|
"primaryKey": false,
|
|
"notNull": false,
|
|
"default": true
|
|
},
|
|
"created_at": {
|
|
"name": "created_at",
|
|
"type": "timestamp with time zone",
|
|
"primaryKey": false,
|
|
"notNull": false,
|
|
"default": "now()"
|
|
},
|
|
"updated_at": {
|
|
"name": "updated_at",
|
|
"type": "timestamp with time zone",
|
|
"primaryKey": false,
|
|
"notNull": false,
|
|
"default": "now()"
|
|
},
|
|
"last_login_at": {
|
|
"name": "last_login_at",
|
|
"type": "timestamp with time zone",
|
|
"primaryKey": false,
|
|
"notNull": false
|
|
}
|
|
},
|
|
"indexes": {},
|
|
"foreignKeys": {},
|
|
"compositePrimaryKeys": {},
|
|
"uniqueConstraints": {
|
|
"users_entra_object_id_key": {
|
|
"columns": [
|
|
"entra_object_id"
|
|
],
|
|
"nullsNotDistinct": false,
|
|
"name": "users_entra_object_id_key"
|
|
}
|
|
},
|
|
"checkConstraints": {},
|
|
"policies": {},
|
|
"isRLSEnabled": false
|
|
},
|
|
"public.spaces": {
|
|
"name": "spaces",
|
|
"schema": "",
|
|
"columns": {
|
|
"space_id": {
|
|
"name": "space_id",
|
|
"type": "uuid",
|
|
"primaryKey": true,
|
|
"notNull": true,
|
|
"default": "gen_random_uuid()"
|
|
},
|
|
"space_key": {
|
|
"name": "space_key",
|
|
"type": "varchar(50)",
|
|
"primaryKey": false,
|
|
"notNull": true
|
|
},
|
|
"name": {
|
|
"name": "name",
|
|
"type": "varchar(255)",
|
|
"primaryKey": false,
|
|
"notNull": true
|
|
},
|
|
"description": {
|
|
"name": "description",
|
|
"type": "text",
|
|
"primaryKey": false,
|
|
"notNull": false
|
|
},
|
|
"created_by_user_id": {
|
|
"name": "created_by_user_id",
|
|
"type": "uuid",
|
|
"primaryKey": false,
|
|
"notNull": true
|
|
},
|
|
"created_at": {
|
|
"name": "created_at",
|
|
"type": "timestamp with time zone",
|
|
"primaryKey": false,
|
|
"notNull": false,
|
|
"default": "now()"
|
|
}
|
|
},
|
|
"indexes": {},
|
|
"foreignKeys": {
|
|
"spaces_created_by_user_id_fkey": {
|
|
"name": "spaces_created_by_user_id_fkey",
|
|
"tableFrom": "spaces",
|
|
"tableTo": "users",
|
|
"schemaTo": "public",
|
|
"columnsFrom": [
|
|
"created_by_user_id"
|
|
],
|
|
"columnsTo": [
|
|
"user_id"
|
|
],
|
|
"onDelete": "no action",
|
|
"onUpdate": "no action"
|
|
}
|
|
},
|
|
"compositePrimaryKeys": {},
|
|
"uniqueConstraints": {
|
|
"spaces_space_key_key": {
|
|
"columns": [
|
|
"space_key"
|
|
],
|
|
"nullsNotDistinct": false,
|
|
"name": "spaces_space_key_key"
|
|
}
|
|
},
|
|
"checkConstraints": {},
|
|
"policies": {},
|
|
"isRLSEnabled": false
|
|
},
|
|
"public.pages": {
|
|
"name": "pages",
|
|
"schema": "",
|
|
"columns": {
|
|
"page_id": {
|
|
"name": "page_id",
|
|
"type": "uuid",
|
|
"primaryKey": true,
|
|
"notNull": true,
|
|
"default": "gen_random_uuid()"
|
|
},
|
|
"space_id": {
|
|
"name": "space_id",
|
|
"type": "uuid",
|
|
"primaryKey": false,
|
|
"notNull": true
|
|
},
|
|
"parent_page_id": {
|
|
"name": "parent_page_id",
|
|
"type": "uuid",
|
|
"primaryKey": false,
|
|
"notNull": false
|
|
},
|
|
"sort_order": {
|
|
"name": "sort_order",
|
|
"type": "integer",
|
|
"primaryKey": false,
|
|
"notNull": false,
|
|
"default": 0
|
|
},
|
|
"title": {
|
|
"name": "title",
|
|
"type": "varchar(255)",
|
|
"primaryKey": false,
|
|
"notNull": true
|
|
},
|
|
"content": {
|
|
"name": "content",
|
|
"type": "text",
|
|
"primaryKey": false,
|
|
"notNull": false
|
|
},
|
|
"created_by_user_id": {
|
|
"name": "created_by_user_id",
|
|
"type": "uuid",
|
|
"primaryKey": false,
|
|
"notNull": true
|
|
},
|
|
"created_at": {
|
|
"name": "created_at",
|
|
"type": "timestamp with time zone",
|
|
"primaryKey": false,
|
|
"notNull": false,
|
|
"default": "now()"
|
|
},
|
|
"updated_by_user_id": {
|
|
"name": "updated_by_user_id",
|
|
"type": "uuid",
|
|
"primaryKey": false,
|
|
"notNull": true
|
|
},
|
|
"updated_at": {
|
|
"name": "updated_at",
|
|
"type": "timestamp with time zone",
|
|
"primaryKey": false,
|
|
"notNull": false,
|
|
"default": "now()"
|
|
},
|
|
"is_deleted": {
|
|
"name": "is_deleted",
|
|
"type": "boolean",
|
|
"primaryKey": false,
|
|
"notNull": false,
|
|
"default": false
|
|
}
|
|
},
|
|
"indexes": {},
|
|
"foreignKeys": {
|
|
"pages_space_id_fkey": {
|
|
"name": "pages_space_id_fkey",
|
|
"tableFrom": "pages",
|
|
"tableTo": "spaces",
|
|
"schemaTo": "public",
|
|
"columnsFrom": [
|
|
"space_id"
|
|
],
|
|
"columnsTo": [
|
|
"space_id"
|
|
],
|
|
"onDelete": "cascade",
|
|
"onUpdate": "no action"
|
|
},
|
|
"pages_parent_page_id_fkey": {
|
|
"name": "pages_parent_page_id_fkey",
|
|
"tableFrom": "pages",
|
|
"tableTo": "pages",
|
|
"schemaTo": "public",
|
|
"columnsFrom": [
|
|
"parent_page_id"
|
|
],
|
|
"columnsTo": [
|
|
"page_id"
|
|
],
|
|
"onDelete": "cascade",
|
|
"onUpdate": "no action"
|
|
},
|
|
"pages_created_by_user_id_fkey": {
|
|
"name": "pages_created_by_user_id_fkey",
|
|
"tableFrom": "pages",
|
|
"tableTo": "users",
|
|
"schemaTo": "public",
|
|
"columnsFrom": [
|
|
"created_by_user_id"
|
|
],
|
|
"columnsTo": [
|
|
"user_id"
|
|
],
|
|
"onDelete": "no action",
|
|
"onUpdate": "no action"
|
|
},
|
|
"pages_updated_by_user_id_fkey": {
|
|
"name": "pages_updated_by_user_id_fkey",
|
|
"tableFrom": "pages",
|
|
"tableTo": "users",
|
|
"schemaTo": "public",
|
|
"columnsFrom": [
|
|
"updated_by_user_id"
|
|
],
|
|
"columnsTo": [
|
|
"user_id"
|
|
],
|
|
"onDelete": "no action",
|
|
"onUpdate": "no action"
|
|
}
|
|
},
|
|
"compositePrimaryKeys": {},
|
|
"uniqueConstraints": {},
|
|
"checkConstraints": {},
|
|
"policies": {},
|
|
"isRLSEnabled": false
|
|
},
|
|
"public.accesstokens": {
|
|
"name": "accesstokens",
|
|
"schema": "",
|
|
"columns": {
|
|
"token_id": {
|
|
"name": "token_id",
|
|
"type": "uuid",
|
|
"primaryKey": true,
|
|
"notNull": true,
|
|
"default": "gen_random_uuid()"
|
|
},
|
|
"token_value": {
|
|
"name": "token_value",
|
|
"type": "text",
|
|
"primaryKey": false,
|
|
"notNull": true
|
|
},
|
|
"description": {
|
|
"name": "description",
|
|
"type": "varchar(255)",
|
|
"primaryKey": false,
|
|
"notNull": false
|
|
},
|
|
"expires_at": {
|
|
"name": "expires_at",
|
|
"type": "timestamp with time zone",
|
|
"primaryKey": false,
|
|
"notNull": false
|
|
},
|
|
"created_by_user_id": {
|
|
"name": "created_by_user_id",
|
|
"type": "uuid",
|
|
"primaryKey": false,
|
|
"notNull": true
|
|
},
|
|
"created_at": {
|
|
"name": "created_at",
|
|
"type": "timestamp with time zone",
|
|
"primaryKey": false,
|
|
"notNull": false,
|
|
"default": "now()"
|
|
}
|
|
},
|
|
"indexes": {},
|
|
"foreignKeys": {
|
|
"accesstokens_created_by_user_id_fkey": {
|
|
"name": "accesstokens_created_by_user_id_fkey",
|
|
"tableFrom": "accesstokens",
|
|
"tableTo": "users",
|
|
"schemaTo": "public",
|
|
"columnsFrom": [
|
|
"created_by_user_id"
|
|
],
|
|
"columnsTo": [
|
|
"user_id"
|
|
],
|
|
"onDelete": "no action",
|
|
"onUpdate": "no action"
|
|
}
|
|
},
|
|
"compositePrimaryKeys": {},
|
|
"uniqueConstraints": {
|
|
"accesstokens_token_value_key": {
|
|
"columns": [
|
|
"token_value"
|
|
],
|
|
"nullsNotDistinct": false,
|
|
"name": "accesstokens_token_value_key"
|
|
}
|
|
},
|
|
"checkConstraints": {},
|
|
"policies": {},
|
|
"isRLSEnabled": false
|
|
},
|
|
"public.tokenpermissions": {
|
|
"name": "tokenpermissions",
|
|
"schema": "",
|
|
"columns": {
|
|
"permission_id": {
|
|
"name": "permission_id",
|
|
"type": "uuid",
|
|
"primaryKey": true,
|
|
"notNull": true,
|
|
"default": "gen_random_uuid()"
|
|
},
|
|
"token_id": {
|
|
"name": "token_id",
|
|
"type": "uuid",
|
|
"primaryKey": false,
|
|
"notNull": true
|
|
},
|
|
"space_id": {
|
|
"name": "space_id",
|
|
"type": "uuid",
|
|
"primaryKey": false,
|
|
"notNull": false
|
|
},
|
|
"page_id": {
|
|
"name": "page_id",
|
|
"type": "uuid",
|
|
"primaryKey": false,
|
|
"notNull": false
|
|
}
|
|
},
|
|
"indexes": {},
|
|
"foreignKeys": {
|
|
"tokenpermissions_token_id_fkey": {
|
|
"name": "tokenpermissions_token_id_fkey",
|
|
"tableFrom": "tokenpermissions",
|
|
"tableTo": "accesstokens",
|
|
"schemaTo": "public",
|
|
"columnsFrom": [
|
|
"token_id"
|
|
],
|
|
"columnsTo": [
|
|
"token_id"
|
|
],
|
|
"onDelete": "cascade",
|
|
"onUpdate": "no action"
|
|
},
|
|
"tokenpermissions_space_id_fkey": {
|
|
"name": "tokenpermissions_space_id_fkey",
|
|
"tableFrom": "tokenpermissions",
|
|
"tableTo": "spaces",
|
|
"schemaTo": "public",
|
|
"columnsFrom": [
|
|
"space_id"
|
|
],
|
|
"columnsTo": [
|
|
"space_id"
|
|
],
|
|
"onDelete": "cascade",
|
|
"onUpdate": "no action"
|
|
},
|
|
"tokenpermissions_page_id_fkey": {
|
|
"name": "tokenpermissions_page_id_fkey",
|
|
"tableFrom": "tokenpermissions",
|
|
"tableTo": "pages",
|
|
"schemaTo": "public",
|
|
"columnsFrom": [
|
|
"page_id"
|
|
],
|
|
"columnsTo": [
|
|
"page_id"
|
|
],
|
|
"onDelete": "cascade",
|
|
"onUpdate": "no action"
|
|
}
|
|
},
|
|
"compositePrimaryKeys": {},
|
|
"uniqueConstraints": {
|
|
"tokenpermissions_token_id_space_id_key": {
|
|
"columns": [
|
|
"token_id",
|
|
"space_id"
|
|
],
|
|
"nullsNotDistinct": false,
|
|
"name": "tokenpermissions_token_id_space_id_key"
|
|
},
|
|
"tokenpermissions_token_id_page_id_key": {
|
|
"columns": [
|
|
"token_id",
|
|
"page_id"
|
|
],
|
|
"nullsNotDistinct": false,
|
|
"name": "tokenpermissions_token_id_page_id_key"
|
|
}
|
|
},
|
|
"checkConstraints": {
|
|
"tokenpermissions_check": {
|
|
"name": "tokenpermissions_check",
|
|
"value": "((space_id IS NOT NULL) AND (page_id IS NULL)) OR ((space_id IS NULL) AND (page_id IS NOT NULL))"
|
|
}
|
|
},
|
|
"policies": {},
|
|
"isRLSEnabled": false
|
|
}
|
|
},
|
|
"enums": {},
|
|
"schemas": {},
|
|
"sequences": {},
|
|
"roles": {},
|
|
"policies": {},
|
|
"views": {},
|
|
"_meta": {
|
|
"schemas": {},
|
|
"tables": {},
|
|
"columns": {}
|
|
},
|
|
"internal": {
|
|
"tables": {}
|
|
}
|
|
} |