Expand description
Standard-library P4b (#2608): the project’s migrations/ folder, which
holds each D1 instance’s schema migrations as
migrations/<database>/NNNN_<name>.sql, where <database> is the
instance’s undecorated database name (d1_database_name).
The checker stays disk-free: the folder reaches it from the caller as a
[bynk_project::assets::AssetFolder], and phase_d1_migrations checks
the file names, reads every file of a declared database, and warns about a
directory no instance owns. Wrangler applies the files and records which
ran in the database itself, so nothing here tracks that.
Structs§
- Migration
File - One migration file: its name (
0001_create_orders.sql) and its SQL.
Constants§
- IDEMPOTENCY_
BINDING - W30 (#2840): the binding of a Worker’s implicit idempotency database, which
holds
Idempotency.claim’s claims. A Worker that callsclaimdeclares it with no author action; its database is<worker>-idempotency(d1_database_name), and its schema isimplicit_migrations. - PG_
TEST_ KEY - #3321: the key the opt-in
Postgrestest double’s schema rides under in aD1Migrationson its way to the test emitters. Not a database name (those are<worker>-<capability>, never starting@), so it cannot collide with one, and nothing that looks a database up finds it. Present exactly when the project has[test] postgres = "pglite"; its one file isschema.sql, or none when the project has none.
Functions§
- d1_
database_ name - P4a (#2602): the account-facing name of a
D1instance’s database,<worker>-<capability, kebab>:shop-cartandD1_ORDERSgiveshop-cart-orders. D1 database names are scoped to the account, as R2 bucket names are.bynk deployenvironment-qualifies it. - declared_
databases - Every
D1instance’s database name, from each context’s derived capabilities. - double_
files - The
Postgrestest double’s database, as test emitters look it up: the project’sschema.sqlfor aPostgresinstance, the migrations of aD1database namedd1_databaseotherwise (#3321, P4b #2608). - implicit_
migrations - W30 (#2840): the migration files the compiler owns for an implicit database
(the author writes no SQL), by its
binding;Nonefor any other binding.idempotency_claimsholds one row per claimed key and the time it lapses;idempotency_valuesone per remembered key: its JSON value and the time it lapses. - is_d1
- Whether
instance(a context’s derived capability) is aD1database. - is_
ignored - Whether the listed
keyis hidden (.DS_Store, an editor’s.0001_create.sql.swp, anything under a.archive/directory) or an editor backup (0001_create.sql~), which the folder holds without meaning to: it’s neither checked nor copied. - is_
implicit_ idempotency - Whether
bindingis a Worker’s implicit idempotency database: decided by its source, not its name, so a project’s ownD1capability namedIdempotency(also bound asD1_IDEMPOTENCY) keeps its own migrations. - migration_
number - The number of a well-formed migration file name,
NNNN_<name>.sql: four ASCII digits, an underscore, then one or more letters, digits,_or-. Wrangler applies a directory’s.sqlfiles in name order, so the fixed width keeps that order numeric. - migrations_
of - The migration files of database
database, bound asbinding: the project’s own (migrations/<database>/), or the compiler’s for an implicit database (implicit_migrations). - pglite_
on - Whether the project opts in to the PGlite
Postgrestest double (#3321). - phase_
d1_ migrations - Check the listed
migrations/folder against the declared databases, and read the files of each.Nonemeans no filesystem was consulted, so there is nothing to check or read.
Type Aliases§
- D1Migrations
- Every declared database’s migrations, in order, keyed by database name. A database without a directory has no entry.