golang-migrate/migrate · error
no schema/database name
Error message
no schema/database name
What it means
ErrNoSchemaOrDatabase (message "no schema/database name") is returned by Snowflake's Open (snowflake.go:105-108) when the URL path, split on "/", has fewer than 3 segments — i.e. both the schema and database parts of the DSN are missing. It fires before the more specific ErrNoSchema/ErrNoDatabaseName checks and means the DSN lacks Snowflake's required /schema/database path structure entirely.
Source
Thrown at database/snowflake/snowflake.go:31
"github.com/golang-migrate/migrate/v4/database"
"github.com/lib/pq"
sf "github.com/snowflakedb/gosnowflake"
)
func init() {
db := Snowflake{}
database.Register("snowflake", &db)
}
var DefaultMigrationsTable = "schema_migrations"
var (
ErrNilConfig = fmt.Errorf("no config")
ErrNoDatabaseName = fmt.Errorf("no database name")
ErrNoPassword = fmt.Errorf("no password")
ErrNoSchema = fmt.Errorf("no schema")
ErrNoSchemaOrDatabase = fmt.Errorf("no schema/database name")
)
type Config struct {
MigrationsTable string
DatabaseName string
}
type Snowflake struct {
isLocked atomic.Bool
conn *sql.Conn
db *sql.DB
// Open and WithInstance need to guarantee that config is never nil
config *Config
}
func WithInstance(instance *sql.DB, config *Config) (database.Driver, error) {
if config == nil {View on GitHub (pinned to 01a9643f14)
Solutions
- Provide the full path with both levels: snowflake://user:pass@account/schema/database
- If migrating from a single-segment DSN template, add the schema segment (commonly PUBLIC) and the database segment
- Validate the URL with url.Parse in your own code and assert len(strings.Split(p, "/")) >= 3 before calling Open
Example fix
// before url := "snowflake://user:pass@acct" // after url := "snowflake://user:pass@acct/PUBLIC/MYDB"
Defensive patterns
Strategy: validation
Validate before calling
u, _ := url.Parse(dsn)
if len(strings.Split(u.Path, "/")) < 3 {
return fmt.Errorf("snowflake DSN must include /schema/database in the path: %q", u.Path)
} Prevention
- Use the full three-part DSN form snowflake://user:pass@account/schema/database everywhere
- Do not reuse single-database DSN templates from Postgres/MySQL for Snowflake
- Add a startup config check that parses every DSN and asserts path depth before calling migrate.New
When it happens
Trigger: Opening snowflake://user:pass@account (no path) or snowflake://user:pass@account/db (only one path segment); nurl.Parse yielding a Path with insufficient components.
Common situations: Postgres/MySQL-style DSNs (single database in the path) pasted into a Snowflake URL; missing trailing path in templated URLs; users confusing the account identifier with the database name.
Related errors
AI-assisted analysis of golang-migrate/migrate@01a9643f14 (2026-09-02).
Data as JSON: /api/errors/c2abf3db2d6bdc02.
Report an issue: GitHub.