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
This commit is contained in:
44
updates/202610110001_create_golem15_faq_faqs.go
Normal file
44
updates/202610110001_create_golem15_faq_faqs.go
Normal file
@@ -0,0 +1,44 @@
|
||||
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...)
|
||||
}
|
||||
17
updates/registry.go
Normal file
17
updates/registry.go
Normal file
@@ -0,0 +1,17 @@
|
||||
// Package updates holds the FAQ plugin's migrations.
|
||||
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.
|
||||
func All() []*gormigrate.Migration {
|
||||
return all
|
||||
}
|
||||
Reference in New Issue
Block a user