Files
sm-journal-plugin/updates/202610060001_create_golem15_journal_posts.go
Jakub Zych 54322128fb feat(15-01): clone journal plugin with translatable Post tracer
- Register golem15.journal requiring exactly golem15.translate
- Squash golem15_journal_posts DDL with unique slug and JSONB columns
- Persist one en/pl Post through translate helpers on real Postgres

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-06 18:22:47 +02:00

49 lines
1.2 KiB
Go

package updates
import (
"github.com/go-gormigrate/gormigrate/v2"
"gorm.io/gorm"
)
var createPosts = []*gormigrate.Migration{
{
ID: "202610060001_create_golem15_journal_posts",
Migrate: func(tx *gorm.DB) error {
for _, stmt := range []string{
`CREATE TABLE golem15_journal_posts (
id SERIAL PRIMARY KEY,
user_id INTEGER NULL,
redactor_id INTEGER NULL,
title TEXT NULL,
slug TEXT NOT NULL,
excerpt TEXT NULL,
content TEXT NULL,
content_html TEXT NULL,
published_at TIMESTAMPTZ NULL,
published BOOLEAN NOT NULL DEFAULT FALSE,
is_pinned BOOLEAN NOT NULL DEFAULT FALSE,
metadata JSONB NULL,
sources JSONB NULL,
created_at TIMESTAMPTZ NULL,
updated_at TIMESTAMPTZ NULL
)`,
`CREATE INDEX golem15_journal_posts_user_id_index ON golem15_journal_posts (user_id)`,
`CREATE INDEX golem15_journal_posts_redactor_id_index ON golem15_journal_posts (redactor_id)`,
`CREATE UNIQUE INDEX golem15_journal_posts_slug_unique ON golem15_journal_posts (slug)`,
} {
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_journal_posts`).Error
},
},
}
func init() {
Register(createPosts...)
}