feat: address-change 301 (tracer)
- golem15_seo_redirects table and Redirect model - AddressChanged: old -> new 301 in the save transaction, earlier redirects pointed at the new address, self-loops dropped - the SEO tab save compares descriptor URLs with the entry URLs and answers the redirects.auto_created notice - resolve answers redirect with the absolute target for an exact source
This commit is contained in:
39
updates/202610270006_create_golem15_seo_redirects.go
Normal file
39
updates/202610270006_create_golem15_seo_redirects.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package updates
|
||||
|
||||
import (
|
||||
"github.com/go-gormigrate/gormigrate/v2"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// createRedirects creates golem15_seo_redirects: 301, 302 and 410 rules
|
||||
// with exact, pattern and regex sources (D-16, D-17), one per source and
|
||||
// match.
|
||||
var createRedirects = []*gormigrate.Migration{
|
||||
{
|
||||
ID: "202610270006_create_golem15_seo_redirects",
|
||||
Migrate: func(tx *gorm.DB) error {
|
||||
return tx.Exec(`CREATE TABLE golem15_seo_redirects (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
source TEXT NOT NULL,
|
||||
match TEXT NOT NULL DEFAULT 'exact',
|
||||
target TEXT NOT NULL DEFAULT '',
|
||||
status INTEGER NOT NULL DEFAULT 301,
|
||||
query TEXT NOT NULL DEFAULT 'ignore',
|
||||
ignore_case BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
trailing_slash BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
origin TEXT NOT NULL DEFAULT 'manual',
|
||||
note TEXT NOT NULL DEFAULT '',
|
||||
created_at TIMESTAMP(0) NULL,
|
||||
updated_at TIMESTAMP(0) NULL,
|
||||
CONSTRAINT golem15_seo_redirects_source_match UNIQUE (source, match)
|
||||
)`).Error
|
||||
},
|
||||
Rollback: func(tx *gorm.DB) error {
|
||||
return tx.Exec(`DROP TABLE IF EXISTS golem15_seo_redirects`).Error
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
Register(createRedirects...)
|
||||
}
|
||||
Reference in New Issue
Block a user