[优化] 增加根目录选项

This commit is contained in:
ryan
2026-06-04 09:56:03 +08:00
parent e117e314d9
commit 6e85f1158b
10 changed files with 186 additions and 13 deletions
@@ -0,0 +1,32 @@
package goose
import (
"fmt"
presslygoose "github.com/pressly/goose/v3"
"gorm.io/gorm"
)
const versionPagesDeploymentRootDir int64 = 202606040001
// migration202606040001 adds RootDir field to Pages deployments.
func migration202606040001(backend string, ctx Context) *presslygoose.Migration {
return newGORMMigration(
versionPagesDeploymentRootDir,
"202606040001_add_pages_deployment_root_dir.go",
backend,
ctx,
migratePagesDeploymentRootDir,
)
}
func migratePagesDeploymentRootDir(ctx Context, db *gorm.DB, backend string) error {
if err := ctx.ApplyCurrentSchema(db, backend); err != nil {
return err
}
// Verify that the column exists
if !db.Migrator().HasColumn("pages_deployments", "root_dir") {
return fmt.Errorf("column pages_deployments.root_dir is missing")
}
return nil
}
@@ -45,6 +45,7 @@ func registeredMigrations(backend string, ctx Context) []*presslygoose.Migration
migration202606030002(backend, ctx),
migration202606030003(backend, ctx),
migration202606030004(backend, ctx),
migration202606040001(backend, ctx),
}
}