feat(i18n): extend content translation storage
This commit is contained in:
@@ -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;
|
||||
@@ -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`);
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -373,6 +373,7 @@ export const chatMessages = sqliteTable(
|
||||
.$type<string[]>()
|
||||
.default([])
|
||||
.notNull(),
|
||||
sourceLocale: text("source_locale"),
|
||||
createdAt: integer("created_at", { mode: "timestamp_ms" }).default(nowMs).notNull(),
|
||||
},
|
||||
(table) => [
|
||||
|
||||
@@ -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`),
|
||||
|
||||
Reference in New Issue
Block a user