mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2025-12-10 01:02:52 +01:00
refactor: remove pocketbase (#1138)
This commit is contained in:
34
app/migration/migrations.go
Normal file
34
app/migration/migrations.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package migration
|
||||
|
||||
import "fmt"
|
||||
|
||||
var migrationGenerators = []func() (migration, error){
|
||||
newSQLMigration("000_create_pocketbase_tables"),
|
||||
newSQLMigration("001_create_tables"),
|
||||
newFilesMigration(),
|
||||
newSQLMigration("002_create_defaultdata"),
|
||||
newSQLMigration("003_create_groups"),
|
||||
}
|
||||
|
||||
func migrations(version int) ([]migration, error) {
|
||||
var migrations []migration
|
||||
|
||||
if version < 0 || version > len(migrationGenerators) {
|
||||
return nil, fmt.Errorf("invalid migration version: %d", version)
|
||||
}
|
||||
|
||||
if version == len(migrationGenerators) {
|
||||
return migrations, nil // No migrations to apply
|
||||
}
|
||||
|
||||
for _, migrationFunc := range migrationGenerators[version:] {
|
||||
migration, err := migrationFunc()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create migration: %w", err)
|
||||
}
|
||||
|
||||
migrations = append(migrations, migration)
|
||||
}
|
||||
|
||||
return migrations, nil
|
||||
}
|
||||
Reference in New Issue
Block a user