fix: IndexNow hears of deleted and edited records

RecordDeleted marks the listed rows it excludes and RecordSaved the rows
whose lastmod it moves (indexnow_pending_at); the next rebuild sends
them to IndexNow as removed or changed and clears the marks. RecordSaved
checks for a nil event before reading it. TestIndexNow now deletes and
edits through the record events, as the admin does.
This commit is contained in:
Jakub Zych
2026-11-04 23:02:09 +01:00
parent 6b67ab759b
commit f58d55555c
8 changed files with 147 additions and 12 deletions

View File

@@ -0,0 +1,27 @@
package updates
import (
"github.com/go-gormigrate/gormigrate/v2"
"gorm.io/gorm"
)
// addIndexNowPending adds indexnow_pending_at to golem15_sitemap_urls
// (P33-62): the record listeners mark the rows of a deleted record that
// were listed, and the rows of an edited record whose lastmod moved, so
// the next rebuild sends them to IndexNow as removed or changed and clears
// the mark.
var addIndexNowPending = []*gormigrate.Migration{
{
ID: "202611040001_add_golem15_sitemap_urls_indexnow_pending",
Migrate: func(tx *gorm.DB) error {
return tx.Exec(`ALTER TABLE golem15_sitemap_urls ADD COLUMN indexnow_pending_at TIMESTAMPTZ NULL`).Error
},
Rollback: func(tx *gorm.DB) error {
return tx.Exec(`ALTER TABLE golem15_sitemap_urls DROP COLUMN IF EXISTS indexnow_pending_at`).Error
},
},
}
func init() {
Register(addIndexNowPending...)
}