Switch tts_segments schema to use settings_json (jsonb for Postgres, text for SQLite) instead of settings_hash. Update related indexes and migration SQL. Regenerate Drizzle snapshots to reflect the new structure. This improves flexibility for storing TTS settings and enables more robust segment lookups.
26 lines
No EOL
1.1 KiB
SQL
26 lines
No EOL
1.1 KiB
SQL
DROP TABLE IF EXISTS `tts_segments`;--> statement-breakpoint
|
|
CREATE TABLE `tts_segments` (
|
|
`segment_id` text NOT NULL,
|
|
`user_id` text NOT NULL,
|
|
`document_id` text NOT NULL,
|
|
`reader_type` text NOT NULL,
|
|
`document_version` integer NOT NULL,
|
|
`segment_index` integer NOT NULL,
|
|
`locator_json` text,
|
|
`settings_json` text NOT NULL,
|
|
`text_hash` text NOT NULL,
|
|
`text_length` integer DEFAULT 0 NOT NULL,
|
|
`audio_key` text,
|
|
`audio_format` text DEFAULT 'mp3' NOT NULL,
|
|
`duration_ms` integer,
|
|
`alignment_json` text,
|
|
`status` text DEFAULT 'pending' NOT NULL,
|
|
`error` text,
|
|
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)),
|
|
`updated_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)),
|
|
PRIMARY KEY(`segment_id`, `user_id`),
|
|
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE INDEX `idx_tts_segments_lookup` ON `tts_segments` (`user_id`,`document_id`,`document_version`,`settings_json`);--> statement-breakpoint
|
|
CREATE INDEX `idx_tts_segments_doc_index` ON `tts_segments` (`user_id`,`document_id`,`segment_index`); |