{"record":{"id":"092273d321da55db","repo":"golang-migrate/migrate","slug":"the-seq-and-format-options-are-mutually-exclusive","errorCode":null,"errorMessage":"the seq and format options are mutually exclusive","messagePattern":"the seq and format options are mutually exclusive","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cli/commands.go","lineNumber":19,"sourceCode":"package cli\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/golang-migrate/migrate/v4\"\n\t_ \"github.com/golang-migrate/migrate/v4/database/stub\" // TODO remove again\n\t_ \"github.com/golang-migrate/migrate/v4/source/file\"\n)\n\nvar (\n\terrInvalidSequenceWidth     = errors.New(\"digits must be positive\")\n\terrIncompatibleSeqAndFormat = errors.New(\"the seq and format options are mutually exclusive\")\n\terrInvalidTimeFormat        = errors.New(\"time format may not be empty\")\n)\n\nfunc nextSeqVersion(matches []string, seqDigits int) (string, error) {\n\tif seqDigits <= 0 {\n\t\treturn \"\", errInvalidSequenceWidth\n\t}\n\n\tnextSeq := uint64(1)\n\n\tif len(matches) > 0 {\n\t\tfilename := matches[len(matches)-1]\n\t\tmatchSeqStr := filepath.Base(filename)\n\t\tidx := strings.Index(matchSeqStr, \"_\")\n\n\t\tif idx < 1 { // Using 1 instead of 0 since there should be at least 1 digit\n\t\t\treturn \"\", fmt.Errorf(\"malformed migration filename: %s\", filename)\n\t\t}","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/internal/cli/commands.go#L1-L37","documentation":"errIncompatibleSeqAndFormat ('the seq and format options are mutually exclusive') is returned by createCmd when -seq is passed together with an explicit -format other than the default time format. Sequential numbering (000001_name.up.sql) and time-based versioning (unix/Nano/time.Time format strings) are two different version schemes and cannot be combined.","triggerScenarios":"Running `migrate create -seq -format unix ...` or `-seq -format 20060102150405 ...` — any explicit -format while -seq is enabled (only the defaultTimeFormat is allowed alongside seq).","commonSituations":"Copy-pasting CLI invocations that include both flags from different templates; a CI wrapper always injecting -format unix while users add -seq; switching a project from time-based to sequential naming without removing the -format flag.","solutions":["Remove the -format flag when using -seq.","Remove -seq if you want a specific -format (time-based versions).","In wrapper scripts, make the flags mutually exclusive and pass only one scheme.","Keep the project consistent with existing migrations' naming scheme (migrate rejects mixed version schemes)."],"exampleFix":"// before\nmigrate create -seq -format unix -ext sql -dir migrations add_orders\n// after\nmigrate create -seq -ext sql -dir migrations add_orders","handlingStrategy":"validation","validationCode":"if [ -n \"$SEQ\" ] && [ -n \"$FORMAT\" ] && [ \"$FORMAT\" != \"2006-01-02 15:04:05\" ]; then\n\techo \"-seq and -format are mutually exclusive\"; exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick one versioning scheme per project (seq OR time-based) and encode it in your make/scripts","Never inject -format unconditionally in templates that also support -seq","Check existing migration filenames to confirm the project's scheme before creating new ones"],"tags":["go","cli","golang-migrate","conflicting-flags"],"backgroundTag":"conflicting-flags","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}