- golem15.menu plugin, tables golem15_menu_menus and golem15_menu_menu_entries with the PHP columns plus a nullable url_pattern (D-02) - MenuEntry BeforeSave ports PHP beforeSave: nest columns 0, menu from the parent, sort_order after the menu's last - entry type dropdown: url, divider and the signpost registry types; reference depends on type through signpost.ReferenceOptions - URL scheme allowlist (errors.url_scheme), target _self or _blank, menu and parent cycle checks - menu filter, toolbar reorder/create/delete and config_reorder.yaml partitioned by menu - navigation Menus with Menus and Menu entries, permission golem15.menu.manage_menu, en and pl phrasebooks - TestMenuAdminSmoke
54 lines
1.5 KiB
Go
54 lines
1.5 KiB
Go
package updates
|
|
|
|
import (
|
|
"github.com/go-gormigrate/gormigrate/v2"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// createMenuEntries creates golem15_menu_menu_entries with the PHP columns
|
|
// (v1.0.1 create_menu_entries_table): the menu, the tree columns (parent_id,
|
|
// the NestedTree nest columns and sort_order), the entry's type, title, URL
|
|
// and reference, and its display attributes.
|
|
var createMenuEntries = []*gormigrate.Migration{
|
|
{
|
|
ID: "202610110002_create_golem15_menu_menu_entries",
|
|
Migrate: func(tx *gorm.DB) error {
|
|
for _, stmt := range []string{
|
|
`CREATE TABLE golem15_menu_menu_entries (
|
|
id SERIAL PRIMARY KEY,
|
|
menu_id INTEGER NOT NULL,
|
|
parent_id INTEGER NULL,
|
|
nest_left INTEGER NOT NULL,
|
|
nest_right INTEGER NOT NULL,
|
|
nest_depth INTEGER NOT NULL,
|
|
sort_order INTEGER NULL,
|
|
type VARCHAR(255) NOT NULL,
|
|
title VARCHAR(255) NOT NULL,
|
|
url VARCHAR(255) NULL,
|
|
reference VARCHAR(255) NULL,
|
|
code VARCHAR(255) NULL,
|
|
icon VARCHAR(255) NULL,
|
|
css_class VARCHAR(255) NULL,
|
|
target VARCHAR(255) NULL,
|
|
is_published BOOLEAN NOT NULL DEFAULT true,
|
|
created_at TIMESTAMPTZ NULL,
|
|
updated_at TIMESTAMPTZ NULL
|
|
)`,
|
|
`CREATE INDEX golem15_menu_menu_entries_menu_parent_sort_index ON golem15_menu_menu_entries (menu_id, parent_id, sort_order)`,
|
|
} {
|
|
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_menu_menu_entries`).Error
|
|
},
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
Register(createMenuEntries...)
|
|
}
|