| 55 | } |
| 56 | |
| 57 | func validateSetupConfig(config *SetupConfig, db DB) error { |
| 58 | if len(config.SchemaFilePath) == 0 && len(config.SchemaName) == 0 && config.DisableVersioning { |
| 59 | return NewConfigError("needs either " + flag(CLIOptSchemaFile) + " or " + flag(CLIOptSchemaName)) |
| 60 | } |
| 61 | if (config.DisableVersioning && len(config.InitialVersion) > 0) || |
| 62 | (!config.DisableVersioning && len(config.InitialVersion) == 0) { |
| 63 | return NewConfigError("missing argument; either " + flag(CLIOptDisableVersioning) + " or " + |
| 64 | flag(CLIOptVersion) + " but not both must be specified") |
| 65 | } |
| 66 | if len(config.SchemaFilePath) > 0 && len(config.SchemaName) > 0 { |
| 67 | return NewConfigError("either" + flag(CLIOptSchemaFile) + " or " + |
| 68 | flag(CLIOptSchemaName) + " must be specified") |
| 69 | } |
| 70 | if len(config.SchemaName) > 0 { |
| 71 | if !slices.Contains(dbschemas.PathsByDB(db.Type()), config.SchemaName) { |
| 72 | return NewConfigError(fmt.Sprintf("%s must be one of: %v", |
| 73 | flag(CLIOptSchemaName), dbschemas.PathsByDB(db.Type()))) |
| 74 | } |
| 75 | } |
| 76 | if !config.DisableVersioning { |
| 77 | ver, err := normalizeVersionString(config.InitialVersion) |
| 78 | if err != nil { |
| 79 | return NewConfigError("invalid " + flag(CLIOptVersion) + " argument:" + err.Error()) |
| 80 | } |
| 81 | config.InitialVersion = ver |
| 82 | } |
| 83 | return nil |
| 84 | } |
| 85 | |
| 86 | func validateUpdateConfig(config *UpdateConfig, db DB) error { |
| 87 | if len(config.SchemaDir) == 0 && len(config.SchemaName) == 0 { |