feat(03-01): add shared postgres pool and plugin migrations

Open one pgx stdlib *sql.DB, hand it to GORM, and run per-plugin
gormigrate sets with isolated history tables after an ICU pl-PL check.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jakub Zych
2026-09-17 19:55:33 +02:00
parent 15a8389e46
commit d0d845052b
18 changed files with 700 additions and 22 deletions

View File

@@ -85,6 +85,7 @@ func generateMain(m Manifest) ([]byte, error) {
b.WriteString("\t\"git.golem15.com/golem15/summercms/backpack\"\n")
b.WriteString("\t\"git.golem15.com/golem15/summercms/bonfire\"\n")
b.WriteString("\t\"git.golem15.com/golem15/summercms/compass\"\n")
b.WriteString("\t\"git.golem15.com/golem15/summercms/lagoon\"\n")
b.WriteString("\t\"git.golem15.com/golem15/summercms/pact\"\n")
b.WriteString("\t\"git.golem15.com/golem15/summercms/party\"\n")
b.WriteString(")\n\n")
@@ -104,7 +105,7 @@ func generateMain(m Manifest) ([]byte, error) {
b.WriteString("\tif err != nil {\n")
b.WriteString("\t\treturn err\n")
b.WriteString("\t}\n")
b.WriteString("\tvar commands []bonfire.Command\n")
b.WriteString("\tcommands := lagoon.RuntimeCommands(app, plugins)\n")
b.WriteString("\tfor _, plugin := range plugins {\n")
b.WriteString("\t\tif hasCommands, ok := plugin.(pact.HasCommands); ok {\n")
b.WriteString("\t\t\tcommands = append(commands, hasCommands.Commands()...)\n")

View File

@@ -94,6 +94,9 @@ func TestGenerateStableQuotedImportsInManifestOrder(t *testing.T) {
if !bytes.Contains(mainSrc, []byte(`bonfire.NewRoot("hello"`)) {
t.Fatalf("main does not use manifest binary:\n%s", mainSrc)
}
if !bytes.Contains(mainSrc, []byte("lagoon.RuntimeCommands")) {
t.Fatalf("main does not register lagoon runtime commands:\n%s", mainSrc)
}
if bytes.Contains(mainSrc, []byte("examples/hello")) {
t.Fatal("generated main hard-codes examples/hello")
}

View File

@@ -121,6 +121,11 @@ func ValidatePluginID(id string) error {
return nil
}
// FindAppDir walks up from start looking for summer.yaml.
func FindAppDir(start string) (string, error) {
return findAppDir(start)
}
func findAppDir(start string) (string, error) {
if start == "" {
return "", fmt.Errorf("build: app directory is empty")