Files
sm-faq-plugin/updates/202610110001_create_golem15_faq_faqs.go
Jakub Zych 1c5491232a feat(17-04): FAQ plugin tracer, admin FAQ with sanitized question repeater
- golem15.faq plugin (Requires golem15.translate), table golem15_faq_faqs with the PHP columns
- FAQ model with jsonable content and the translate Locale relation
- admin controller golem15.faq.faqs: name, slug, locale, active switch, richeditor description, question repeater
- navigation FAQ (order 500), permission golem15.faq.faqs, en and pl phrasebooks
- TestFaqAdminSmoke: answers stored sanitized with a notice under content.1.answer
2026-10-12 17:24:52 +02:00

45 lines
1.1 KiB
Go

package updates
import (
"github.com/go-gormigrate/gormigrate/v2"
"gorm.io/gorm"
)
// createFAQs creates golem15_faq_faqs with the PHP columns (v1.0.1
// create_f_a_q_s_table): one row per FAQ and locale, the question and answer
// list as JSON text in content. PHP has no unique index on slug; the
// (slug, locale_id) index serves the public lookup.
var createFAQs = []*gormigrate.Migration{
{
ID: "202610110001_create_golem15_faq_faqs",
Migrate: func(tx *gorm.DB) error {
for _, stmt := range []string{
`CREATE TABLE golem15_faq_faqs (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
slug VARCHAR(255) NOT NULL,
locale_id INTEGER NOT NULL,
is_active BOOLEAN NOT NULL DEFAULT false,
description TEXT NULL,
content TEXT NULL,
created_at TIMESTAMPTZ NULL,
updated_at TIMESTAMPTZ NULL
)`,
`CREATE INDEX golem15_faq_faqs_slug_locale_id_index ON golem15_faq_faqs (slug, locale_id)`,
} {
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_faq_faqs`).Error
},
},
}
func init() {
Register(createFAQs...)
}