Files
trueref-legacy/src/lib/server/db/migrations/0002_silky_stellaris.sql
Giancarmine Salucci 9519a66cef test(embeddings): fix 6 remaining test failures
- Fix schema.test.ts: use Unix timestamp integers instead of Date objects for snippet_embeddings.createdAt
- Fix embedding.service.test.ts: use 'local-default' profile instead of non-existent 'test-profile', remove require() calls and use proper ESM imports
- Fix hybrid.search.service.test.ts: update VectorSearch.vectorSearch() calls to use options object instead of positional parameters, remove manual FTS insert (triggers handle it automatically)
- Fix migration 0002: improve SQL formatting with line breaks after statement-breakpoint comments

All 459 tests now passing (18 skipped).
2026-03-25 19:41:24 +01:00

38 lines
1.6 KiB
SQL

CREATE TABLE `embedding_profiles` (
`id` text PRIMARY KEY NOT NULL,
`provider_kind` text NOT NULL,
`title` text NOT NULL,
`enabled` integer DEFAULT true NOT NULL,
`is_default` integer DEFAULT false NOT NULL,
`model` text NOT NULL,
`dimensions` integer NOT NULL,
`config` text NOT NULL,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL
);
--> statement-breakpoint
INSERT INTO embedding_profiles (id, provider_kind, title, enabled, is_default, model, dimensions, config, created_at, updated_at)
VALUES ('local-default', 'local-transformers', 'Local (Xenova/all-MiniLM-L6-v2)', 1, 1, 'Xenova/all-MiniLM-L6-v2', 384, '{}', unixepoch(), unixepoch())
ON CONFLICT(id) DO NOTHING;
--> statement-breakpoint
PRAGMA foreign_keys=OFF;
--> statement-breakpoint
CREATE TABLE `__new_snippet_embeddings` (
`snippet_id` text NOT NULL,
`profile_id` text NOT NULL,
`model` text NOT NULL,
`dimensions` integer NOT NULL,
`embedding` blob NOT NULL,
`created_at` integer NOT NULL,
PRIMARY KEY(`snippet_id`, `profile_id`),
FOREIGN KEY (`snippet_id`) REFERENCES `snippets`(`id`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (`profile_id`) REFERENCES `embedding_profiles`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
INSERT INTO `__new_snippet_embeddings`("snippet_id", "profile_id", "model", "dimensions", "embedding", "created_at") SELECT "snippet_id", 'local-default', "model", "dimensions", "embedding", "created_at" FROM `snippet_embeddings`;
--> statement-breakpoint
DROP TABLE `snippet_embeddings`;
--> statement-breakpoint
ALTER TABLE `__new_snippet_embeddings` RENAME TO `snippet_embeddings`;
--> statement-breakpoint
PRAGMA foreign_keys=ON;