- golem15.sitemap plugin: golem15_sitemap_definitions migration, Definition model (Fillable theme and data) with tolerant PHP-shaped item decoding and PHP toArray item encoding - Url::to and buildUrl port, libxml-format serializer, generator for url and registry items - GET /sitemap.xml serves the definition with theme default (404 without one, empty body without items) - tests/php/gen-goldens.php and the tracer golden; TestSitemapGolden and the Postgres TestSitemapTracer
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package updates
|
|
|
|
import (
|
|
"github.com/go-gormigrate/gormigrate/v2"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// createDefinitions creates golem15_sitemap_definitions with the PHP columns
|
|
// (v1.0.2 create_definitions_table, renamed in v2.0.0 and v2.0.1): a
|
|
// nullable indexed theme and the data text of the items.
|
|
var createDefinitions = []*gormigrate.Migration{
|
|
{
|
|
ID: "202610110001_create_golem15_sitemap_definitions",
|
|
Migrate: func(tx *gorm.DB) error {
|
|
for _, stmt := range []string{
|
|
`CREATE TABLE golem15_sitemap_definitions (
|
|
id SERIAL PRIMARY KEY,
|
|
theme VARCHAR(255) NULL,
|
|
data TEXT NULL,
|
|
created_at TIMESTAMPTZ NULL,
|
|
updated_at TIMESTAMPTZ NULL
|
|
)`,
|
|
`CREATE INDEX golem15_sitemap_definitions_theme_index ON golem15_sitemap_definitions (theme)`,
|
|
} {
|
|
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_sitemap_definitions`).Error
|
|
},
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
Register(createDefinitions...)
|
|
}
|