Skip to main content

D1Database

Creates and manages Cloudflare D1 Databases - serverless SQL databases built on SQLite.

Props

string
Name of the database.
string
Optional primary location hint for the database.Options: wnam, enam, weur, eeur, apac, oc
object
Read replication configuration (only mutable property during updates).
boolean
default:"true"
Whether to delete the database when the resource is removed from Alchemy.
boolean
default:"false"
Whether to adopt an existing database with the same name if it exists.
D1Database | { id: string } | { name: string }
Clone data from an existing database to this new database (only applicable during creation phase).
string[]
The names of SQL files to import. After migrations are applied, these files will be run.
string
default:"d1_migrations"
Name of the table used to track migrations. Only used if migrationsDir is specified.
string
Directory containing migration SQL files. If not set, no migrations will be applied.
default | eu | fedramp
Optional jurisdiction for the database.

Output

string
The unique ID of the database (UUID).
string
The name of the database.
D1DatabaseJurisdiction
The jurisdiction of the database.
d1
Type identifier for the binding.

Examples

Basic D1 Database

Database with Location Hint

Adopt Existing Database

Database with Migrations

Database with Custom Migration Table (Drizzle Compatible)

Clone Existing Database