diff --git a/lib/i18n/content.ts b/lib/i18n/content.ts index b95c3a3..dff87a4 100644 --- a/lib/i18n/content.ts +++ b/lib/i18n/content.ts @@ -2,10 +2,15 @@ export type ContentTranslationFieldKind = "text" | "textarea"; export type ContentTranslationEntityType = | "branding" | "calendar_event" + | "chat_session" | "client" | "client_activity" + | "finance_transaction" + | "journal_entry" | "planning_section" + | "proposal" | "project" + | "subscription" | "task"; export type ContentTranslationField = { @@ -48,6 +53,25 @@ export const contentTranslationRegistry = { { name: "title", label: "Başlık", required: true, maxLength: 500 }, { name: "content", label: "İçerik", kind: "textarea", maxLength: 20_000 }, ], + finance_transaction: [ + { name: "category", label: "Kategori", maxLength: 100 }, + { name: "description", label: "Açıklama", kind: "textarea", maxLength: 1_000 }, + ], + journal_entry: [ + { name: "moodLabel", label: "Mod Etiketi", maxLength: 100 }, + { name: "note", label: "Not", kind: "textarea", maxLength: 5_000 }, + ], + chat_session: [ + { name: "title", label: "Başlık", required: true, maxLength: 200 }, + ], + proposal: [ + { name: "title", label: "Başlık", required: true, maxLength: 300, placeholder: "Örn. Kurumsal web sitesi teklifi" }, + { name: "description", label: "Açıklama", kind: "textarea", maxLength: 30_000, placeholder: "Kapsam, teslimatlar ve teklif notları..." }, + ], + subscription: [ + { name: "name", label: "Abonelik adı", required: true, maxLength: 300, placeholder: "Örn. Tasarım aracı" }, + { name: "category", label: "Kategori", maxLength: 160, placeholder: "Örn. Yazılım, altyapı, pazarlama" }, + ], } satisfies Record; export function contentInputName(locale: string, field: string) { diff --git a/lib/i18n/types.ts b/lib/i18n/types.ts index 4a9544c..4e9e189 100644 --- a/lib/i18n/types.ts +++ b/lib/i18n/types.ts @@ -15,6 +15,8 @@ export const I18N_NAMESPACES = [ "status", "validation", "api", + "analytics", + "business", ] as const; export type I18nNamespace = (typeof I18N_NAMESPACES)[number]; diff --git a/server/db/migrations/0010_lovely_smasher.sql b/server/db/migrations/0010_lovely_smasher.sql new file mode 100644 index 0000000..df6c556 --- /dev/null +++ b/server/db/migrations/0010_lovely_smasher.sql @@ -0,0 +1,23 @@ +PRAGMA foreign_keys=OFF;--> statement-breakpoint +CREATE TABLE `__new_content_translations` ( + `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `entity_type` text NOT NULL, + `entity_id` text NOT NULL, + `field` text NOT NULL, + `locale` text NOT NULL, + `value` text NOT NULL, + `created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL, + `updated_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL, + CONSTRAINT "content_translations_entity_type_check" CHECK("__new_content_translations"."entity_type" in ('branding', 'calendar_event', 'chat_session', 'client', 'client_activity', 'finance_transaction', 'journal_entry', 'planning_section', 'project', 'task')), + CONSTRAINT "content_translations_field_check" CHECK(length("__new_content_translations"."field") between 1 and 64), + CONSTRAINT "content_translations_locale_check" CHECK(length("__new_content_translations"."locale") between 2 and 12) +); +--> statement-breakpoint +INSERT INTO `__new_content_translations`("id", "entity_type", "entity_id", "field", "locale", "value", "created_at", "updated_at") SELECT "id", "entity_type", "entity_id", "field", "locale", "value", "created_at", "updated_at" FROM `content_translations`;--> statement-breakpoint +DROP TABLE `content_translations`;--> statement-breakpoint +ALTER TABLE `__new_content_translations` RENAME TO `content_translations`;--> statement-breakpoint +PRAGMA foreign_keys=ON;--> statement-breakpoint +CREATE UNIQUE INDEX `content_translations_entity_field_locale_unique` ON `content_translations` (`entity_type`,`entity_id`,`field`,`locale`);--> statement-breakpoint +CREATE INDEX `content_translations_locale_idx` ON `content_translations` (`locale`);--> statement-breakpoint +CREATE INDEX `content_translations_entity_locale_idx` ON `content_translations` (`entity_type`,`entity_id`,`locale`);--> statement-breakpoint +ALTER TABLE `chat_messages` ADD `source_locale` text; \ No newline at end of file diff --git a/server/db/migrations/0011_tricky_mordo.sql b/server/db/migrations/0011_tricky_mordo.sql new file mode 100644 index 0000000..6d66655 --- /dev/null +++ b/server/db/migrations/0011_tricky_mordo.sql @@ -0,0 +1,22 @@ +PRAGMA foreign_keys=OFF;--> statement-breakpoint +CREATE TABLE `__new_content_translations` ( + `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `entity_type` text NOT NULL, + `entity_id` text NOT NULL, + `field` text NOT NULL, + `locale` text NOT NULL, + `value` text NOT NULL, + `created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL, + `updated_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL, + CONSTRAINT "content_translations_entity_type_check" CHECK("__new_content_translations"."entity_type" in ('branding', 'calendar_event', 'chat_session', 'client', 'client_activity', 'finance_transaction', 'journal_entry', 'planning_section', 'proposal', 'project', 'subscription', 'task')), + CONSTRAINT "content_translations_field_check" CHECK(length("__new_content_translations"."field") between 1 and 64), + CONSTRAINT "content_translations_locale_check" CHECK(length("__new_content_translations"."locale") between 2 and 12) +); +--> statement-breakpoint +INSERT INTO `__new_content_translations`("id", "entity_type", "entity_id", "field", "locale", "value", "created_at", "updated_at") SELECT "id", "entity_type", "entity_id", "field", "locale", "value", "created_at", "updated_at" FROM `content_translations`;--> statement-breakpoint +DROP TABLE `content_translations`;--> statement-breakpoint +ALTER TABLE `__new_content_translations` RENAME TO `content_translations`;--> statement-breakpoint +PRAGMA foreign_keys=ON;--> statement-breakpoint +CREATE UNIQUE INDEX `content_translations_entity_field_locale_unique` ON `content_translations` (`entity_type`,`entity_id`,`field`,`locale`);--> statement-breakpoint +CREATE INDEX `content_translations_locale_idx` ON `content_translations` (`locale`);--> statement-breakpoint +CREATE INDEX `content_translations_entity_locale_idx` ON `content_translations` (`entity_type`,`entity_id`,`locale`); \ No newline at end of file diff --git a/server/db/migrations/meta/0010_snapshot.json b/server/db/migrations/meta/0010_snapshot.json new file mode 100644 index 0000000..9528ed0 --- /dev/null +++ b/server/db/migrations/meta/0010_snapshot.json @@ -0,0 +1,4231 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "f0cf9ffa-cb58-444c-9b0b-749a8a9a15d0", + "prevId": "11484e18-f5f7-40b2-bda0-be23018d6a86", + "tables": { + "account": { + "name": "account", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "account_user_id_idx": { + "name": "account_user_id_idx", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "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": {}, + "checkConstraints": {} + }, + "app_profiles": { + "name": "app_profiles", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "auth_user_id": { + "name": "auth_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "disabled": { + "name": "disabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "app_profiles_auth_user_id_unique": { + "name": "app_profiles_auth_user_id_unique", + "columns": [ + "auth_user_id" + ], + "isUnique": true + }, + "app_profiles_client_id_unique": { + "name": "app_profiles_client_id_unique", + "columns": [ + "client_id" + ], + "isUnique": true + }, + "app_profiles_role_idx": { + "name": "app_profiles_role_idx", + "columns": [ + "role" + ], + "isUnique": false + } + }, + "foreignKeys": { + "app_profiles_auth_user_id_user_id_fk": { + "name": "app_profiles_auth_user_id_user_id_fk", + "tableFrom": "app_profiles", + "tableTo": "user", + "columnsFrom": [ + "auth_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "app_setup_state": { + "name": "app_setup_state", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "locked_by": { + "name": "locked_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "locked_at": { + "name": "locked_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "completed_at": { + "name": "completed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "auth_audit_events": { + "name": "auth_audit_events", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "auth_user_id": { + "name": "auth_user_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "auth_audit_events_type_idx": { + "name": "auth_audit_events_type_idx", + "columns": [ + "type" + ], + "isUnique": false + }, + "auth_audit_events_auth_user_id_idx": { + "name": "auth_audit_events_auth_user_id_idx", + "columns": [ + "auth_user_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "auth_audit_events_auth_user_id_user_id_fk": { + "name": "auth_audit_events_auth_user_id_user_id_fk", + "tableFrom": "auth_audit_events", + "tableTo": "user", + "columnsFrom": [ + "auth_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "portal_invitations": { + "name": "portal_invitations", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "locale": { + "name": "locale", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'tr'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "accepted_at": { + "name": "accepted_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "portal_invitations_token_hash_unique": { + "name": "portal_invitations_token_hash_unique", + "columns": [ + "token_hash" + ], + "isUnique": true + }, + "portal_invitations_client_id_idx": { + "name": "portal_invitations_client_id_idx", + "columns": [ + "client_id" + ], + "isUnique": false + }, + "portal_invitations_email_idx": { + "name": "portal_invitations_email_idx", + "columns": [ + "email" + ], + "isUnique": false + }, + "portal_invitations_locale_idx": { + "name": "portal_invitations_locale_idx", + "columns": [ + "locale" + ], + "isUnique": false + } + }, + "foreignKeys": { + "portal_invitations_created_by_user_id_user_id_fk": { + "name": "portal_invitations_created_by_user_id_user_id_fk", + "tableFrom": "portal_invitations", + "tableTo": "user", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "session": { + "name": "session", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "session_token_unique": { + "name": "session_token_unique", + "columns": [ + "token" + ], + "isUnique": true + }, + "session_user_id_idx": { + "name": "session_user_id_idx", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "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": {}, + "checkConstraints": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email_verified": { + "name": "email_verified", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "user_email_unique": { + "name": "user_email_unique", + "columns": [ + "email" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "verification": { + "name": "verification", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "verification_identifier_idx": { + "name": "verification_identifier_idx", + "columns": [ + "identifier" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "calendar_events": { + "name": "calendar_events", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'focus'" + }, + "starts_at": { + "name": "starts_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ends_at": { + "name": "ends_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "calendar_events_owner_range_idx": { + "name": "calendar_events_owner_range_idx", + "columns": [ + "owner_user_id", + "starts_at" + ], + "isUnique": false + }, + "calendar_events_project_id_idx": { + "name": "calendar_events_project_id_idx", + "columns": [ + "project_id" + ], + "isUnique": false + }, + "calendar_events_task_id_idx": { + "name": "calendar_events_task_id_idx", + "columns": [ + "task_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "calendar_events_owner_user_id_user_id_fk": { + "name": "calendar_events_owner_user_id_user_id_fk", + "tableFrom": "calendar_events", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "calendar_events_client_id_clients_id_fk": { + "name": "calendar_events_client_id_clients_id_fk", + "tableFrom": "calendar_events", + "tableTo": "clients", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "calendar_events_project_id_projects_id_fk": { + "name": "calendar_events_project_id_projects_id_fk", + "tableFrom": "calendar_events", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "calendar_events_task_id_tasks_id_fk": { + "name": "calendar_events_task_id_tasks_id_fk", + "tableFrom": "calendar_events", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "calendar_events_type_check": { + "name": "calendar_events_type_check", + "value": "\"calendar_events\".\"type\" in ('meeting', 'focus', 'deadline', 'personal', 'finance')" + }, + "calendar_events_time_check": { + "name": "calendar_events_time_check", + "value": "\"calendar_events\".\"ends_at\" is null or \"calendar_events\".\"ends_at\" >= \"calendar_events\".\"starts_at\"" + } + } + }, + "chat_messages": { + "name": "chat_messages", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "context_journal_entry_ids": { + "name": "context_journal_entry_ids", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "source_locale": { + "name": "source_locale", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "chat_messages_session_created_idx": { + "name": "chat_messages_session_created_idx", + "columns": [ + "session_id", + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "chat_messages_session_id_chat_sessions_id_fk": { + "name": "chat_messages_session_id_chat_sessions_id_fk", + "tableFrom": "chat_messages", + "tableTo": "chat_sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "chat_messages_role_check": { + "name": "chat_messages_role_check", + "value": "\"chat_messages\".\"role\" in ('system', 'user', 'assistant', 'tool')" + } + } + }, + "chat_sessions": { + "name": "chat_sessions", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "chat_sessions_owner_updated_idx": { + "name": "chat_sessions_owner_updated_idx", + "columns": [ + "owner_user_id", + "updated_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "chat_sessions_owner_user_id_user_id_fk": { + "name": "chat_sessions_owner_user_id_user_id_fk", + "tableFrom": "chat_sessions", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "client_activities": { + "name": "client_activities", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "activity_date": { + "name": "activity_date", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "client_activities_owner_client_idx": { + "name": "client_activities_owner_client_idx", + "columns": [ + "owner_user_id", + "client_id" + ], + "isUnique": false + }, + "client_activities_client_date_idx": { + "name": "client_activities_client_date_idx", + "columns": [ + "client_id", + "activity_date" + ], + "isUnique": false + } + }, + "foreignKeys": { + "client_activities_owner_user_id_user_id_fk": { + "name": "client_activities_owner_user_id_user_id_fk", + "tableFrom": "client_activities", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "client_activities_client_id_clients_id_fk": { + "name": "client_activities_client_id_clients_id_fk", + "tableFrom": "client_activities", + "tableTo": "clients", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "client_activities_type_check": { + "name": "client_activities_type_check", + "value": "\"client_activities\".\"type\" in ('note', 'call', 'meeting', 'email')" + } + } + }, + "clients": { + "name": "clients", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "auth_user_id": { + "name": "auth_user_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "company_name": { + "name": "company_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "website": { + "name": "website", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "portal_locale": { + "name": "portal_locale", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'active'" + }, + "pipeline_stage": { + "name": "pipeline_stage", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'lead'" + }, + "next_follow_up_date": { + "name": "next_follow_up_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "clients_auth_user_id_unique": { + "name": "clients_auth_user_id_unique", + "columns": [ + "auth_user_id" + ], + "isUnique": true + }, + "clients_owner_user_id_idx": { + "name": "clients_owner_user_id_idx", + "columns": [ + "owner_user_id" + ], + "isUnique": false + }, + "clients_owner_status_idx": { + "name": "clients_owner_status_idx", + "columns": [ + "owner_user_id", + "status" + ], + "isUnique": false + }, + "clients_owner_pipeline_idx": { + "name": "clients_owner_pipeline_idx", + "columns": [ + "owner_user_id", + "pipeline_stage" + ], + "isUnique": false + }, + "clients_portal_locale_idx": { + "name": "clients_portal_locale_idx", + "columns": [ + "portal_locale" + ], + "isUnique": false + }, + "clients_next_follow_up_date_idx": { + "name": "clients_next_follow_up_date_idx", + "columns": [ + "next_follow_up_date" + ], + "isUnique": false + } + }, + "foreignKeys": { + "clients_owner_user_id_user_id_fk": { + "name": "clients_owner_user_id_user_id_fk", + "tableFrom": "clients", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clients_auth_user_id_user_id_fk": { + "name": "clients_auth_user_id_user_id_fk", + "tableFrom": "clients", + "tableTo": "user", + "columnsFrom": [ + "auth_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "clients_status_check": { + "name": "clients_status_check", + "value": "\"clients\".\"status\" in ('active', 'paused', 'archived')" + }, + "clients_pipeline_stage_check": { + "name": "clients_pipeline_stage_check", + "value": "\"clients\".\"pipeline_stage\" in ('lead', 'contacted', 'proposal_sent', 'won', 'lost')" + } + } + }, + "contracts": { + "name": "contracts", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "proposal_id": { + "name": "proposal_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'draft'" + }, + "signed_at": { + "name": "signed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "contracts_owner_status_idx": { + "name": "contracts_owner_status_idx", + "columns": [ + "owner_user_id", + "status" + ], + "isUnique": false + } + }, + "foreignKeys": { + "contracts_owner_user_id_user_id_fk": { + "name": "contracts_owner_user_id_user_id_fk", + "tableFrom": "contracts", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "contracts_proposal_id_proposals_id_fk": { + "name": "contracts_proposal_id_proposals_id_fk", + "tableFrom": "contracts", + "tableTo": "proposals", + "columnsFrom": [ + "proposal_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "contracts_client_id_clients_id_fk": { + "name": "contracts_client_id_clients_id_fk", + "tableFrom": "contracts", + "tableTo": "clients", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "contracts_status_check": { + "name": "contracts_status_check", + "value": "\"contracts\".\"status\" in ('draft', 'active', 'completed', 'cancelled')" + } + } + }, + "finance_transactions": { + "name": "finance_transactions", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "amount_minor": { + "name": "amount_minor", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'USD'" + }, + "transaction_date": { + "name": "transaction_date", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_status": { + "name": "payment_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'planned'" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "finance_transactions_owner_date_idx": { + "name": "finance_transactions_owner_date_idx", + "columns": [ + "owner_user_id", + "transaction_date" + ], + "isUnique": false + }, + "finance_transactions_owner_type_idx": { + "name": "finance_transactions_owner_type_idx", + "columns": [ + "owner_user_id", + "type" + ], + "isUnique": false + }, + "finance_transactions_client_id_idx": { + "name": "finance_transactions_client_id_idx", + "columns": [ + "client_id" + ], + "isUnique": false + }, + "finance_transactions_project_id_idx": { + "name": "finance_transactions_project_id_idx", + "columns": [ + "project_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "finance_transactions_owner_user_id_user_id_fk": { + "name": "finance_transactions_owner_user_id_user_id_fk", + "tableFrom": "finance_transactions", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "finance_transactions_client_id_clients_id_fk": { + "name": "finance_transactions_client_id_clients_id_fk", + "tableFrom": "finance_transactions", + "tableTo": "clients", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "finance_transactions_project_id_projects_id_fk": { + "name": "finance_transactions_project_id_projects_id_fk", + "tableFrom": "finance_transactions", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "finance_transactions_type_check": { + "name": "finance_transactions_type_check", + "value": "\"finance_transactions\".\"type\" in ('income', 'expense')" + }, + "finance_transactions_amount_check": { + "name": "finance_transactions_amount_check", + "value": "\"finance_transactions\".\"amount_minor\" >= 0" + }, + "finance_transactions_payment_status_check": { + "name": "finance_transactions_payment_status_check", + "value": "\"finance_transactions\".\"payment_status\" in ('planned', 'pending', 'paid', 'cancelled')" + }, + "finance_transactions_currency_check": { + "name": "finance_transactions_currency_check", + "value": "length(\"finance_transactions\".\"currency\") = 3" + } + } + }, + "invoices": { + "name": "invoices", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "invoice_number": { + "name": "invoice_number", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "amount_minor": { + "name": "amount_minor", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "tax_basis_points": { + "name": "tax_basis_points", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'TRY'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'draft'" + }, + "issue_date": { + "name": "issue_date", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "due_date": { + "name": "due_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "paid_at": { + "name": "paid_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "invoices_owner_number_unique": { + "name": "invoices_owner_number_unique", + "columns": [ + "owner_user_id", + "invoice_number" + ], + "isUnique": true + }, + "invoices_owner_status_idx": { + "name": "invoices_owner_status_idx", + "columns": [ + "owner_user_id", + "status" + ], + "isUnique": false + } + }, + "foreignKeys": { + "invoices_owner_user_id_user_id_fk": { + "name": "invoices_owner_user_id_user_id_fk", + "tableFrom": "invoices", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invoices_client_id_clients_id_fk": { + "name": "invoices_client_id_clients_id_fk", + "tableFrom": "invoices", + "tableTo": "clients", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "invoices_project_id_projects_id_fk": { + "name": "invoices_project_id_projects_id_fk", + "tableFrom": "invoices", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "invoices_status_check": { + "name": "invoices_status_check", + "value": "\"invoices\".\"status\" in ('draft', 'sent', 'paid', 'overdue', 'cancelled')" + }, + "invoices_amount_check": { + "name": "invoices_amount_check", + "value": "\"invoices\".\"amount_minor\" >= 0" + }, + "invoices_tax_check": { + "name": "invoices_tax_check", + "value": "\"invoices\".\"tax_basis_points\" between 0 and 10000" + } + } + }, + "journal_entries": { + "name": "journal_entries", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "entry_date": { + "name": "entry_date", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "mood_score": { + "name": "mood_score", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "energy_score": { + "name": "energy_score", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "work_satisfaction_score": { + "name": "work_satisfaction_score", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "mood_label": { + "name": "mood_label", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "legacy_ai_metadata": { + "name": "legacy_ai_metadata", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "journal_entries_owner_date_unique": { + "name": "journal_entries_owner_date_unique", + "columns": [ + "owner_user_id", + "entry_date" + ], + "isUnique": true + }, + "journal_entries_owner_date_idx": { + "name": "journal_entries_owner_date_idx", + "columns": [ + "owner_user_id", + "entry_date" + ], + "isUnique": false + } + }, + "foreignKeys": { + "journal_entries_owner_user_id_user_id_fk": { + "name": "journal_entries_owner_user_id_user_id_fk", + "tableFrom": "journal_entries", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "journal_entries_mood_score_check": { + "name": "journal_entries_mood_score_check", + "value": "\"journal_entries\".\"mood_score\" is null or \"journal_entries\".\"mood_score\" between 1 and 5" + }, + "journal_entries_energy_score_check": { + "name": "journal_entries_energy_score_check", + "value": "\"journal_entries\".\"energy_score\" is null or \"journal_entries\".\"energy_score\" between 1 and 5" + }, + "journal_entries_work_score_check": { + "name": "journal_entries_work_score_check", + "value": "\"journal_entries\".\"work_satisfaction_score\" is null or \"journal_entries\".\"work_satisfaction_score\" between 1 and 5" + } + } + }, + "project_planning_sections": { + "name": "project_planning_sections", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'{}'" + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "project_planning_sections_owner_idx": { + "name": "project_planning_sections_owner_idx", + "columns": [ + "owner_user_id" + ], + "isUnique": false + }, + "project_planning_sections_project_order_idx": { + "name": "project_planning_sections_project_order_idx", + "columns": [ + "project_id", + "sort_order" + ], + "isUnique": false + } + }, + "foreignKeys": { + "project_planning_sections_owner_user_id_user_id_fk": { + "name": "project_planning_sections_owner_user_id_user_id_fk", + "tableFrom": "project_planning_sections", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "project_planning_sections_project_id_projects_id_fk": { + "name": "project_planning_sections_project_id_projects_id_fk", + "tableFrom": "project_planning_sections", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "project_planning_sections_category_check": { + "name": "project_planning_sections_category_check", + "value": "\"project_planning_sections\".\"category\" in ('overview', 'problem', 'goal', 'audience', 'scope', 'design_system', 'color_palette', 'typography', 'assets', 'notes')" + } + } + }, + "project_revisions": { + "name": "project_revisions", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "requested_by_user_id": { + "name": "requested_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "project_revisions_owner_project_idx": { + "name": "project_revisions_owner_project_idx", + "columns": [ + "owner_user_id", + "project_id" + ], + "isUnique": false + }, + "project_revisions_client_project_idx": { + "name": "project_revisions_client_project_idx", + "columns": [ + "client_id", + "project_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "project_revisions_owner_user_id_user_id_fk": { + "name": "project_revisions_owner_user_id_user_id_fk", + "tableFrom": "project_revisions", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "project_revisions_project_id_projects_id_fk": { + "name": "project_revisions_project_id_projects_id_fk", + "tableFrom": "project_revisions", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "project_revisions_client_id_clients_id_fk": { + "name": "project_revisions_client_id_clients_id_fk", + "tableFrom": "project_revisions", + "tableTo": "clients", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "project_revisions_requested_by_user_id_user_id_fk": { + "name": "project_revisions_requested_by_user_id_user_id_fk", + "tableFrom": "project_revisions", + "tableTo": "user", + "columnsFrom": [ + "requested_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "project_revisions_status_check": { + "name": "project_revisions_status_check", + "value": "\"project_revisions\".\"status\" in ('pending', 'in_progress', 'completed', 'rejected')" + } + } + }, + "projects": { + "name": "projects", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'client_project'" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'planning'" + }, + "start_date": { + "name": "start_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "due_date": { + "name": "due_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "budget_amount_minor": { + "name": "budget_amount_minor", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'USD'" + }, + "progress": { + "name": "progress", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "progress_type": { + "name": "progress_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'manual'" + }, + "revision_quota": { + "name": "revision_quota", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "legacy_cover_image_path": { + "name": "legacy_cover_image_path", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cover_image_alt": { + "name": "cover_image_alt", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "projects_owner_user_id_idx": { + "name": "projects_owner_user_id_idx", + "columns": [ + "owner_user_id" + ], + "isUnique": false + }, + "projects_owner_status_idx": { + "name": "projects_owner_status_idx", + "columns": [ + "owner_user_id", + "status" + ], + "isUnique": false + }, + "projects_client_id_idx": { + "name": "projects_client_id_idx", + "columns": [ + "client_id" + ], + "isUnique": false + }, + "projects_due_date_idx": { + "name": "projects_due_date_idx", + "columns": [ + "due_date" + ], + "isUnique": false + } + }, + "foreignKeys": { + "projects_owner_user_id_user_id_fk": { + "name": "projects_owner_user_id_user_id_fk", + "tableFrom": "projects", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "projects_client_id_clients_id_fk": { + "name": "projects_client_id_clients_id_fk", + "tableFrom": "projects", + "tableTo": "clients", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "projects_type_check": { + "name": "projects_type_check", + "value": "\"projects\".\"type\" in ('client_project', 'side_project')" + }, + "projects_status_check": { + "name": "projects_status_check", + "value": "\"projects\".\"status\" in ('planning', 'active', 'paused', 'completed', 'cancelled')" + }, + "projects_progress_check": { + "name": "projects_progress_check", + "value": "\"projects\".\"progress\" between 0 and 100" + }, + "projects_revision_quota_check": { + "name": "projects_revision_quota_check", + "value": "\"projects\".\"revision_quota\" >= 0" + }, + "projects_budget_check": { + "name": "projects_budget_check", + "value": "\"projects\".\"budget_amount_minor\" is null or \"projects\".\"budget_amount_minor\" >= 0" + }, + "projects_currency_check": { + "name": "projects_currency_check", + "value": "length(\"projects\".\"currency\") = 3" + } + } + }, + "proposals": { + "name": "proposals", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "amount_minor": { + "name": "amount_minor", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'TRY'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'draft'" + }, + "valid_until": { + "name": "valid_until", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "proposals_owner_status_idx": { + "name": "proposals_owner_status_idx", + "columns": [ + "owner_user_id", + "status" + ], + "isUnique": false + } + }, + "foreignKeys": { + "proposals_owner_user_id_user_id_fk": { + "name": "proposals_owner_user_id_user_id_fk", + "tableFrom": "proposals", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "proposals_client_id_clients_id_fk": { + "name": "proposals_client_id_clients_id_fk", + "tableFrom": "proposals", + "tableTo": "clients", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "proposals_project_id_projects_id_fk": { + "name": "proposals_project_id_projects_id_fk", + "tableFrom": "proposals", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "proposals_status_check": { + "name": "proposals_status_check", + "value": "\"proposals\".\"status\" in ('draft', 'sent', 'accepted', 'rejected')" + }, + "proposals_amount_check": { + "name": "proposals_amount_check", + "value": "\"proposals\".\"amount_minor\" >= 0" + } + } + }, + "subscriptions": { + "name": "subscriptions", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "amount_minor": { + "name": "amount_minor", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'TRY'" + }, + "billing_cycle": { + "name": "billing_cycle", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'monthly'" + }, + "next_billing_date": { + "name": "next_billing_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'active'" + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "subscriptions_owner_status_idx": { + "name": "subscriptions_owner_status_idx", + "columns": [ + "owner_user_id", + "status" + ], + "isUnique": false + }, + "subscriptions_next_billing_date_idx": { + "name": "subscriptions_next_billing_date_idx", + "columns": [ + "next_billing_date" + ], + "isUnique": false + } + }, + "foreignKeys": { + "subscriptions_owner_user_id_user_id_fk": { + "name": "subscriptions_owner_user_id_user_id_fk", + "tableFrom": "subscriptions", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "subscriptions_cycle_check": { + "name": "subscriptions_cycle_check", + "value": "\"subscriptions\".\"billing_cycle\" in ('weekly', 'monthly', 'yearly')" + }, + "subscriptions_status_check": { + "name": "subscriptions_status_check", + "value": "\"subscriptions\".\"status\" in ('active', 'cancelled')" + }, + "subscriptions_amount_check": { + "name": "subscriptions_amount_check", + "value": "\"subscriptions\".\"amount_minor\" >= 0" + } + } + }, + "tasks": { + "name": "tasks", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source_journal_entry_id": { + "name": "source_journal_entry_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'todo'" + }, + "priority": { + "name": "priority", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'medium'" + }, + "scheduled_date": { + "name": "scheduled_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "due_at": { + "name": "due_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "estimated_minutes": { + "name": "estimated_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actual_minutes": { + "name": "actual_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ai_generated": { + "name": "ai_generated", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "is_public_to_client": { + "name": "is_public_to_client", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "tasks_owner_user_id_idx": { + "name": "tasks_owner_user_id_idx", + "columns": [ + "owner_user_id" + ], + "isUnique": false + }, + "tasks_owner_status_idx": { + "name": "tasks_owner_status_idx", + "columns": [ + "owner_user_id", + "status" + ], + "isUnique": false + }, + "tasks_project_id_idx": { + "name": "tasks_project_id_idx", + "columns": [ + "project_id" + ], + "isUnique": false + }, + "tasks_client_id_idx": { + "name": "tasks_client_id_idx", + "columns": [ + "client_id" + ], + "isUnique": false + }, + "tasks_due_at_idx": { + "name": "tasks_due_at_idx", + "columns": [ + "due_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "tasks_owner_user_id_user_id_fk": { + "name": "tasks_owner_user_id_user_id_fk", + "tableFrom": "tasks", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tasks_client_id_clients_id_fk": { + "name": "tasks_client_id_clients_id_fk", + "tableFrom": "tasks", + "tableTo": "clients", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "tasks_project_id_projects_id_fk": { + "name": "tasks_project_id_projects_id_fk", + "tableFrom": "tasks", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "tasks_source_journal_entry_id_journal_entries_id_fk": { + "name": "tasks_source_journal_entry_id_journal_entries_id_fk", + "tableFrom": "tasks", + "tableTo": "journal_entries", + "columnsFrom": [ + "source_journal_entry_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "tasks_status_check": { + "name": "tasks_status_check", + "value": "\"tasks\".\"status\" in ('todo', 'in_progress', 'done', 'cancelled')" + }, + "tasks_priority_check": { + "name": "tasks_priority_check", + "value": "\"tasks\".\"priority\" in ('low', 'medium', 'high', 'urgent')" + }, + "tasks_estimated_minutes_check": { + "name": "tasks_estimated_minutes_check", + "value": "\"tasks\".\"estimated_minutes\" is null or \"tasks\".\"estimated_minutes\" >= 0" + }, + "tasks_actual_minutes_check": { + "name": "tasks_actual_minutes_check", + "value": "\"tasks\".\"actual_minutes\" is null or \"tasks\".\"actual_minutes\" >= 0" + } + } + }, + "content_translations": { + "name": "content_translations", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "field": { + "name": "field", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "locale": { + "name": "locale", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "content_translations_entity_field_locale_unique": { + "name": "content_translations_entity_field_locale_unique", + "columns": [ + "entity_type", + "entity_id", + "field", + "locale" + ], + "isUnique": true + }, + "content_translations_locale_idx": { + "name": "content_translations_locale_idx", + "columns": [ + "locale" + ], + "isUnique": false + }, + "content_translations_entity_locale_idx": { + "name": "content_translations_entity_locale_idx", + "columns": [ + "entity_type", + "entity_id", + "locale" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "content_translations_entity_type_check": { + "name": "content_translations_entity_type_check", + "value": "\"content_translations\".\"entity_type\" in ('branding', 'calendar_event', 'chat_session', 'client', 'client_activity', 'finance_transaction', 'journal_entry', 'planning_section', 'project', 'task')" + }, + "content_translations_field_check": { + "name": "content_translations_field_check", + "value": "length(\"content_translations\".\"field\") between 1 and 64" + }, + "content_translations_locale_check": { + "name": "content_translations_locale_check", + "value": "length(\"content_translations\".\"locale\") between 2 and 12" + } + } + }, + "instance_i18n_settings": { + "name": "instance_i18n_settings", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false, + "default": "'default'" + }, + "default_locale": { + "name": "default_locale", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'tr'" + }, + "catalog_version": { + "name": "catalog_version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "instance_locales": { + "name": "instance_locales", + "columns": { + "code": { + "name": "code", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "native_name": { + "name": "native_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'draft'" + }, + "fallback_locale": { + "name": "fallback_locale", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "text_direction": { + "name": "text_direction", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'ltr'" + }, + "built_in": { + "name": "built_in", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "instance_locales_status_idx": { + "name": "instance_locales_status_idx", + "columns": [ + "status" + ], + "isUnique": false + }, + "instance_locales_fallback_idx": { + "name": "instance_locales_fallback_idx", + "columns": [ + "fallback_locale" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "instance_locales_code_check": { + "name": "instance_locales_code_check", + "value": "\"instance_locales\".\"code\" glob '[a-z][a-z]' or \"instance_locales\".\"code\" glob '[a-z][a-z]-[A-Z][A-Z]' or \"instance_locales\".\"code\" glob '[a-z][a-z]-[A-Z][A-Z][0-9]'" + }, + "instance_locales_status_check": { + "name": "instance_locales_status_check", + "value": "\"instance_locales\".\"status\" in ('draft', 'active', 'archived', 'test')" + }, + "instance_locales_direction_check": { + "name": "instance_locales_direction_check", + "value": "\"instance_locales\".\"text_direction\" in ('ltr', 'rtl')" + }, + "instance_locales_not_self_fallback_check": { + "name": "instance_locales_not_self_fallback_check", + "value": "\"instance_locales\".\"fallback_locale\" is null or \"instance_locales\".\"fallback_locale\" != \"instance_locales\".\"code\"" + } + } + }, + "instance_ui_translations": { + "name": "instance_ui_translations", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "locale": { + "name": "locale", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "namespace": { + "name": "namespace", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "translation_key": { + "name": "translation_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "instance_ui_translations_locale_key_unique": { + "name": "instance_ui_translations_locale_key_unique", + "columns": [ + "locale", + "namespace", + "translation_key" + ], + "isUnique": true + }, + "instance_ui_translations_locale_namespace_idx": { + "name": "instance_ui_translations_locale_namespace_idx", + "columns": [ + "locale", + "namespace" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "instance_ui_translations_locale_check": { + "name": "instance_ui_translations_locale_check", + "value": "length(\"instance_ui_translations\".\"locale\") between 2 and 12" + }, + "instance_ui_translations_namespace_check": { + "name": "instance_ui_translations_namespace_check", + "value": "length(\"instance_ui_translations\".\"namespace\") between 1 and 64" + }, + "instance_ui_translations_key_check": { + "name": "instance_ui_translations_key_check", + "value": "length(\"instance_ui_translations\".\"translation_key\") between 1 and 160" + } + } + }, + "runtime_checks": { + "name": "runtime_checks", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "runtime_events": { + "name": "runtime_events", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "instance_settings": { + "name": "instance_settings", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "instance_id": { + "name": "instance_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "instance_settings_instance_id_unique": { + "name": "instance_settings_instance_id_unique", + "columns": [ + "instance_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user_ai_settings": { + "name": "user_ai_settings", + "columns": { + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'gemini'" + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "encrypted_api_key": { + "name": "encrypted_api_key", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "user_ai_settings_owner_user_id_user_id_fk": { + "name": "user_ai_settings_owner_user_id_user_id_fk", + "tableFrom": "user_ai_settings", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "user_ai_settings_provider_check": { + "name": "user_ai_settings_provider_check", + "value": "\"user_ai_settings\".\"provider\" in ('gemini', 'openai', 'groq', 'ollama')" + } + } + }, + "user_preferences": { + "name": "user_preferences", + "columns": { + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'Europe/Istanbul'" + }, + "default_currency": { + "name": "default_currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'TRY'" + }, + "language": { + "name": "language", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'tr'" + }, + "date_format": { + "name": "date_format", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'dd.MM.yyyy'" + }, + "color_mode": { + "name": "color_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'system'" + }, + "sidebar_collapsed": { + "name": "sidebar_collapsed", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "user_preferences_owner_user_id_user_id_fk": { + "name": "user_preferences_owner_user_id_user_id_fk", + "tableFrom": "user_preferences", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "user_preferences_currency_check": { + "name": "user_preferences_currency_check", + "value": "length(\"user_preferences\".\"default_currency\") = 3" + }, + "user_preferences_language_check": { + "name": "user_preferences_language_check", + "value": "length(\"user_preferences\".\"language\") between 2 and 12" + }, + "user_preferences_color_mode_check": { + "name": "user_preferences_color_mode_check", + "value": "\"user_preferences\".\"color_mode\" in ('light', 'dark', 'system')" + } + } + }, + "files": { + "name": "files", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "uploaded_by_user_id": { + "name": "uploaded_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "auth_user_id": { + "name": "auth_user_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'private'" + }, + "storage_path": { + "name": "storage_path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "original_name": { + "name": "original_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "byte_size": { + "name": "byte_size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "files_storage_path_unique": { + "name": "files_storage_path_unique", + "columns": [ + "storage_path" + ], + "isUnique": true + }, + "files_owner_kind_idx": { + "name": "files_owner_kind_idx", + "columns": [ + "owner_user_id", + "kind" + ], + "isUnique": false + }, + "files_auth_user_id_idx": { + "name": "files_auth_user_id_idx", + "columns": [ + "auth_user_id" + ], + "isUnique": false + }, + "files_project_id_idx": { + "name": "files_project_id_idx", + "columns": [ + "project_id" + ], + "isUnique": false + }, + "files_sha256_idx": { + "name": "files_sha256_idx", + "columns": [ + "sha256" + ], + "isUnique": false + } + }, + "foreignKeys": { + "files_owner_user_id_user_id_fk": { + "name": "files_owner_user_id_user_id_fk", + "tableFrom": "files", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "files_uploaded_by_user_id_user_id_fk": { + "name": "files_uploaded_by_user_id_user_id_fk", + "tableFrom": "files", + "tableTo": "user", + "columnsFrom": [ + "uploaded_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "files_auth_user_id_user_id_fk": { + "name": "files_auth_user_id_user_id_fk", + "tableFrom": "files", + "tableTo": "user", + "columnsFrom": [ + "auth_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "files_project_id_projects_id_fk": { + "name": "files_project_id_projects_id_fk", + "tableFrom": "files", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "files_kind_check": { + "name": "files_kind_check", + "value": "\"files\".\"kind\" in ('avatar', 'branding_logo', 'branding_icon', 'project_asset')" + }, + "files_visibility_check": { + "name": "files_visibility_check", + "value": "\"files\".\"visibility\" in ('private', 'portal', 'public_branding')" + }, + "files_byte_size_check": { + "name": "files_byte_size_check", + "value": "\"files\".\"byte_size\" > 0" + }, + "files_sha256_check": { + "name": "files_sha256_check", + "value": "length(\"files\".\"sha256\") = 64" + }, + "files_storage_path_check": { + "name": "files_storage_path_check", + "value": "\"files\".\"storage_path\" not like '/%' and instr(\"files\".\"storage_path\", '..') = 0" + }, + "files_resource_check": { + "name": "files_resource_check", + "value": "(\n (\"files\".\"kind\" = 'avatar' and \"files\".\"auth_user_id\" is not null and \"files\".\"project_id\" is null and \"files\".\"visibility\" = 'private')\n or (\"files\".\"kind\" in ('branding_logo', 'branding_icon') and \"files\".\"auth_user_id\" is null and \"files\".\"project_id\" is null and \"files\".\"visibility\" = 'public_branding')\n or (\"files\".\"kind\" = 'project_asset' and \"files\".\"auth_user_id\" is null and \"files\".\"project_id\" is not null and \"files\".\"visibility\" in ('private', 'portal'))\n )" + } + } + }, + "instance_branding": { + "name": "instance_branding", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false, + "default": "'default'" + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "application_name": { + "name": "application_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'Neta'" + }, + "short_name": { + "name": "short_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'Neta'" + }, + "primary_color": { + "name": "primary_color", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'#C81E1E'" + }, + "accent_color": { + "name": "accent_color", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'#E6EDF5'" + }, + "light_logo_file_id": { + "name": "light_logo_file_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "dark_logo_file_id": { + "name": "dark_logo_file_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "icon_file_id": { + "name": "icon_file_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "default_color_mode": { + "name": "default_color_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'system'" + }, + "radius_scale": { + "name": "radius_scale", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'default'" + }, + "organization_name": { + "name": "organization_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "support_email": { + "name": "support_email", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "portal_welcome_text": { + "name": "portal_welcome_text", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "portal_footer_text": { + "name": "portal_footer_text", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_by_user_id": { + "name": "updated_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "instance_branding_owner_unique": { + "name": "instance_branding_owner_unique", + "columns": [ + "owner_user_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "instance_branding_owner_user_id_user_id_fk": { + "name": "instance_branding_owner_user_id_user_id_fk", + "tableFrom": "instance_branding", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "instance_branding_light_logo_file_id_files_id_fk": { + "name": "instance_branding_light_logo_file_id_files_id_fk", + "tableFrom": "instance_branding", + "tableTo": "files", + "columnsFrom": [ + "light_logo_file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "instance_branding_dark_logo_file_id_files_id_fk": { + "name": "instance_branding_dark_logo_file_id_files_id_fk", + "tableFrom": "instance_branding", + "tableTo": "files", + "columnsFrom": [ + "dark_logo_file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "instance_branding_icon_file_id_files_id_fk": { + "name": "instance_branding_icon_file_id_files_id_fk", + "tableFrom": "instance_branding", + "tableTo": "files", + "columnsFrom": [ + "icon_file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "instance_branding_updated_by_user_id_user_id_fk": { + "name": "instance_branding_updated_by_user_id_user_id_fk", + "tableFrom": "instance_branding", + "tableTo": "user", + "columnsFrom": [ + "updated_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "instance_branding_id_check": { + "name": "instance_branding_id_check", + "value": "\"instance_branding\".\"id\" = 'default'" + }, + "instance_branding_primary_color_check": { + "name": "instance_branding_primary_color_check", + "value": "\"instance_branding\".\"primary_color\" glob '#[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]'" + }, + "instance_branding_accent_color_check": { + "name": "instance_branding_accent_color_check", + "value": "\"instance_branding\".\"accent_color\" glob '#[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]'" + }, + "instance_branding_color_mode_check": { + "name": "instance_branding_color_mode_check", + "value": "\"instance_branding\".\"default_color_mode\" in ('light', 'dark', 'system')" + }, + "instance_branding_radius_scale_check": { + "name": "instance_branding_radius_scale_check", + "value": "\"instance_branding\".\"radius_scale\" in ('compact', 'default', 'soft')" + } + } + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/server/db/migrations/meta/0011_snapshot.json b/server/db/migrations/meta/0011_snapshot.json new file mode 100644 index 0000000..96a14ba --- /dev/null +++ b/server/db/migrations/meta/0011_snapshot.json @@ -0,0 +1,4231 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "5f712c96-b52a-4df5-97fe-24269ca0ecff", + "prevId": "f0cf9ffa-cb58-444c-9b0b-749a8a9a15d0", + "tables": { + "account": { + "name": "account", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "account_user_id_idx": { + "name": "account_user_id_idx", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "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": {}, + "checkConstraints": {} + }, + "app_profiles": { + "name": "app_profiles", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "auth_user_id": { + "name": "auth_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "disabled": { + "name": "disabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "app_profiles_auth_user_id_unique": { + "name": "app_profiles_auth_user_id_unique", + "columns": [ + "auth_user_id" + ], + "isUnique": true + }, + "app_profiles_client_id_unique": { + "name": "app_profiles_client_id_unique", + "columns": [ + "client_id" + ], + "isUnique": true + }, + "app_profiles_role_idx": { + "name": "app_profiles_role_idx", + "columns": [ + "role" + ], + "isUnique": false + } + }, + "foreignKeys": { + "app_profiles_auth_user_id_user_id_fk": { + "name": "app_profiles_auth_user_id_user_id_fk", + "tableFrom": "app_profiles", + "tableTo": "user", + "columnsFrom": [ + "auth_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "app_setup_state": { + "name": "app_setup_state", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "locked_by": { + "name": "locked_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "locked_at": { + "name": "locked_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "completed_at": { + "name": "completed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "auth_audit_events": { + "name": "auth_audit_events", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "auth_user_id": { + "name": "auth_user_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "auth_audit_events_type_idx": { + "name": "auth_audit_events_type_idx", + "columns": [ + "type" + ], + "isUnique": false + }, + "auth_audit_events_auth_user_id_idx": { + "name": "auth_audit_events_auth_user_id_idx", + "columns": [ + "auth_user_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "auth_audit_events_auth_user_id_user_id_fk": { + "name": "auth_audit_events_auth_user_id_user_id_fk", + "tableFrom": "auth_audit_events", + "tableTo": "user", + "columnsFrom": [ + "auth_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "portal_invitations": { + "name": "portal_invitations", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "locale": { + "name": "locale", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'tr'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "accepted_at": { + "name": "accepted_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "portal_invitations_token_hash_unique": { + "name": "portal_invitations_token_hash_unique", + "columns": [ + "token_hash" + ], + "isUnique": true + }, + "portal_invitations_client_id_idx": { + "name": "portal_invitations_client_id_idx", + "columns": [ + "client_id" + ], + "isUnique": false + }, + "portal_invitations_email_idx": { + "name": "portal_invitations_email_idx", + "columns": [ + "email" + ], + "isUnique": false + }, + "portal_invitations_locale_idx": { + "name": "portal_invitations_locale_idx", + "columns": [ + "locale" + ], + "isUnique": false + } + }, + "foreignKeys": { + "portal_invitations_created_by_user_id_user_id_fk": { + "name": "portal_invitations_created_by_user_id_user_id_fk", + "tableFrom": "portal_invitations", + "tableTo": "user", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "session": { + "name": "session", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "session_token_unique": { + "name": "session_token_unique", + "columns": [ + "token" + ], + "isUnique": true + }, + "session_user_id_idx": { + "name": "session_user_id_idx", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "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": {}, + "checkConstraints": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email_verified": { + "name": "email_verified", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "user_email_unique": { + "name": "user_email_unique", + "columns": [ + "email" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "verification": { + "name": "verification", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "verification_identifier_idx": { + "name": "verification_identifier_idx", + "columns": [ + "identifier" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "calendar_events": { + "name": "calendar_events", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'focus'" + }, + "starts_at": { + "name": "starts_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ends_at": { + "name": "ends_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "calendar_events_owner_range_idx": { + "name": "calendar_events_owner_range_idx", + "columns": [ + "owner_user_id", + "starts_at" + ], + "isUnique": false + }, + "calendar_events_project_id_idx": { + "name": "calendar_events_project_id_idx", + "columns": [ + "project_id" + ], + "isUnique": false + }, + "calendar_events_task_id_idx": { + "name": "calendar_events_task_id_idx", + "columns": [ + "task_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "calendar_events_owner_user_id_user_id_fk": { + "name": "calendar_events_owner_user_id_user_id_fk", + "tableFrom": "calendar_events", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "calendar_events_client_id_clients_id_fk": { + "name": "calendar_events_client_id_clients_id_fk", + "tableFrom": "calendar_events", + "tableTo": "clients", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "calendar_events_project_id_projects_id_fk": { + "name": "calendar_events_project_id_projects_id_fk", + "tableFrom": "calendar_events", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "calendar_events_task_id_tasks_id_fk": { + "name": "calendar_events_task_id_tasks_id_fk", + "tableFrom": "calendar_events", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "calendar_events_type_check": { + "name": "calendar_events_type_check", + "value": "\"calendar_events\".\"type\" in ('meeting', 'focus', 'deadline', 'personal', 'finance')" + }, + "calendar_events_time_check": { + "name": "calendar_events_time_check", + "value": "\"calendar_events\".\"ends_at\" is null or \"calendar_events\".\"ends_at\" >= \"calendar_events\".\"starts_at\"" + } + } + }, + "chat_messages": { + "name": "chat_messages", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "context_journal_entry_ids": { + "name": "context_journal_entry_ids", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "source_locale": { + "name": "source_locale", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "chat_messages_session_created_idx": { + "name": "chat_messages_session_created_idx", + "columns": [ + "session_id", + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "chat_messages_session_id_chat_sessions_id_fk": { + "name": "chat_messages_session_id_chat_sessions_id_fk", + "tableFrom": "chat_messages", + "tableTo": "chat_sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "chat_messages_role_check": { + "name": "chat_messages_role_check", + "value": "\"chat_messages\".\"role\" in ('system', 'user', 'assistant', 'tool')" + } + } + }, + "chat_sessions": { + "name": "chat_sessions", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "chat_sessions_owner_updated_idx": { + "name": "chat_sessions_owner_updated_idx", + "columns": [ + "owner_user_id", + "updated_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "chat_sessions_owner_user_id_user_id_fk": { + "name": "chat_sessions_owner_user_id_user_id_fk", + "tableFrom": "chat_sessions", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "client_activities": { + "name": "client_activities", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "activity_date": { + "name": "activity_date", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "client_activities_owner_client_idx": { + "name": "client_activities_owner_client_idx", + "columns": [ + "owner_user_id", + "client_id" + ], + "isUnique": false + }, + "client_activities_client_date_idx": { + "name": "client_activities_client_date_idx", + "columns": [ + "client_id", + "activity_date" + ], + "isUnique": false + } + }, + "foreignKeys": { + "client_activities_owner_user_id_user_id_fk": { + "name": "client_activities_owner_user_id_user_id_fk", + "tableFrom": "client_activities", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "client_activities_client_id_clients_id_fk": { + "name": "client_activities_client_id_clients_id_fk", + "tableFrom": "client_activities", + "tableTo": "clients", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "client_activities_type_check": { + "name": "client_activities_type_check", + "value": "\"client_activities\".\"type\" in ('note', 'call', 'meeting', 'email')" + } + } + }, + "clients": { + "name": "clients", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "auth_user_id": { + "name": "auth_user_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "company_name": { + "name": "company_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "website": { + "name": "website", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "portal_locale": { + "name": "portal_locale", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'active'" + }, + "pipeline_stage": { + "name": "pipeline_stage", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'lead'" + }, + "next_follow_up_date": { + "name": "next_follow_up_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "clients_auth_user_id_unique": { + "name": "clients_auth_user_id_unique", + "columns": [ + "auth_user_id" + ], + "isUnique": true + }, + "clients_owner_user_id_idx": { + "name": "clients_owner_user_id_idx", + "columns": [ + "owner_user_id" + ], + "isUnique": false + }, + "clients_owner_status_idx": { + "name": "clients_owner_status_idx", + "columns": [ + "owner_user_id", + "status" + ], + "isUnique": false + }, + "clients_owner_pipeline_idx": { + "name": "clients_owner_pipeline_idx", + "columns": [ + "owner_user_id", + "pipeline_stage" + ], + "isUnique": false + }, + "clients_portal_locale_idx": { + "name": "clients_portal_locale_idx", + "columns": [ + "portal_locale" + ], + "isUnique": false + }, + "clients_next_follow_up_date_idx": { + "name": "clients_next_follow_up_date_idx", + "columns": [ + "next_follow_up_date" + ], + "isUnique": false + } + }, + "foreignKeys": { + "clients_owner_user_id_user_id_fk": { + "name": "clients_owner_user_id_user_id_fk", + "tableFrom": "clients", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clients_auth_user_id_user_id_fk": { + "name": "clients_auth_user_id_user_id_fk", + "tableFrom": "clients", + "tableTo": "user", + "columnsFrom": [ + "auth_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "clients_status_check": { + "name": "clients_status_check", + "value": "\"clients\".\"status\" in ('active', 'paused', 'archived')" + }, + "clients_pipeline_stage_check": { + "name": "clients_pipeline_stage_check", + "value": "\"clients\".\"pipeline_stage\" in ('lead', 'contacted', 'proposal_sent', 'won', 'lost')" + } + } + }, + "contracts": { + "name": "contracts", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "proposal_id": { + "name": "proposal_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'draft'" + }, + "signed_at": { + "name": "signed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "contracts_owner_status_idx": { + "name": "contracts_owner_status_idx", + "columns": [ + "owner_user_id", + "status" + ], + "isUnique": false + } + }, + "foreignKeys": { + "contracts_owner_user_id_user_id_fk": { + "name": "contracts_owner_user_id_user_id_fk", + "tableFrom": "contracts", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "contracts_proposal_id_proposals_id_fk": { + "name": "contracts_proposal_id_proposals_id_fk", + "tableFrom": "contracts", + "tableTo": "proposals", + "columnsFrom": [ + "proposal_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "contracts_client_id_clients_id_fk": { + "name": "contracts_client_id_clients_id_fk", + "tableFrom": "contracts", + "tableTo": "clients", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "contracts_status_check": { + "name": "contracts_status_check", + "value": "\"contracts\".\"status\" in ('draft', 'active', 'completed', 'cancelled')" + } + } + }, + "finance_transactions": { + "name": "finance_transactions", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "amount_minor": { + "name": "amount_minor", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'USD'" + }, + "transaction_date": { + "name": "transaction_date", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_status": { + "name": "payment_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'planned'" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "finance_transactions_owner_date_idx": { + "name": "finance_transactions_owner_date_idx", + "columns": [ + "owner_user_id", + "transaction_date" + ], + "isUnique": false + }, + "finance_transactions_owner_type_idx": { + "name": "finance_transactions_owner_type_idx", + "columns": [ + "owner_user_id", + "type" + ], + "isUnique": false + }, + "finance_transactions_client_id_idx": { + "name": "finance_transactions_client_id_idx", + "columns": [ + "client_id" + ], + "isUnique": false + }, + "finance_transactions_project_id_idx": { + "name": "finance_transactions_project_id_idx", + "columns": [ + "project_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "finance_transactions_owner_user_id_user_id_fk": { + "name": "finance_transactions_owner_user_id_user_id_fk", + "tableFrom": "finance_transactions", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "finance_transactions_client_id_clients_id_fk": { + "name": "finance_transactions_client_id_clients_id_fk", + "tableFrom": "finance_transactions", + "tableTo": "clients", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "finance_transactions_project_id_projects_id_fk": { + "name": "finance_transactions_project_id_projects_id_fk", + "tableFrom": "finance_transactions", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "finance_transactions_type_check": { + "name": "finance_transactions_type_check", + "value": "\"finance_transactions\".\"type\" in ('income', 'expense')" + }, + "finance_transactions_amount_check": { + "name": "finance_transactions_amount_check", + "value": "\"finance_transactions\".\"amount_minor\" >= 0" + }, + "finance_transactions_payment_status_check": { + "name": "finance_transactions_payment_status_check", + "value": "\"finance_transactions\".\"payment_status\" in ('planned', 'pending', 'paid', 'cancelled')" + }, + "finance_transactions_currency_check": { + "name": "finance_transactions_currency_check", + "value": "length(\"finance_transactions\".\"currency\") = 3" + } + } + }, + "invoices": { + "name": "invoices", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "invoice_number": { + "name": "invoice_number", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "amount_minor": { + "name": "amount_minor", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "tax_basis_points": { + "name": "tax_basis_points", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'TRY'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'draft'" + }, + "issue_date": { + "name": "issue_date", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "due_date": { + "name": "due_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "paid_at": { + "name": "paid_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "invoices_owner_number_unique": { + "name": "invoices_owner_number_unique", + "columns": [ + "owner_user_id", + "invoice_number" + ], + "isUnique": true + }, + "invoices_owner_status_idx": { + "name": "invoices_owner_status_idx", + "columns": [ + "owner_user_id", + "status" + ], + "isUnique": false + } + }, + "foreignKeys": { + "invoices_owner_user_id_user_id_fk": { + "name": "invoices_owner_user_id_user_id_fk", + "tableFrom": "invoices", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invoices_client_id_clients_id_fk": { + "name": "invoices_client_id_clients_id_fk", + "tableFrom": "invoices", + "tableTo": "clients", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "invoices_project_id_projects_id_fk": { + "name": "invoices_project_id_projects_id_fk", + "tableFrom": "invoices", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "invoices_status_check": { + "name": "invoices_status_check", + "value": "\"invoices\".\"status\" in ('draft', 'sent', 'paid', 'overdue', 'cancelled')" + }, + "invoices_amount_check": { + "name": "invoices_amount_check", + "value": "\"invoices\".\"amount_minor\" >= 0" + }, + "invoices_tax_check": { + "name": "invoices_tax_check", + "value": "\"invoices\".\"tax_basis_points\" between 0 and 10000" + } + } + }, + "journal_entries": { + "name": "journal_entries", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "entry_date": { + "name": "entry_date", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "mood_score": { + "name": "mood_score", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "energy_score": { + "name": "energy_score", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "work_satisfaction_score": { + "name": "work_satisfaction_score", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "mood_label": { + "name": "mood_label", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "legacy_ai_metadata": { + "name": "legacy_ai_metadata", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "journal_entries_owner_date_unique": { + "name": "journal_entries_owner_date_unique", + "columns": [ + "owner_user_id", + "entry_date" + ], + "isUnique": true + }, + "journal_entries_owner_date_idx": { + "name": "journal_entries_owner_date_idx", + "columns": [ + "owner_user_id", + "entry_date" + ], + "isUnique": false + } + }, + "foreignKeys": { + "journal_entries_owner_user_id_user_id_fk": { + "name": "journal_entries_owner_user_id_user_id_fk", + "tableFrom": "journal_entries", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "journal_entries_mood_score_check": { + "name": "journal_entries_mood_score_check", + "value": "\"journal_entries\".\"mood_score\" is null or \"journal_entries\".\"mood_score\" between 1 and 5" + }, + "journal_entries_energy_score_check": { + "name": "journal_entries_energy_score_check", + "value": "\"journal_entries\".\"energy_score\" is null or \"journal_entries\".\"energy_score\" between 1 and 5" + }, + "journal_entries_work_score_check": { + "name": "journal_entries_work_score_check", + "value": "\"journal_entries\".\"work_satisfaction_score\" is null or \"journal_entries\".\"work_satisfaction_score\" between 1 and 5" + } + } + }, + "project_planning_sections": { + "name": "project_planning_sections", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'{}'" + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "project_planning_sections_owner_idx": { + "name": "project_planning_sections_owner_idx", + "columns": [ + "owner_user_id" + ], + "isUnique": false + }, + "project_planning_sections_project_order_idx": { + "name": "project_planning_sections_project_order_idx", + "columns": [ + "project_id", + "sort_order" + ], + "isUnique": false + } + }, + "foreignKeys": { + "project_planning_sections_owner_user_id_user_id_fk": { + "name": "project_planning_sections_owner_user_id_user_id_fk", + "tableFrom": "project_planning_sections", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "project_planning_sections_project_id_projects_id_fk": { + "name": "project_planning_sections_project_id_projects_id_fk", + "tableFrom": "project_planning_sections", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "project_planning_sections_category_check": { + "name": "project_planning_sections_category_check", + "value": "\"project_planning_sections\".\"category\" in ('overview', 'problem', 'goal', 'audience', 'scope', 'design_system', 'color_palette', 'typography', 'assets', 'notes')" + } + } + }, + "project_revisions": { + "name": "project_revisions", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "requested_by_user_id": { + "name": "requested_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "project_revisions_owner_project_idx": { + "name": "project_revisions_owner_project_idx", + "columns": [ + "owner_user_id", + "project_id" + ], + "isUnique": false + }, + "project_revisions_client_project_idx": { + "name": "project_revisions_client_project_idx", + "columns": [ + "client_id", + "project_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "project_revisions_owner_user_id_user_id_fk": { + "name": "project_revisions_owner_user_id_user_id_fk", + "tableFrom": "project_revisions", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "project_revisions_project_id_projects_id_fk": { + "name": "project_revisions_project_id_projects_id_fk", + "tableFrom": "project_revisions", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "project_revisions_client_id_clients_id_fk": { + "name": "project_revisions_client_id_clients_id_fk", + "tableFrom": "project_revisions", + "tableTo": "clients", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "project_revisions_requested_by_user_id_user_id_fk": { + "name": "project_revisions_requested_by_user_id_user_id_fk", + "tableFrom": "project_revisions", + "tableTo": "user", + "columnsFrom": [ + "requested_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "project_revisions_status_check": { + "name": "project_revisions_status_check", + "value": "\"project_revisions\".\"status\" in ('pending', 'in_progress', 'completed', 'rejected')" + } + } + }, + "projects": { + "name": "projects", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'client_project'" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'planning'" + }, + "start_date": { + "name": "start_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "due_date": { + "name": "due_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "budget_amount_minor": { + "name": "budget_amount_minor", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'USD'" + }, + "progress": { + "name": "progress", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "progress_type": { + "name": "progress_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'manual'" + }, + "revision_quota": { + "name": "revision_quota", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "legacy_cover_image_path": { + "name": "legacy_cover_image_path", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cover_image_alt": { + "name": "cover_image_alt", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "projects_owner_user_id_idx": { + "name": "projects_owner_user_id_idx", + "columns": [ + "owner_user_id" + ], + "isUnique": false + }, + "projects_owner_status_idx": { + "name": "projects_owner_status_idx", + "columns": [ + "owner_user_id", + "status" + ], + "isUnique": false + }, + "projects_client_id_idx": { + "name": "projects_client_id_idx", + "columns": [ + "client_id" + ], + "isUnique": false + }, + "projects_due_date_idx": { + "name": "projects_due_date_idx", + "columns": [ + "due_date" + ], + "isUnique": false + } + }, + "foreignKeys": { + "projects_owner_user_id_user_id_fk": { + "name": "projects_owner_user_id_user_id_fk", + "tableFrom": "projects", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "projects_client_id_clients_id_fk": { + "name": "projects_client_id_clients_id_fk", + "tableFrom": "projects", + "tableTo": "clients", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "projects_type_check": { + "name": "projects_type_check", + "value": "\"projects\".\"type\" in ('client_project', 'side_project')" + }, + "projects_status_check": { + "name": "projects_status_check", + "value": "\"projects\".\"status\" in ('planning', 'active', 'paused', 'completed', 'cancelled')" + }, + "projects_progress_check": { + "name": "projects_progress_check", + "value": "\"projects\".\"progress\" between 0 and 100" + }, + "projects_revision_quota_check": { + "name": "projects_revision_quota_check", + "value": "\"projects\".\"revision_quota\" >= 0" + }, + "projects_budget_check": { + "name": "projects_budget_check", + "value": "\"projects\".\"budget_amount_minor\" is null or \"projects\".\"budget_amount_minor\" >= 0" + }, + "projects_currency_check": { + "name": "projects_currency_check", + "value": "length(\"projects\".\"currency\") = 3" + } + } + }, + "proposals": { + "name": "proposals", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "amount_minor": { + "name": "amount_minor", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'TRY'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'draft'" + }, + "valid_until": { + "name": "valid_until", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "proposals_owner_status_idx": { + "name": "proposals_owner_status_idx", + "columns": [ + "owner_user_id", + "status" + ], + "isUnique": false + } + }, + "foreignKeys": { + "proposals_owner_user_id_user_id_fk": { + "name": "proposals_owner_user_id_user_id_fk", + "tableFrom": "proposals", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "proposals_client_id_clients_id_fk": { + "name": "proposals_client_id_clients_id_fk", + "tableFrom": "proposals", + "tableTo": "clients", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "proposals_project_id_projects_id_fk": { + "name": "proposals_project_id_projects_id_fk", + "tableFrom": "proposals", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "proposals_status_check": { + "name": "proposals_status_check", + "value": "\"proposals\".\"status\" in ('draft', 'sent', 'accepted', 'rejected')" + }, + "proposals_amount_check": { + "name": "proposals_amount_check", + "value": "\"proposals\".\"amount_minor\" >= 0" + } + } + }, + "subscriptions": { + "name": "subscriptions", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "amount_minor": { + "name": "amount_minor", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'TRY'" + }, + "billing_cycle": { + "name": "billing_cycle", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'monthly'" + }, + "next_billing_date": { + "name": "next_billing_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'active'" + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "subscriptions_owner_status_idx": { + "name": "subscriptions_owner_status_idx", + "columns": [ + "owner_user_id", + "status" + ], + "isUnique": false + }, + "subscriptions_next_billing_date_idx": { + "name": "subscriptions_next_billing_date_idx", + "columns": [ + "next_billing_date" + ], + "isUnique": false + } + }, + "foreignKeys": { + "subscriptions_owner_user_id_user_id_fk": { + "name": "subscriptions_owner_user_id_user_id_fk", + "tableFrom": "subscriptions", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "subscriptions_cycle_check": { + "name": "subscriptions_cycle_check", + "value": "\"subscriptions\".\"billing_cycle\" in ('weekly', 'monthly', 'yearly')" + }, + "subscriptions_status_check": { + "name": "subscriptions_status_check", + "value": "\"subscriptions\".\"status\" in ('active', 'cancelled')" + }, + "subscriptions_amount_check": { + "name": "subscriptions_amount_check", + "value": "\"subscriptions\".\"amount_minor\" >= 0" + } + } + }, + "tasks": { + "name": "tasks", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source_journal_entry_id": { + "name": "source_journal_entry_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'todo'" + }, + "priority": { + "name": "priority", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'medium'" + }, + "scheduled_date": { + "name": "scheduled_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "due_at": { + "name": "due_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "estimated_minutes": { + "name": "estimated_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actual_minutes": { + "name": "actual_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ai_generated": { + "name": "ai_generated", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "is_public_to_client": { + "name": "is_public_to_client", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "tasks_owner_user_id_idx": { + "name": "tasks_owner_user_id_idx", + "columns": [ + "owner_user_id" + ], + "isUnique": false + }, + "tasks_owner_status_idx": { + "name": "tasks_owner_status_idx", + "columns": [ + "owner_user_id", + "status" + ], + "isUnique": false + }, + "tasks_project_id_idx": { + "name": "tasks_project_id_idx", + "columns": [ + "project_id" + ], + "isUnique": false + }, + "tasks_client_id_idx": { + "name": "tasks_client_id_idx", + "columns": [ + "client_id" + ], + "isUnique": false + }, + "tasks_due_at_idx": { + "name": "tasks_due_at_idx", + "columns": [ + "due_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "tasks_owner_user_id_user_id_fk": { + "name": "tasks_owner_user_id_user_id_fk", + "tableFrom": "tasks", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tasks_client_id_clients_id_fk": { + "name": "tasks_client_id_clients_id_fk", + "tableFrom": "tasks", + "tableTo": "clients", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "tasks_project_id_projects_id_fk": { + "name": "tasks_project_id_projects_id_fk", + "tableFrom": "tasks", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "tasks_source_journal_entry_id_journal_entries_id_fk": { + "name": "tasks_source_journal_entry_id_journal_entries_id_fk", + "tableFrom": "tasks", + "tableTo": "journal_entries", + "columnsFrom": [ + "source_journal_entry_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "tasks_status_check": { + "name": "tasks_status_check", + "value": "\"tasks\".\"status\" in ('todo', 'in_progress', 'done', 'cancelled')" + }, + "tasks_priority_check": { + "name": "tasks_priority_check", + "value": "\"tasks\".\"priority\" in ('low', 'medium', 'high', 'urgent')" + }, + "tasks_estimated_minutes_check": { + "name": "tasks_estimated_minutes_check", + "value": "\"tasks\".\"estimated_minutes\" is null or \"tasks\".\"estimated_minutes\" >= 0" + }, + "tasks_actual_minutes_check": { + "name": "tasks_actual_minutes_check", + "value": "\"tasks\".\"actual_minutes\" is null or \"tasks\".\"actual_minutes\" >= 0" + } + } + }, + "content_translations": { + "name": "content_translations", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "field": { + "name": "field", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "locale": { + "name": "locale", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "content_translations_entity_field_locale_unique": { + "name": "content_translations_entity_field_locale_unique", + "columns": [ + "entity_type", + "entity_id", + "field", + "locale" + ], + "isUnique": true + }, + "content_translations_locale_idx": { + "name": "content_translations_locale_idx", + "columns": [ + "locale" + ], + "isUnique": false + }, + "content_translations_entity_locale_idx": { + "name": "content_translations_entity_locale_idx", + "columns": [ + "entity_type", + "entity_id", + "locale" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "content_translations_entity_type_check": { + "name": "content_translations_entity_type_check", + "value": "\"content_translations\".\"entity_type\" in ('branding', 'calendar_event', 'chat_session', 'client', 'client_activity', 'finance_transaction', 'journal_entry', 'planning_section', 'proposal', 'project', 'subscription', 'task')" + }, + "content_translations_field_check": { + "name": "content_translations_field_check", + "value": "length(\"content_translations\".\"field\") between 1 and 64" + }, + "content_translations_locale_check": { + "name": "content_translations_locale_check", + "value": "length(\"content_translations\".\"locale\") between 2 and 12" + } + } + }, + "instance_i18n_settings": { + "name": "instance_i18n_settings", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false, + "default": "'default'" + }, + "default_locale": { + "name": "default_locale", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'tr'" + }, + "catalog_version": { + "name": "catalog_version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "instance_locales": { + "name": "instance_locales", + "columns": { + "code": { + "name": "code", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "native_name": { + "name": "native_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'draft'" + }, + "fallback_locale": { + "name": "fallback_locale", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "text_direction": { + "name": "text_direction", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'ltr'" + }, + "built_in": { + "name": "built_in", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "instance_locales_status_idx": { + "name": "instance_locales_status_idx", + "columns": [ + "status" + ], + "isUnique": false + }, + "instance_locales_fallback_idx": { + "name": "instance_locales_fallback_idx", + "columns": [ + "fallback_locale" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "instance_locales_code_check": { + "name": "instance_locales_code_check", + "value": "\"instance_locales\".\"code\" glob '[a-z][a-z]' or \"instance_locales\".\"code\" glob '[a-z][a-z]-[A-Z][A-Z]' or \"instance_locales\".\"code\" glob '[a-z][a-z]-[A-Z][A-Z][0-9]'" + }, + "instance_locales_status_check": { + "name": "instance_locales_status_check", + "value": "\"instance_locales\".\"status\" in ('draft', 'active', 'archived', 'test')" + }, + "instance_locales_direction_check": { + "name": "instance_locales_direction_check", + "value": "\"instance_locales\".\"text_direction\" in ('ltr', 'rtl')" + }, + "instance_locales_not_self_fallback_check": { + "name": "instance_locales_not_self_fallback_check", + "value": "\"instance_locales\".\"fallback_locale\" is null or \"instance_locales\".\"fallback_locale\" != \"instance_locales\".\"code\"" + } + } + }, + "instance_ui_translations": { + "name": "instance_ui_translations", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "locale": { + "name": "locale", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "namespace": { + "name": "namespace", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "translation_key": { + "name": "translation_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "instance_ui_translations_locale_key_unique": { + "name": "instance_ui_translations_locale_key_unique", + "columns": [ + "locale", + "namespace", + "translation_key" + ], + "isUnique": true + }, + "instance_ui_translations_locale_namespace_idx": { + "name": "instance_ui_translations_locale_namespace_idx", + "columns": [ + "locale", + "namespace" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "instance_ui_translations_locale_check": { + "name": "instance_ui_translations_locale_check", + "value": "length(\"instance_ui_translations\".\"locale\") between 2 and 12" + }, + "instance_ui_translations_namespace_check": { + "name": "instance_ui_translations_namespace_check", + "value": "length(\"instance_ui_translations\".\"namespace\") between 1 and 64" + }, + "instance_ui_translations_key_check": { + "name": "instance_ui_translations_key_check", + "value": "length(\"instance_ui_translations\".\"translation_key\") between 1 and 160" + } + } + }, + "runtime_checks": { + "name": "runtime_checks", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "runtime_events": { + "name": "runtime_events", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "instance_settings": { + "name": "instance_settings", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "instance_id": { + "name": "instance_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "instance_settings_instance_id_unique": { + "name": "instance_settings_instance_id_unique", + "columns": [ + "instance_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user_ai_settings": { + "name": "user_ai_settings", + "columns": { + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'gemini'" + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "encrypted_api_key": { + "name": "encrypted_api_key", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "user_ai_settings_owner_user_id_user_id_fk": { + "name": "user_ai_settings_owner_user_id_user_id_fk", + "tableFrom": "user_ai_settings", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "user_ai_settings_provider_check": { + "name": "user_ai_settings_provider_check", + "value": "\"user_ai_settings\".\"provider\" in ('gemini', 'openai', 'groq', 'ollama')" + } + } + }, + "user_preferences": { + "name": "user_preferences", + "columns": { + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'Europe/Istanbul'" + }, + "default_currency": { + "name": "default_currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'TRY'" + }, + "language": { + "name": "language", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'tr'" + }, + "date_format": { + "name": "date_format", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'dd.MM.yyyy'" + }, + "color_mode": { + "name": "color_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'system'" + }, + "sidebar_collapsed": { + "name": "sidebar_collapsed", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "user_preferences_owner_user_id_user_id_fk": { + "name": "user_preferences_owner_user_id_user_id_fk", + "tableFrom": "user_preferences", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "user_preferences_currency_check": { + "name": "user_preferences_currency_check", + "value": "length(\"user_preferences\".\"default_currency\") = 3" + }, + "user_preferences_language_check": { + "name": "user_preferences_language_check", + "value": "length(\"user_preferences\".\"language\") between 2 and 12" + }, + "user_preferences_color_mode_check": { + "name": "user_preferences_color_mode_check", + "value": "\"user_preferences\".\"color_mode\" in ('light', 'dark', 'system')" + } + } + }, + "files": { + "name": "files", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "uploaded_by_user_id": { + "name": "uploaded_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "auth_user_id": { + "name": "auth_user_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'private'" + }, + "storage_path": { + "name": "storage_path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "original_name": { + "name": "original_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "byte_size": { + "name": "byte_size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "files_storage_path_unique": { + "name": "files_storage_path_unique", + "columns": [ + "storage_path" + ], + "isUnique": true + }, + "files_owner_kind_idx": { + "name": "files_owner_kind_idx", + "columns": [ + "owner_user_id", + "kind" + ], + "isUnique": false + }, + "files_auth_user_id_idx": { + "name": "files_auth_user_id_idx", + "columns": [ + "auth_user_id" + ], + "isUnique": false + }, + "files_project_id_idx": { + "name": "files_project_id_idx", + "columns": [ + "project_id" + ], + "isUnique": false + }, + "files_sha256_idx": { + "name": "files_sha256_idx", + "columns": [ + "sha256" + ], + "isUnique": false + } + }, + "foreignKeys": { + "files_owner_user_id_user_id_fk": { + "name": "files_owner_user_id_user_id_fk", + "tableFrom": "files", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "files_uploaded_by_user_id_user_id_fk": { + "name": "files_uploaded_by_user_id_user_id_fk", + "tableFrom": "files", + "tableTo": "user", + "columnsFrom": [ + "uploaded_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "files_auth_user_id_user_id_fk": { + "name": "files_auth_user_id_user_id_fk", + "tableFrom": "files", + "tableTo": "user", + "columnsFrom": [ + "auth_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "files_project_id_projects_id_fk": { + "name": "files_project_id_projects_id_fk", + "tableFrom": "files", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "files_kind_check": { + "name": "files_kind_check", + "value": "\"files\".\"kind\" in ('avatar', 'branding_logo', 'branding_icon', 'project_asset')" + }, + "files_visibility_check": { + "name": "files_visibility_check", + "value": "\"files\".\"visibility\" in ('private', 'portal', 'public_branding')" + }, + "files_byte_size_check": { + "name": "files_byte_size_check", + "value": "\"files\".\"byte_size\" > 0" + }, + "files_sha256_check": { + "name": "files_sha256_check", + "value": "length(\"files\".\"sha256\") = 64" + }, + "files_storage_path_check": { + "name": "files_storage_path_check", + "value": "\"files\".\"storage_path\" not like '/%' and instr(\"files\".\"storage_path\", '..') = 0" + }, + "files_resource_check": { + "name": "files_resource_check", + "value": "(\n (\"files\".\"kind\" = 'avatar' and \"files\".\"auth_user_id\" is not null and \"files\".\"project_id\" is null and \"files\".\"visibility\" = 'private')\n or (\"files\".\"kind\" in ('branding_logo', 'branding_icon') and \"files\".\"auth_user_id\" is null and \"files\".\"project_id\" is null and \"files\".\"visibility\" = 'public_branding')\n or (\"files\".\"kind\" = 'project_asset' and \"files\".\"auth_user_id\" is null and \"files\".\"project_id\" is not null and \"files\".\"visibility\" in ('private', 'portal'))\n )" + } + } + }, + "instance_branding": { + "name": "instance_branding", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false, + "default": "'default'" + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "application_name": { + "name": "application_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'Neta'" + }, + "short_name": { + "name": "short_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'Neta'" + }, + "primary_color": { + "name": "primary_color", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'#C81E1E'" + }, + "accent_color": { + "name": "accent_color", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'#E6EDF5'" + }, + "light_logo_file_id": { + "name": "light_logo_file_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "dark_logo_file_id": { + "name": "dark_logo_file_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "icon_file_id": { + "name": "icon_file_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "default_color_mode": { + "name": "default_color_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'system'" + }, + "radius_scale": { + "name": "radius_scale", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'default'" + }, + "organization_name": { + "name": "organization_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "support_email": { + "name": "support_email", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "portal_welcome_text": { + "name": "portal_welcome_text", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "portal_footer_text": { + "name": "portal_footer_text", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_by_user_id": { + "name": "updated_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "instance_branding_owner_unique": { + "name": "instance_branding_owner_unique", + "columns": [ + "owner_user_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "instance_branding_owner_user_id_user_id_fk": { + "name": "instance_branding_owner_user_id_user_id_fk", + "tableFrom": "instance_branding", + "tableTo": "user", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "instance_branding_light_logo_file_id_files_id_fk": { + "name": "instance_branding_light_logo_file_id_files_id_fk", + "tableFrom": "instance_branding", + "tableTo": "files", + "columnsFrom": [ + "light_logo_file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "instance_branding_dark_logo_file_id_files_id_fk": { + "name": "instance_branding_dark_logo_file_id_files_id_fk", + "tableFrom": "instance_branding", + "tableTo": "files", + "columnsFrom": [ + "dark_logo_file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "instance_branding_icon_file_id_files_id_fk": { + "name": "instance_branding_icon_file_id_files_id_fk", + "tableFrom": "instance_branding", + "tableTo": "files", + "columnsFrom": [ + "icon_file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "instance_branding_updated_by_user_id_user_id_fk": { + "name": "instance_branding_updated_by_user_id_user_id_fk", + "tableFrom": "instance_branding", + "tableTo": "user", + "columnsFrom": [ + "updated_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "instance_branding_id_check": { + "name": "instance_branding_id_check", + "value": "\"instance_branding\".\"id\" = 'default'" + }, + "instance_branding_primary_color_check": { + "name": "instance_branding_primary_color_check", + "value": "\"instance_branding\".\"primary_color\" glob '#[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]'" + }, + "instance_branding_accent_color_check": { + "name": "instance_branding_accent_color_check", + "value": "\"instance_branding\".\"accent_color\" glob '#[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]'" + }, + "instance_branding_color_mode_check": { + "name": "instance_branding_color_mode_check", + "value": "\"instance_branding\".\"default_color_mode\" in ('light', 'dark', 'system')" + }, + "instance_branding_radius_scale_check": { + "name": "instance_branding_radius_scale_check", + "value": "\"instance_branding\".\"radius_scale\" in ('compact', 'default', 'soft')" + } + } + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/server/db/migrations/meta/_journal.json b/server/db/migrations/meta/_journal.json index dd2d761..4adf704 100644 --- a/server/db/migrations/meta/_journal.json +++ b/server/db/migrations/meta/_journal.json @@ -71,6 +71,20 @@ "when": 1784533970134, "tag": "0009_loose_sersi", "breakpoints": true + }, + { + "idx": 10, + "version": "6", + "when": 1784625110660, + "tag": "0010_lovely_smasher", + "breakpoints": true + }, + { + "idx": 11, + "version": "6", + "when": 1784626279393, + "tag": "0011_tricky_mordo", + "breakpoints": true } ] } \ No newline at end of file diff --git a/server/db/schema/domain.ts b/server/db/schema/domain.ts index 83c7080..289e1ec 100644 --- a/server/db/schema/domain.ts +++ b/server/db/schema/domain.ts @@ -373,6 +373,7 @@ export const chatMessages = sqliteTable( .$type() .default([]) .notNull(), + sourceLocale: text("source_locale"), createdAt: integer("created_at", { mode: "timestamp_ms" }).default(nowMs).notNull(), }, (table) => [ diff --git a/server/db/schema/i18n.ts b/server/db/schema/i18n.ts index 15c9c54..c6b7345 100644 --- a/server/db/schema/i18n.ts +++ b/server/db/schema/i18n.ts @@ -13,10 +13,15 @@ export type TextDirection = "ltr" | "rtl"; export type TranslationEntityType = | "branding" | "calendar_event" + | "chat_session" | "client" | "client_activity" + | "finance_transaction" + | "journal_entry" | "planning_section" + | "proposal" | "project" + | "subscription" | "task"; const nowMs = sql`(cast(unixepoch('subsecond') * 1000 as integer))`; @@ -115,7 +120,7 @@ export const contentTranslations = sqliteTable( index("content_translations_entity_locale_idx").on(table.entityType, table.entityId, table.locale), check( "content_translations_entity_type_check", - sql`${table.entityType} in ('branding', 'calendar_event', 'client', 'client_activity', 'planning_section', 'project', 'task')`, + sql`${table.entityType} in ('branding', 'calendar_event', 'chat_session', 'client', 'client_activity', 'finance_transaction', 'journal_entry', 'planning_section', 'proposal', 'project', 'subscription', 'task')`, ), check("content_translations_field_check", sql`length(${table.field}) between 1 and 64`), check("content_translations_locale_check", sql`length(${table.locale}) between 2 and 12`), diff --git a/server/domain/validation.ts b/server/domain/validation.ts index e8f1ba7..1184a3a 100644 --- a/server/domain/validation.ts +++ b/server/domain/validation.ts @@ -232,6 +232,7 @@ export const chatMessageCreateSchema = z.object({ role: z.enum(chatMessageRoles), content: z.string().trim().min(1).max(100_000), contextJournalEntryIds: z.array(resourceIdSchema).max(100).default([]), + sourceLocale: z.string().trim().min(2).max(12).nullable().optional(), }); export const proposalCreateSchema = z.object({ diff --git a/server/services/domain.ts b/server/services/domain.ts index d27e86e..5c993ee 100644 --- a/server/services/domain.ts +++ b/server/services/domain.ts @@ -44,7 +44,7 @@ import type { ContentTranslationInput } from "../../lib/i18n/content"; export class DomainService { readonly repositories: DomainRepositories; - private readonly contentTranslations: ContentTranslationService; + public readonly contentTranslations: ContentTranslationService; constructor( private readonly db: DomainDatabase, @@ -283,9 +283,16 @@ export class DomainService { createFinanceTransaction(actor: DomainActor, input: unknown) { const scope = requireOwnerScope(actor); - const value = parseDomainInput(financeTransactionCreateSchema, input); + const translations = this.getContentTranslations(input); + const defaultLocale = this.contentTranslations.getLocalizationContext(actor).defaultLocale; + const value = parseDomainInput( + financeTransactionCreateSchema, + translations ? projectBaseFromTranslations("finance_transaction", input as Record, translations, defaultLocale) : input, + ); this.assertTaskRelations(scope, value); - return this.repositories.finance.create(scope, { ...value, id: value.id ?? this.id() }); + const transaction = this.repositories.finance.create(scope, { ...value, id: value.id ?? this.id() }); + this.contentTranslations.upsertEntityTranslations("finance_transaction", transaction.id, translations); + return transaction; } listFinanceTransactions(actor: DomainActor) { @@ -295,21 +302,42 @@ export class DomainService { updateFinanceTransaction(actor: DomainActor, transactionId: string, input: unknown) { const scope = requireOwnerScope(actor); const current = this.repositories.finance.get(scope, transactionId) ?? this.throwNotFound("Finans kaydı"); - const value = parseDomainInput(financeTransactionUpdateSchema, input); + const translations = this.getContentTranslations(input); + const defaultLocale = this.contentTranslations.getLocalizationContext(actor).defaultLocale; + const value = parseDomainInput( + financeTransactionUpdateSchema, + translations ? projectBaseFromTranslations("finance_transaction", input as Record, translations, defaultLocale) : input, + ); this.assertTaskRelations(scope, { ...current, ...value }); - return this.repositories.finance.update(scope, transactionId, value) ?? this.throwNotFound("Finans kaydı"); + const transaction = this.repositories.finance.update(scope, transactionId, value) ?? this.throwNotFound("Finans kaydı"); + this.contentTranslations.upsertEntityTranslations("finance_transaction", transaction.id, translations); + return transaction; } deleteFinanceTransaction(actor: DomainActor, transactionId: string) { - return this.repositories.finance.remove(requireOwnerScope(actor), transactionId) ?? this.throwNotFound("Finans kaydı"); + const transaction = this.repositories.finance.remove(requireOwnerScope(actor), transactionId) ?? this.throwNotFound("Finans kaydı"); + this.contentTranslations.deleteEntityTranslations("finance_transaction", transactionId); + return transaction; } saveJournalEntry(actor: DomainActor, input: unknown) { const scope = requireOwnerScope(actor); - const value = parseDomainInput(journalEntrySchema, input); - const existing = this.repositories.journal.getByDate(scope, value.entryDate); - if (existing) return this.repositories.journal.updateByDate(scope, value.entryDate, value); - return this.repositories.journal.create(scope, { ...value, id: value.id ?? this.id() }); + const translations = this.getContentTranslations(input); + const defaultLocale = this.contentTranslations.getLocalizationContext(actor).defaultLocale; + const value = parseDomainInput( + journalEntrySchema, + translations ? projectBaseFromTranslations("journal_entry", input as Record, translations, defaultLocale) : input, + ); + let entry = this.repositories.journal.getByDate(scope, value.entryDate); + if (entry) { + entry = this.repositories.journal.updateByDate(scope, value.entryDate, value); + } else { + entry = this.repositories.journal.create(scope, { ...value, id: value.id ?? this.id() }); + } + if (entry) { + this.contentTranslations.upsertEntityTranslations("journal_entry", entry.id, translations); + } + return entry; } listJournalEntries(actor: DomainActor) { @@ -318,16 +346,25 @@ export class DomainService { updateJournalEntry(actor: DomainActor, entryId: string, input: unknown) { const scope = requireOwnerScope(actor); - const value = parseDomainInput(journalEntrySchema.omit({ id: true }), input); + const translations = this.getContentTranslations(input); + const defaultLocale = this.contentTranslations.getLocalizationContext(actor).defaultLocale; + const value = parseDomainInput( + journalEntrySchema.omit({ id: true }), + translations ? projectBaseFromTranslations("journal_entry", input as Record, translations, defaultLocale) : input, + ); const conflicting = this.repositories.journal.getByDate(scope, value.entryDate); if (conflicting && conflicting.id !== entryId) { throw conflict("Bu tarih için zaten bir günlük kaydı var."); } - return this.repositories.journal.update(scope, entryId, value) ?? this.throwNotFound("Günlük kaydı"); + const entry = this.repositories.journal.update(scope, entryId, value) ?? this.throwNotFound("Günlük kaydı"); + this.contentTranslations.upsertEntityTranslations("journal_entry", entry.id, translations); + return entry; } deleteJournalEntry(actor: DomainActor, entryId: string) { - return this.repositories.journal.remove(requireOwnerScope(actor), entryId) ?? this.throwNotFound("Günlük kaydı"); + const entry = this.repositories.journal.remove(requireOwnerScope(actor), entryId) ?? this.throwNotFound("Günlük kaydı"); + this.contentTranslations.deleteEntityTranslations("journal_entry", entryId); + return entry; } addPlanningSection(actor: DomainActor, input: unknown) { @@ -579,9 +616,16 @@ export class DomainService { createProposal(actor: DomainActor, input: unknown) { const scope = requireOwnerScope(actor); - const value = parseDomainInput(proposalCreateSchema, input); + const { translations, ...rawInput } = input as Record; + const defaultLocale = this.contentTranslations.getLocalizationContext(actor).defaultLocale; + const value = parseDomainInput( + proposalCreateSchema, + translations ? projectBaseFromTranslations("proposal", rawInput, translations as ContentTranslationInput, defaultLocale) : input, + ); this.assertTaskRelations(scope, value); - return this.repositories.business.createProposal(scope, { ...value, id: value.id ?? this.id() }); + const proposal = this.repositories.business.createProposal(scope, { ...value, id: value.id ?? this.id() }); + this.contentTranslations.upsertEntityTranslations("proposal", proposal.id, translations as ContentTranslationInput | undefined); + return proposal; } listProposals(actor: DomainActor) { @@ -597,15 +641,24 @@ export class DomainService { const scope = requireOwnerScope(actor); const current = this.repositories.business.getProposal(scope, proposalId) ?? this.throwNotFound("Teklif"); - const value = parseDomainInput(proposalUpdateSchema, input); + const { translations, ...rawInput } = input as Record; + const defaultLocale = this.contentTranslations.getLocalizationContext(actor).defaultLocale; + const value = parseDomainInput( + proposalUpdateSchema, + translations ? projectBaseFromTranslations("proposal", rawInput, translations as ContentTranslationInput, defaultLocale) : input, + ); this.assertTaskRelations(scope, { ...current, ...value }); - return this.repositories.business.updateProposal(scope, proposalId, value) + const proposal = this.repositories.business.updateProposal(scope, proposalId, value) ?? this.throwNotFound("Teklif"); + this.contentTranslations.upsertEntityTranslations("proposal", proposal.id, translations as ContentTranslationInput | undefined); + return proposal; } deleteProposal(actor: DomainActor, proposalId: string) { - return this.repositories.business.removeProposal(requireOwnerScope(actor), proposalId) + const proposal = this.repositories.business.removeProposal(requireOwnerScope(actor), proposalId) ?? this.throwNotFound("Teklif"); + this.contentTranslations.deleteEntityTranslations("proposal", proposalId); + return proposal; } createContract(actor: DomainActor, input: unknown) { @@ -672,8 +725,15 @@ export class DomainService { createSubscription(actor: DomainActor, input: unknown) { const scope = requireOwnerScope(actor); - const value = parseDomainInput(subscriptionCreateSchema, input); - return this.repositories.business.createSubscription(scope, { ...value, id: value.id ?? this.id() }); + const { translations, ...rawInput } = input as Record; + const defaultLocale = this.contentTranslations.getLocalizationContext(actor).defaultLocale; + const value = parseDomainInput( + subscriptionCreateSchema, + translations ? projectBaseFromTranslations("subscription", rawInput, translations as ContentTranslationInput, defaultLocale) : input, + ); + const subscription = this.repositories.business.createSubscription(scope, { ...value, id: value.id ?? this.id() }); + this.contentTranslations.upsertEntityTranslations("subscription", subscription.id, translations as ContentTranslationInput | undefined); + return subscription; } listSubscriptions(actor: DomainActor) { @@ -687,17 +747,26 @@ export class DomainService { updateSubscription(actor: DomainActor, subscriptionId: string, input: unknown) { const scope = requireOwnerScope(actor); - const value = parseDomainInput(subscriptionUpdateSchema, input); + const { translations, ...rawInput } = input as Record; + const defaultLocale = this.contentTranslations.getLocalizationContext(actor).defaultLocale; + const value = parseDomainInput( + subscriptionUpdateSchema, + translations ? projectBaseFromTranslations("subscription", rawInput, translations as ContentTranslationInput, defaultLocale) : input, + ); if (!this.repositories.business.getSubscription(scope, subscriptionId)) { throw notFound("Abonelik"); } - return this.repositories.business.updateSubscription(scope, subscriptionId, value) + const subscription = this.repositories.business.updateSubscription(scope, subscriptionId, value) ?? this.throwNotFound("Abonelik"); + this.contentTranslations.upsertEntityTranslations("subscription", subscription.id, translations as ContentTranslationInput | undefined); + return subscription; } deleteSubscription(actor: DomainActor, subscriptionId: string) { - return this.repositories.business.removeSubscription(requireOwnerScope(actor), subscriptionId) + const subscription = this.repositories.business.removeSubscription(requireOwnerScope(actor), subscriptionId) ?? this.throwNotFound("Abonelik"); + this.contentTranslations.deleteEntityTranslations("subscription", subscriptionId); + return subscription; } private requireOwnedClient(scope: OwnerScope, clientId: string) {