/
githubmirror
/
photoprism
Обзор
Документация
Войти
/
githubmirror
/
photoprism
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
internal/entity/migrate/options.go
51 строка
1 KB
Michael Mayer
Backend: Move migrate package to /internal/entity/migrate
02 июл 2024, 07:40
02 июл 2024, 07:40
6944566
Код
Авторство
О чём код?
package migrate // Options represents migration selection options. type Options struct { AutoMigrate bool RunStage string RunFailed bool Migrations []string DropDeprecated bool } // Opt returns migration options based on the specified parameters. func Opt(runAll, runFailed bool, ids []string) Options { runAll = len(ids) == 0 && (runAll || runFailed) return Options{ AutoMigrate: runAll, RunStage: StageMain, RunFailed: runFailed, Migrations: ids, DropDeprecated: runAll, } } // Stage returns options for the specified migration stage. func (opt Options) Stage(name string) Options { if name == "" { return opt } return Options{ AutoMigrate: false, RunStage: name, RunFailed: opt.RunFailed, Migrations: opt.Migrations, DropDeprecated: opt.DropDeprecated, } } // Pre returns options for the pre-migration stage. func (opt Options) Pre() Options { return opt.Stage(StagePre) } // StageName returns the stage name. func (opt Options) StageName() string { if opt.RunStage == "" { return StageMain } else { return opt.RunStage } }