From 648035b194dd1b8c658a6411b9f9fe19467ccc10 Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Fri, 13 Mar 2026 10:18:31 +0300 Subject: Fix: slow startup from silly migrations --- storage/migrate.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'storage/migrate.go') diff --git a/storage/migrate.go b/storage/migrate.go index 38f9854..b6fed37 100644 --- a/storage/migrate.go +++ b/storage/migrate.go @@ -23,9 +23,20 @@ func (p *ProviderSQL) Migrate() error { p.logger.Error("Failed to read migrations directory;", "error", err) return fmt.Errorf("failed to read migrations directory: %w", err) } + + // Check if FTS already has data - skip populate migration if so + var ftsCount int + _ = p.db.QueryRow("SELECT COUNT(*) FROM fts_embeddings").Scan(&ftsCount) + skipFTSMigration := ftsCount > 0 + // Execute each .up.sql file for _, file := range files { if strings.HasSuffix(file.Name(), ".up.sql") { + // Skip FTS populate migration if already populated + if skipFTSMigration && strings.Contains(file.Name(), "004_populate_fts") { + p.logger.Debug("Skipping FTS migration - already populated", "file", file.Name()) + continue + } err := p.executeMigration(migrationsDir, file.Name()) if err != nil { p.logger.Error("Failed to execute migration %s: %v", file.Name(), err) -- cgit v1.2.3