summaryrefslogtreecommitdiff
path: root/vendor/github.com/uptrace/bun/migrate/migrator.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-05-12 14:33:40 +0200
committerLibravatar GitHub <noreply@github.com>2023-05-12 14:33:40 +0200
commitec325fee141c1e9757144a0a4094061b56839b78 (patch)
tree2948ab4ef5702cc8478ab2be841340b946bdb867 /vendor/github.com/uptrace/bun/migrate/migrator.go
parent[frogend/bugfix] fix dynamicSpoiler elements (#1771) (diff)
downloadgotosocial-ec325fee141c1e9757144a0a4094061b56839b78.tar.xz
[chore] Update a bunch of database dependencies (#1772)
* [chore] Update a bunch of database dependencies * fix lil thing
Diffstat (limited to 'vendor/github.com/uptrace/bun/migrate/migrator.go')
-rw-r--r--vendor/github.com/uptrace/bun/migrate/migrator.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/vendor/github.com/uptrace/bun/migrate/migrator.go b/vendor/github.com/uptrace/bun/migrate/migrator.go
index e24dba808..5cae6ccb9 100644
--- a/vendor/github.com/uptrace/bun/migrate/migrator.go
+++ b/vendor/github.com/uptrace/bun/migrate/migrator.go
@@ -217,6 +217,7 @@ func (m *Migrator) Rollback(ctx context.Context, opts ...MigrationOption) (*Migr
type goMigrationConfig struct {
packageName string
+ goTemplate string
}
type GoMigrationOption func(cfg *goMigrationConfig)
@@ -227,12 +228,19 @@ func WithPackageName(name string) GoMigrationOption {
}
}
+func WithGoTemplate(template string) GoMigrationOption {
+ return func(cfg *goMigrationConfig) {
+ cfg.goTemplate = template
+ }
+}
+
// CreateGoMigration creates a Go migration file.
func (m *Migrator) CreateGoMigration(
ctx context.Context, name string, opts ...GoMigrationOption,
) (*MigrationFile, error) {
cfg := &goMigrationConfig{
packageName: "migrations",
+ goTemplate: goTemplate,
}
for _, opt := range opts {
opt(cfg)
@@ -245,7 +253,7 @@ func (m *Migrator) CreateGoMigration(
fname := name + ".go"
fpath := filepath.Join(m.migrations.getDirectory(), fname)
- content := fmt.Sprintf(goTemplate, cfg.packageName)
+ content := fmt.Sprintf(cfg.goTemplate, cfg.packageName)
if err := ioutil.WriteFile(fpath, []byte(content), 0o644); err != nil {
return nil, err