feat: plugin scaffold, entries and the SEO tab tracer

This commit is contained in:
2026-10-27 10:27:46 +01:00
commit fb9590f099
22 changed files with 2373 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
package updates
import (
"github.com/go-gormigrate/gormigrate/v2"
"gorm.io/gorm"
)
// createEntries creates golem15_seo_entries: one row per record and locale
// (D-01), keyed by the record's morph type, its id as text and the locale.
// Empty text means "inherit". data holds later fields (Phase 33 schema
// types, custom JSON-LD) without a migration each.
var createEntries = []*gormigrate.Migration{
{
ID: "202610270001_create_golem15_seo_entries",
Migrate: func(tx *gorm.DB) error {
for _, stmt := range []string{
`CREATE TABLE golem15_seo_entries (
id BIGSERIAL PRIMARY KEY,
model_type TEXT NOT NULL,
record_id TEXT NOT NULL,
locale TEXT NOT NULL DEFAULT '',
type_key TEXT NOT NULL DEFAULT '',
url TEXT NOT NULL DEFAULT '',
title TEXT NOT NULL DEFAULT '',
description TEXT NOT NULL DEFAULT '',
keyphrase TEXT NOT NULL DEFAULT '',
canonical TEXT NOT NULL DEFAULT '',
robots TEXT NOT NULL DEFAULT '',
og_title TEXT NOT NULL DEFAULT '',
og_description TEXT NOT NULL DEFAULT '',
og_image TEXT NOT NULL DEFAULT '',
effective_title TEXT NOT NULL DEFAULT '',
effective_description TEXT NOT NULL DEFAULT '',
data jsonb NOT NULL DEFAULT '{}',
created_at TIMESTAMP(0) NULL,
updated_at TIMESTAMP(0) NULL,
CONSTRAINT golem15_seo_entries_record_locale UNIQUE (model_type, record_id, locale)
)`,
`CREATE INDEX golem15_seo_entries_url ON golem15_seo_entries (url)`,
`CREATE INDEX golem15_seo_entries_type_key ON golem15_seo_entries (type_key)`,
} {
if err := tx.Exec(stmt).Error; err != nil {
return err
}
}
return nil
},
Rollback: func(tx *gorm.DB) error {
return tx.Exec(`DROP TABLE IF EXISTS golem15_seo_entries`).Error
},
},
}
func init() {
Register(createEntries...)
}

18
updates/registry.go Normal file
View File

@@ -0,0 +1,18 @@
// Package updates holds the SEO plugin's ordered gormigrate steps.
package updates
import "github.com/go-gormigrate/gormigrate/v2"
var all []*gormigrate.Migration
// Register appends gormigrate steps so later files add migrations without
// editing plugin.go.
func Register(ms ...*gormigrate.Migration) {
all = append(all, ms...)
}
// All returns every migration registered by this package, in ID order (the
// files register themselves in file-name order).
func All() []*gormigrate.Migration {
return all
}