{"record":{"id":"74d0c744e31d94a8","repo":"hasura/graphql-engine","slug":"no-migration","errorCode":null,"errorMessage":"no migration","messagePattern":"no migration","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"cli/migrate/migrate.go","lineNumber":44,"sourceCode":"\t\"github.com/hasura/graphql-engine/cli/v2/migrate/source\"\n\t\"github.com/hasura/graphql-engine/cli/v2/util\"\n\tlog \"github.com/sirupsen/logrus\"\n\t\"golang.org/x/term\"\n)\n\n// DefaultPrefetchMigrations sets the number of migrations to pre-read\n// from the source. This is helpful if the source is remote, but has little\n// effect for a local source (i.e. file system).\n// Please note that this setting has a major impact on the memory usage,\n// since each pre-read migration is buffered in memory. See DefaultBufferSize.\nvar DefaultPrefetchMigrations = uint64(10)\n\n// DefaultLockTimeout sets the max time a database driver has to acquire a lock.\nvar DefaultLockTimeout = 15 * time.Second\n\nvar (\n\tErrNoChange         = errors.New(\"no change\")\n\tErrNilVersion       = errors.New(\"no migration\")\n\tErrLocked           = errors.New(\"database locked\")\n\tErrNoMigrationFiles = errors.New(\"no migration files found\")\n\tErrLockTimeout      = errors.New(\"timeout: can't acquire database lock\")\n\tErrApplied          = errors.New(\"Version already applied in database\")\n\tErrNotApplied       = errors.New(\"Migration not applied in database\")\n\tErrNoMigrationMode  = errors.New(\"Migration mode is disabled\")\n\tErrMigrationMode    = errors.New(\"Migration mode is enabled\")\n)\n\nconst (\n\tapplyingMigrationsMessage = \"Applying migrations\"\n)\n\nfunc newProgressBar(str string, w io.Writer, pbLogs bool) *pb.ProgressBar { //nolint:unparam\n\t// Default behaviour in non-interactive mode\n\tif !pbLogs && !term.IsTerminal(int(os.Stdout.Fd())) {\n\t\treturn nil\n\t}","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/migrate/migrate.go#L26-L62","documentation":"ErrNilVersion is returned by Version() when the database has no version recorded (no migration has been applied yet), analogous to migrate's NilVersion. It distinguishes 'fresh database' from a real error.","triggerScenarios":"Calling m.Version() before any migration has ever been applied on the target database.","commonSituations":"Fresh Hasura project, wrong endpoint/database pointing at an empty instance, or checking version before the first apply.","solutions":["Treat it as a fresh database: apply migrations first","Verify you're querying the intended environment","Use errors.Is(err, migrate.ErrNilVersion) to branch on fresh state"],"exampleFix":"// before\nv, err := m.Version()\nif err != nil { return err }\n// after\nv, err := m.Version()\nif err != nil && !errors.Is(err, migrate.ErrNilVersion) { return err }","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func IsFreshDatabase(err error) bool { return errors.Is(err, migrate.ErrNilVersion) }","tryCatchPattern":"v, err := m.Version()\nif err != nil {\n    if errors.Is(err, migrate.ErrNilVersion) { /* fresh DB: apply all */ }\n    return err\n}","preventionTips":["Handle ErrNilVersion explicitly before reporting errors","Confirm the target endpoint when version unexpectedly comes back nil"],"tags":["hasura","migration","sentinel","version"],"backgroundTag":"no-migrations-applied","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}