golang-migrate/migrate · error

no schema

Error message

no schema

What it means

ErrNoSchema (message "no schema") is declared in the Snowflake driver (snowflake.go:30) and returned when the schema component of the DSN is empty. In Open (snowflake.go:115-118) the second path segment must be a non-empty schema name; WithInstance/WithConnection also require Config.SchemaName. Snowflake namespaces objects as database.schema.table, so a schema is mandatory.

Source

Thrown at database/snowflake/snowflake.go:30

	"sync/atomic"

	"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) {

View on GitHub (pinned to 01a9643f14)

Solutions

  1. Include the schema in the path: snowflake://user:pass@account/PUBLIC/MYDB (segment order is account host, then /schema/database)
  2. Set SchemaName in the Config when using WithInstance/WithConnection
  3. Use PUBLIC explicitly if that is your intended default — it is not assumed for you

Example fix

// before
url := "snowflake://user:pass@acct//MYDB"
// after
url := "snowflake://user:pass@acct/PUBLIC/MYDB"
Defensive patterns

Strategy: validation

Validate before calling

u, _ := url.Parse(dsn)
parts := strings.Split(u.Path, "/")
if len(parts) < 3 || parts[1] == "" {
    return fmt.Errorf("snowflake DSN missing schema: %q", u.Path)
}

Prevention

When it happens

Trigger: URLs like snowflake://user:pass@account//database (empty schema segment); WithInstance with Config.SchemaName == "".

Common situations: Assuming a default schema (like PUBLIC) is applied automatically; Postgres-style two-level DSN habits (db + search_path) carried over to Snowflake; env-var substitution leaving the schema slot blank.

Related errors


AI-assisted analysis of golang-migrate/migrate@01a9643f14 (2026-09-02). Data as JSON: /api/errors/f41b61283214048f. Report an issue: GitHub.