d1

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDatabaseNotFound = Err(errPrefix + "database not found")

Functions

func NewMigrator added in v0.0.3

func NewMigrator(accountID, databaseID, apiToken string) (ddl.Execer, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL