Skip to content

Commit 73585fb

Browse files
compscidrclaude
andcommitted
Add migration to clean up plugin settings from main settings table
Remove any dot-namespaced keys (e.g. analytics.enabled) from the settings table that were seeded before plugin settings moved to their own plugin_settings table. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6176fc4 commit 73585fb

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

tools/migrate.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,24 @@ func Migrate(db *gorm.DB) error {
379379
seedDefaultPages(db)
380380
linkWritingPagesToPostType(db)
381381
cleanupEmptyTags(db)
382+
cleanupPluginSettingsFromMainTable(db)
382383

383384
return nil
384385
}
385386

387+
// cleanupPluginSettingsFromMainTable removes any dot-namespaced keys
388+
// from the main settings table that belong in plugin_settings instead.
389+
func cleanupPluginSettingsFromMainTable(db *gorm.DB) {
390+
result := db.Exec("DELETE FROM settings WHERE key LIKE '%.%'")
391+
if result.Error != nil {
392+
log.Printf("Warning: failed to clean up plugin settings from main table: %v", result.Error)
393+
return
394+
}
395+
if result.RowsAffected > 0 {
396+
log.Printf("Cleaned up %d plugin settings from main settings table", result.RowsAffected)
397+
}
398+
}
399+
386400
// cleanupEmptyTags removes empty-name tag associations and the empty tag itself.
387401
func cleanupEmptyTags(db *gorm.DB) {
388402
result := db.Exec("DELETE FROM post_tags WHERE tag_name = ''")

0 commit comments

Comments
 (0)