Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrDatabaseNotFound = Err(errPrefix + "database not found")
Functions ¶
func NewMigrator ¶ added in v0.0.3
NewMigrator opens a D1 database over Cloudflare's HTTP Query API, for running schema migrations from CI — outside a Worker, where the NewEdge binding does not exist.
It is named for what it does rather than for its transport, and its return type says the same thing: ddl.Execer is exactly "somewhere to send DDL", so this connection cannot be mistaken for one you can read rows from. Inside a Worker, use NewEdge.
Because it is not a storage.Conn, ddl.Sync takes its additive path — CREATE TABLE plus ADD COLUMN, no safe-drop probe. That is the same path NewEdge already produces in production today (the WASM adapter does not implement ddl.TableIntrospector either), so migrating through this transport does not change migration behavior.
Usage:
conn, err := d1.NewMigrator(accountID, databaseID, apiToken) err = ddl.New(conn, sqlt.NewCompiler()).Sync(models...)
func NewMigratorWithURL ¶ added in v0.0.3
func NewMigratorWithURL(url, apiToken string) *migratorConn
NewMigratorWithURL is the test seam — it lets tests point the client at an httptest.Server instead of the real Cloudflare API.
Types ¶
This section is empty.