{"record":{"id":"245ed5495a7e5811","repo":"golang-migrate/migrate","slug":"no-database-name-245ed5","errorCode":null,"errorMessage":"no database name","messagePattern":"no database name","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/ql/ql.go","lineNumber":25,"sourceCode":"\t\"io\"\n\tnurl \"net/url\"\n\t\"strings\"\n\t\"sync/atomic\"\n\n\t\"github.com/golang-migrate/migrate/v4\"\n\t\"github.com/golang-migrate/migrate/v4/database\"\n\t_ \"modernc.org/ql/driver\"\n)\n\nfunc init() {\n\tdatabase.Register(\"ql\", &Ql{})\n}\n\nvar DefaultMigrationsTable = \"schema_migrations\"\nvar (\n\tErrDatabaseDirty  = fmt.Errorf(\"database is dirty\")\n\tErrNilConfig      = fmt.Errorf(\"no config\")\n\tErrNoDatabaseName = fmt.Errorf(\"no database name\")\n\tErrAppendPEM      = fmt.Errorf(\"failed to append PEM\")\n)\n\ntype Config struct {\n\tMigrationsTable string\n\tDatabaseName    string\n}\n\ntype Ql struct {\n\tdb       *sql.DB\n\tisLocked atomic.Bool\n\n\tconfig *Config\n}\n\nfunc WithInstance(instance *sql.DB, config *Config) (database.Driver, error) {\n\tif config == nil {\n\t\treturn nil, ErrNilConfig","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/ql/ql.go#L7-L43","documentation":"ErrNoDatabaseName is returned by the ql driver when no database name was supplied — either Config.DatabaseName is empty in WithInstance/WithConnection, or the Open URL has no path. The driver needs the target database/schema name to place and address the migrations table.","triggerScenarios":"Calling ql.Open(\"ql://\") with an empty path; WithInstance/WithConnection with a Config whose DatabaseName field is \"\".","commonSituations":"Building the config programmatically and forgetting to copy the database name from application settings; using a DSN generator that omits the path for the ql scheme.","solutions":["Set Config.DatabaseName to the target database name before calling WithInstance/WithConnection","Include the database name in the URL path when using Open, e.g. ql://mydb","Add startup validation that fails fast with a clear message if the configured database name is empty"],"exampleFix":"// before\ncfg := &ql.Config{}\ndriver, err := ql.WithInstance(instance, cfg)\n// after\ncfg := &ql.Config{DatabaseName: os.Getenv(\"DB_NAME\")}\nif cfg.DatabaseName == \"\" {\n    return errors.New(\"DB_NAME must be set\")\n}\ndriver, err := ql.WithInstance(instance, cfg)","handlingStrategy":"validation","validationCode":"func requireDatabaseName(cfg *ql.Config) error {\n    if cfg == nil || cfg.DatabaseName == \"\" {\n        return errors.New(\"ql: DatabaseName is required\")\n    }\n    return nil\n}","typeGuard":"func hasDatabaseName(cfg *ql.Config) bool {\n    return cfg != nil && cfg.DatabaseName != \"\"\n}","tryCatchPattern":null,"preventionTips":["Fail fast at startup if the DB_NAME-style env var is empty","Include the database in the URL path when using Open","Centralize DSN/config building in one tested function"],"tags":["ql","configuration","missing-parameter","validation"],"backgroundTag":"missing-database-name","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}