durable-db 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -11
- package/dist/cli/bin.js +1 -1
- package/dist/cli/index.d.ts +107 -7
- package/dist/cli/index.js +4 -4
- package/dist/{cli-5KmSf8wx.js → cli--9cKeEka.js} +474 -18
- package/dist/context/index.js +1 -1
- package/dist/db/index.d.ts +2 -2
- package/dist/db/index.js +4 -195
- package/dist/{defineDatabase-BE7YRtLh.d.ts → defineDatabase-DlgYfwhP.d.ts} +15 -6
- package/dist/{defineDatabase-Cb5sMNg0.js → defineDatabase-DypFFfjn.js} +2 -2
- package/dist/{index-CUkSkt7G.d.ts → index-B5W4m0Dq.d.ts} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{kysely-q97dtmaQ.js → kysely-DGc-CG_v.js} +1 -1
- package/dist/migrations/generator.d.ts +1 -1
- package/dist/migrations/generator.js +4 -2
- package/dist/migrations/snapshot.d.ts +2 -2
- package/dist/migrations/snapshot.js +1 -1
- package/dist/referencingRows-B6rU7TDW.js +193 -0
- package/dist/registry.d.ts +19 -8
- package/dist/registry.js +41 -18
- package/dist/{snapshot-D_z95s6E.js → snapshot-CY4FLqAo.js} +72 -3
- package/dist/{snapshot-B9Ae2TrS.d.ts → snapshot-D3_SNABU.d.ts} +13 -2
- package/dist/{state-DGYycIoJ.js → state-UT6GH0JD.js} +4 -2
- package/dist/testing/index.js +3 -3
- package/dist/vite/durableDb.d.ts +1 -1
- package/dist/vite/durableDb.js +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -339,7 +339,24 @@ The resolver is called at the moment a database operation needs the tenant ID
|
|
|
339
339
|
|
|
340
340
|
Behind the scenes, each action call is an RPC call to the correct Durable Object instance. The Vite plugin generates stubs that handle instance routing, argument validation, and DO communication transparently.
|
|
341
341
|
|
|
342
|
-
|
|
342
|
+
Each action's args schema is compiled on its first call and reused.
|
|
343
|
+
|
|
344
|
+
### One round trip per invocation: `batchScope()`
|
|
345
|
+
|
|
346
|
+
Calls to the **same** Durable Object instance that one invocation starts before it waits on I/O can share one round trip. Say what an invocation is by wrapping what the platform invokes:
|
|
347
|
+
|
|
348
|
+
```ts
|
|
349
|
+
import { batchScope } from 'durable-db/registry';
|
|
350
|
+
|
|
351
|
+
export default {
|
|
352
|
+
fetch: (request: Request, env: Env, ctx: ExecutionContext) => batchScope(() => app.fetch(request, env, ctx)),
|
|
353
|
+
queue: (batch: MessageBatch, env: Env) => batchScope(() => consume(batch, env)),
|
|
354
|
+
};
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
Inside it, `Promise.all([countProducts({}), listProducts({ featuredOnly: true })])` (or sibling server components fetching at once, or two RPC procedures whose middleware awaits a different number of times before their action calls) sends both in a single RPC, and the object runs them one after another, in the order they were made — each result or error goes back to its own caller. A lone call, and calls made one after another, are plain RPCs.
|
|
358
|
+
|
|
359
|
+
Outside a scope every call is its own RPC. A batch is only safe among the calls of one invocation — the Workers runtime refuses to settle one request's promise from another request's context — and nothing but the scope tells two concurrent requests' calls apart. (Before 0.12 calls were batched per object across the whole isolate, and two requests that reached one object in the same turn could leave one of them hanging.)
|
|
343
360
|
|
|
344
361
|
---
|
|
345
362
|
|
|
@@ -438,21 +455,28 @@ db generate --database main add_posts_table
|
|
|
438
455
|
| `--database <db>` | Only generate for this specific database |
|
|
439
456
|
| `--rename <table.old=new>` | Answer a rename question without a prompt (repeatable). See [Renames](#renames) |
|
|
440
457
|
| `--no-renames` | Answer every remaining rename question with "create" (the old column/table is dropped) |
|
|
441
|
-
| `--force` | Write the migration even when
|
|
458
|
+
| `--force` | Write the migration even when it is not safe on a database that has rows (`db validate` still refuses it) |
|
|
442
459
|
|
|
443
460
|
**What it does:**
|
|
444
461
|
|
|
445
462
|
1. Compares your current Drizzle schema against the production snapshot (`_snapshot.json`)
|
|
446
463
|
2. Generates SQL statements for the diff (asking about renames — see [Renames](#renames))
|
|
447
|
-
3. Checks what they do to a database that has rows (below) — before any file is written
|
|
464
|
+
3. Checks what they do to a database that has rows (below): reads the schema change, then replays the migration on rows — before any file is written
|
|
448
465
|
4. Writes a timestamped `.sql` file to the configured `migrationsDir`
|
|
449
466
|
5. Updates the production snapshot with a new ID and `prevId` chain
|
|
450
467
|
6. Clears dev state for this database (the dev migrations are now superseded by the production migration)
|
|
451
468
|
|
|
452
|
-
**Unsafe statements.** Per-tenant databases migrate lazily, on each tenant's first request after a deploy — so a statement that only fails on a table with rows surfaces in production, once per tenant with data, and that tenant's database stays broken until a fixed migration ships.
|
|
469
|
+
**Unsafe statements.** Per-tenant databases migrate lazily, on each tenant's first request after a deploy — so a statement that only fails on a table with rows surfaces in production, once per tenant with data, and that tenant's database stays broken until a fixed migration ships. Nobody can look into every tenant's database first, so a migration has to pass on **any rows the schema before it allows**. `generate` checks that twice, and writes nothing when it does not hold:
|
|
470
|
+
|
|
471
|
+
- It **reads the schema change**: a column added `NOT NULL` without a default is refused (`products.currency is added NOT NULL without a default — the migration fails on every table that has rows: add .default(...) or add it nullable and backfill`; see [Adding a required column](#adding-a-required-column)); a dropped column or table, a column made `NOT NULL` and a foreign key added to a table that exists are warned about (`⚠`).
|
|
472
|
+
- It **replays the migration on a database that has rows** (see [On a database that has rows](#on-a-database-that-has-rows)) and refuses one that fails there, or takes rows or values along:
|
|
453
473
|
|
|
454
|
-
|
|
455
|
-
|
|
474
|
+
```
|
|
475
|
+
Refusing to write a migration that is not safe on a database that has rows:
|
|
476
|
+
main: it fails on a database that has rows — FOREIGN KEY constraint failed (chunk 0, statement 2: INSERT INTO `__new_cart_items`…): a row references a row that is not there — remove or repair those rows in this migration, before the statement: DELETE FROM … WHERE … NOT IN (SELECT …)
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
`--force` writes the migration anyway — for one you are about to repair by hand (add the `UPDATE` or `DELETE` before the statement that fails), or for tables known to be empty everywhere. Writing is not accepting: `db validate` refuses it until the migration passes on rows or the finding is accepted there.
|
|
456
480
|
|
|
457
481
|
**Output example:**
|
|
458
482
|
|
|
@@ -566,6 +590,8 @@ db validate --verbose
|
|
|
566
590
|
|------|-------------|
|
|
567
591
|
| `--database <db>` | Only validate this specific database |
|
|
568
592
|
| `--no-dev` | Skip dev migrations, only validate production migrations |
|
|
593
|
+
| `--no-rows` | Skip the replay on a database that has rows |
|
|
594
|
+
| `--accept` | Record what the replay on rows finds in the production migrations as looked at and let through |
|
|
569
595
|
|
|
570
596
|
**What it does:**
|
|
571
597
|
|
|
@@ -574,9 +600,8 @@ db validate --verbose
|
|
|
574
600
|
3. Builds the expected schema separately from the Drizzle definition
|
|
575
601
|
4. Compares the migrated schema against the expected schema to detect drift
|
|
576
602
|
5. Reports SQL errors, foreign key violations, or schema mismatches
|
|
577
|
-
6.
|
|
578
|
-
|
|
579
|
-
The replay runs on an **empty** database, so it proves a migration is valid SQL, not that it succeeds on a table with rows. Committed migrations are not re-checked for that: validate cannot know which of them already ran where.
|
|
603
|
+
6. Replays the migrations once more **on a database that has rows** ([below](#on-a-database-that-has-rows)): a production migration that fails there, or takes rows or values along, is an error
|
|
604
|
+
7. Warns (`⚠ not yet generated: …`) about what the schema change `db generate` has not written yet would do to a database that has rows — the checks `generate` applies (a `NOT NULL` column without a default, dropped columns and tables, names that may be renames), and what a dev migration does on rows
|
|
580
605
|
|
|
581
606
|
**Output example (success):**
|
|
582
607
|
|
|
@@ -592,6 +617,11 @@ The replay runs on an **empty** database, so it proves a migration is valid SQL,
|
|
|
592
617
|
✗ 20240315123045_bad[0]: near "INVALID": syntax error
|
|
593
618
|
```
|
|
594
619
|
|
|
620
|
+
```
|
|
621
|
+
✗ main: 5 migration(s)
|
|
622
|
+
✗ 20240315123045_sku: fails on a database that has rows — NOT NULL constraint failed: __new_products.sku (chunk 0, statement 2: INSERT INTO `__new_products`…): a row holds NULL there — give those rows a value in this migration, before the statement: UPDATE … SET … WHERE … IS NULL
|
|
623
|
+
```
|
|
624
|
+
|
|
595
625
|
Schema drift (migrations ran cleanly but produce a different schema than your Drizzle definition) is reported as:
|
|
596
626
|
|
|
597
627
|
```
|
|
@@ -608,7 +638,9 @@ Schema drift (migrations ran cleanly but produce a different schema than your Dr
|
|
|
608
638
|
|
|
609
639
|
### Renames
|
|
610
640
|
|
|
611
|
-
drizzle-kit cannot tell a renamed column (or table) from a dropped one plus a new one.
|
|
641
|
+
drizzle-kit cannot tell a renamed column (or table) from a dropped one plus a new one. durable-db can, where there is one way to read it: **a table that lost exactly one column and gained exactly one declared the same way** — type, nullability, default, everything but the name — **was renamed**, and so was a table that is gone while a new one has its columns. `push` and `generate` write the rename (`` ALTER TABLE `users` RENAME COLUMN "bio" TO "about"; ``) without asking, in a terminal or not, and the data is kept. Taking it for a drop and a create would lose the data for a change nobody made; `--no-renames` says that is what you meant.
|
|
642
|
+
|
|
643
|
+
What is left is a real question — two new names for one that is gone, or a column that changed in more than its name. There drizzle-kit's diff asks:
|
|
612
644
|
|
|
613
645
|
```
|
|
614
646
|
Is about column in users table created or renamed from another column?
|
|
@@ -704,6 +736,39 @@ Each chunk is tracked independently in the `__migrations` table. If a Durable Ob
|
|
|
704
736
|
|
|
705
737
|
Concurrent first calls to a Durable Object share one migration run: requests that arrive while it migrates wait for it instead of applying the same statements again.
|
|
706
738
|
|
|
739
|
+
### On a database that has rows
|
|
740
|
+
|
|
741
|
+
A migration replayed on an empty database proves it is valid SQL. What goes wrong in production goes wrong on rows — and every tenant's database migrates on its own, after the deploy, where nobody is watching. So `db generate` and `db validate` replay each migration a second time, on a database filled with rows that are valid for the schema as it was and as unkind as that schema lets them be:
|
|
742
|
+
|
|
743
|
+
- every nullable column `NULL` in one row — a column made `NOT NULL` fails;
|
|
744
|
+
- the same values in two rows wherever nothing says they are unique — a new unique index fails;
|
|
745
|
+
- values no other table has in columns no foreign key ties down — a new foreign key fails;
|
|
746
|
+
- rows in every table that references another — a rebuild that takes them along shows.
|
|
747
|
+
|
|
748
|
+
It runs as a Durable Object runs a migration: foreign keys on and staying on (`PRAGMA foreign_keys=OFF` does nothing there, which is why a rebuild that adds a foreign key fails in production and passes anywhere else), each chunk in a transaction, the rows that reference a rebuilt table kept through its `DROP`.
|
|
749
|
+
|
|
750
|
+
What it reports, per migration:
|
|
751
|
+
|
|
752
|
+
| Finding | Meaning |
|
|
753
|
+
|---------|---------|
|
|
754
|
+
| `fails on a database that has rows — …` | A statement failed: the SQLite error, the statement, and what to do |
|
|
755
|
+
| `N of the M rows of <table> are gone after it` | Rows are lost and no statement of the migration deletes them |
|
|
756
|
+
| `<table>.<column> is empty after it in N row(s)` | A rebuild did not copy a column that is still there |
|
|
757
|
+
|
|
758
|
+
A rename keeps its rows and values under the new name, and is no finding. A `DELETE FROM` or `UPDATE` written into the migration is its author's: rows it removes and values it changes are not reported.
|
|
759
|
+
|
|
760
|
+
**The fix is in the migration.** Make the rows fit before the statement that needs them to:
|
|
761
|
+
|
|
762
|
+
```sql
|
|
763
|
+
UPDATE `products` SET `sku` = '' WHERE `sku` IS NULL;
|
|
764
|
+
|
|
765
|
+
--> breakpoint
|
|
766
|
+
|
|
767
|
+
-- … the rebuild that makes sku NOT NULL
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
Then `db validate` passes. Where a finding cannot happen — the migration already ran everywhere, or the rows it fails on cannot exist — accept it: `db validate --accept` writes it to `_accepted.json` next to the snapshot (by migration and finding, so a new finding in the same migration is still an error, and the file shows in review what was let through). A table no row could be made for (a `CHECK` the made-up values do not meet) is said, and not checked.
|
|
771
|
+
|
|
707
772
|
### Adding a required column
|
|
708
773
|
|
|
709
774
|
SQLite rejects `ALTER TABLE … ADD … NOT NULL` without a default on a table that has rows (`Cannot add a NOT NULL column with default value NULL`), and every tenant's database migrates on its own, after the deploy. So `db generate` refuses such a column (see [Unsafe statements](#db-generate)). Either:
|
|
@@ -1224,7 +1289,7 @@ related('customers', 'invoices', {
|
|
|
1224
1289
|
});
|
|
1225
1290
|
```
|
|
1226
1291
|
|
|
1227
|
-
**Filtering.** `where` says which rows of a
|
|
1292
|
+
**Filtering.** `where` says which rows of a relation to read — a condition on the related table, written with Kysely's expression builder and typed from the schema. On a `many` it applies before `limit`. On a `one` it says whether the row the foreign key leads to is read at all: where it does not hold the relation answers `null`, also for a foreign key that is never null — and the type says so (`related('invoices', 'customer', { columns: ['name'], where: (eb) => eb('vip', '=', true) })` is `{ name: string } | null`). Its values are bound like those of any condition:
|
|
1228
1293
|
|
|
1229
1294
|
```ts
|
|
1230
1295
|
related('invoices', 'invoiceLines', {
|
package/dist/cli/bin.js
CHANGED
package/dist/cli/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as DatabaseSource } from "../discovery-gHeLq8jk.js";
|
|
2
|
-
import {
|
|
3
|
-
import { l as DatabaseInfo } from "../defineDatabase-
|
|
4
|
-
import "../index-
|
|
2
|
+
import { C as parseRenameSpec, g as SchemaRenameRequiredError, h as SchemaAmbiguity, m as RenameAnswer, n as Snapshot, t as MigrationResolution, u as MigrationRisk } from "../snapshot-D3_SNABU.js";
|
|
3
|
+
import { l as DatabaseInfo } from "../defineDatabase-DlgYfwhP.js";
|
|
4
|
+
import "../index-B5W4m0Dq.js";
|
|
5
5
|
import { Command } from "commander";
|
|
6
6
|
import "vite";
|
|
7
7
|
import "@babel/types";
|
|
@@ -254,6 +254,67 @@ export declare function push(ctx?: PushContext): Promise<PushResult[]>;
|
|
|
254
254
|
*/
|
|
255
255
|
export declare function pushOne(ctx: PushContext | undefined, dbName: string): Promise<PushResult | null>;
|
|
256
256
|
//#endregion
|
|
257
|
+
//#region src/migrations/withRows.d.ts
|
|
258
|
+
/** The part of libsql's (better-sqlite3's) API the replay uses. */
|
|
259
|
+
interface RowsDatabase {
|
|
260
|
+
exec(sql: string): void;
|
|
261
|
+
prepare(sql: string): {
|
|
262
|
+
all(...params: unknown[]): unknown[];
|
|
263
|
+
run(...params: unknown[]): unknown;
|
|
264
|
+
};
|
|
265
|
+
close(): void;
|
|
266
|
+
}
|
|
267
|
+
type RowsDatabaseConstructor = new (filename: string) => RowsDatabase;
|
|
268
|
+
type RowsFindingKind = 'fails' | 'loses-rows' | 'loses-values';
|
|
269
|
+
/** What a migration does to a database that has rows, and should not. */
|
|
270
|
+
interface RowsFinding {
|
|
271
|
+
migration: string;
|
|
272
|
+
kind: RowsFindingKind;
|
|
273
|
+
table?: string;
|
|
274
|
+
column?: string;
|
|
275
|
+
/** Of a failure: the chunk and the statement that failed, and what SQLite said. */
|
|
276
|
+
chunk?: number;
|
|
277
|
+
statement?: string;
|
|
278
|
+
error?: string;
|
|
279
|
+
message: string;
|
|
280
|
+
/** Names the finding from one run to the next: what an acceptance is recorded by. */
|
|
281
|
+
fingerprint: string;
|
|
282
|
+
}
|
|
283
|
+
interface RowsReplay {
|
|
284
|
+
findings: RowsFinding[];
|
|
285
|
+
/** Tables no row could be made for (a CHECK the made-up values do not meet, say): not checked against rows. */
|
|
286
|
+
unseeded: {
|
|
287
|
+
table: string;
|
|
288
|
+
reason: string;
|
|
289
|
+
}[];
|
|
290
|
+
/** A migration that fails on an empty database too: the replay stopped there. */
|
|
291
|
+
stopped?: {
|
|
292
|
+
migration: string;
|
|
293
|
+
error: string;
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Replays `migrations`, in order, on a database with rows: before each one,
|
|
298
|
+
* every table gets rows its schema allows; then the migration runs as a
|
|
299
|
+
* Durable Object would run it. What fails, and what takes rows or values
|
|
300
|
+
* along without saying so, is a finding. A migration that fails is run again
|
|
301
|
+
* on the emptied database, so the ones after it are still checked.
|
|
302
|
+
*/
|
|
303
|
+
export declare function replayWithRows(Database: RowsDatabaseConstructor, migrations: readonly (readonly [name: string, chunks: string[][]])[]): RowsReplay;
|
|
304
|
+
/** `<migrations>/<database>/_accepted.json`: the findings someone has looked at and let through, by migration. */
|
|
305
|
+
type Accepted = Record<string, string[]>;
|
|
306
|
+
export declare const ACCEPTED_FILE = "_accepted.json";
|
|
307
|
+
/** The findings nobody has accepted, and the ones somebody has. */
|
|
308
|
+
export declare function sift(findings: RowsFinding[], accepted: Accepted): {
|
|
309
|
+
open: RowsFinding[];
|
|
310
|
+
accepted: RowsFinding[];
|
|
311
|
+
};
|
|
312
|
+
/** `accepted` with these findings added. */
|
|
313
|
+
export declare function accept(accepted: Accepted, findings: RowsFinding[]): Accepted;
|
|
314
|
+
/** The acceptances of a database's migrations; none where the file is not there (or cannot be read as one). */
|
|
315
|
+
export declare function readAccepted(migrationsDir: string): Accepted;
|
|
316
|
+
export declare function writeAccepted(migrationsDir: string, accepted: Accepted): void;
|
|
317
|
+
//#endregion
|
|
257
318
|
//#region src/cli/generate.d.ts
|
|
258
319
|
interface GenerateContext {
|
|
259
320
|
projectRoot?: string;
|
|
@@ -267,9 +328,12 @@ interface GenerateOptions extends RenameResolutionOptions {
|
|
|
267
328
|
/** Only generate for this database (an unknown name throws UnknownDatabaseError) */
|
|
268
329
|
database?: string;
|
|
269
330
|
/**
|
|
270
|
-
* Write the migration even when
|
|
271
|
-
*
|
|
272
|
-
*
|
|
331
|
+
* Write the migration even when it is not safe on a database that has rows
|
|
332
|
+
* — a statement that fails on every table with rows (a NOT NULL column
|
|
333
|
+
* without a default), or what the replay on rows finds (a foreign key over
|
|
334
|
+
* rows that reference nothing, a unique index over rows that repeat).
|
|
335
|
+
* Writing is not accepting: `db validate` still refuses it, until the
|
|
336
|
+
* migration repairs the rows or the finding is accepted there.
|
|
273
337
|
*/
|
|
274
338
|
force?: boolean;
|
|
275
339
|
}
|
|
@@ -301,6 +365,20 @@ export declare class UnsafeMigrationError extends Error {
|
|
|
301
365
|
database: string;
|
|
302
366
|
}>);
|
|
303
367
|
}
|
|
368
|
+
/**
|
|
369
|
+
* `db generate` refuses a migration that is not safe on a database that has
|
|
370
|
+
* rows: one the replay on rows (migrations/withRows.ts) sees fail, or take
|
|
371
|
+
* rows or values along. Nothing is written — unless `force`, for a migration
|
|
372
|
+
* that is going to be repaired by hand before it ships.
|
|
373
|
+
*/
|
|
374
|
+
export declare class MigrationFailsOnRowsError extends Error {
|
|
375
|
+
readonly findings: Array<RowsFinding & {
|
|
376
|
+
database: string;
|
|
377
|
+
}>;
|
|
378
|
+
constructor(findings: Array<RowsFinding & {
|
|
379
|
+
database: string;
|
|
380
|
+
}>);
|
|
381
|
+
}
|
|
304
382
|
/**
|
|
305
383
|
* Generate production migrations from schema changes
|
|
306
384
|
*
|
|
@@ -457,12 +535,26 @@ interface ValidateContext {
|
|
|
457
535
|
noDev?: boolean;
|
|
458
536
|
/** Only validate this database */
|
|
459
537
|
database?: string;
|
|
538
|
+
/**
|
|
539
|
+
* Skip the replay on a database that has rows (default: it runs). The
|
|
540
|
+
* replay on an empty one proves the SQL; this one, that it passes on data.
|
|
541
|
+
*/
|
|
542
|
+
rows?: boolean;
|
|
543
|
+
/**
|
|
544
|
+
* Record what the replay on rows finds in the production migrations as
|
|
545
|
+
* looked at and let through (`_accepted.json` next to the snapshot): for
|
|
546
|
+
* migrations that already ran everywhere, and for a failure that cannot
|
|
547
|
+
* happen on the data there is.
|
|
548
|
+
*/
|
|
549
|
+
accept?: boolean;
|
|
460
550
|
}
|
|
461
551
|
interface ValidateError {
|
|
462
552
|
migration: string;
|
|
463
553
|
chunk: number;
|
|
464
554
|
statement: string;
|
|
465
555
|
error: string;
|
|
556
|
+
/** Found by the replay on a database that has rows: the SQL is valid, the migration is not safe. */
|
|
557
|
+
rows?: RowsFinding;
|
|
466
558
|
}
|
|
467
559
|
interface ValidateResult {
|
|
468
560
|
database: string;
|
|
@@ -480,6 +572,14 @@ interface ValidateResult {
|
|
|
480
572
|
* database and cannot know which committed migrations already ran where.
|
|
481
573
|
*/
|
|
482
574
|
pendingWarnings: string[];
|
|
575
|
+
/**
|
|
576
|
+
* What the replay on a database that has rows found and somebody accepted
|
|
577
|
+
* (`_accepted.json`), what it found in dev migrations (`db generate` will
|
|
578
|
+
* refuse those), and the tables it could make no row for. What it found in
|
|
579
|
+
* production migrations and nobody accepted is in `errors`, and makes
|
|
580
|
+
* `migrationsValid` false.
|
|
581
|
+
*/
|
|
582
|
+
rowsWarnings: string[];
|
|
483
583
|
}
|
|
484
584
|
/**
|
|
485
585
|
* Dry-run all migrations against a local in-memory SQLite to catch errors
|
|
@@ -495,4 +595,4 @@ export declare function validate(ctx?: ValidateContext): Promise<ValidateResult[
|
|
|
495
595
|
*/
|
|
496
596
|
export declare function declaresSchema(db: Pick<DatabaseInfo, 'schemaExport' | 'schemaTableNames'>): boolean;
|
|
497
597
|
//#endregion
|
|
498
|
-
export { type DatabaseDevState, type DatabaseDiff, type DatabaseSource, type DatabaseStatus, type DbCommandDefaults, type DevPaths, type DevServerLock, type DevState, type DiffResult, type DiscoverOptions, type GenerateContext, type GenerateOptions, type GenerateResult, type MigrationRisk, type PushContext, type PushResult, type RenameAnswer, type RenameResolutionOptions, type ResetContext, type ResetOptions, type ResetResult, type SchemaAmbiguity, SchemaRenameRequiredError, type StatusContext, type StatusResult, type ValidateContext, type ValidateError, type ValidateResult, parseRenameSpec };
|
|
598
|
+
export { type Accepted, type DatabaseDevState, type DatabaseDiff, type DatabaseSource, type DatabaseStatus, type DbCommandDefaults, type DevPaths, type DevServerLock, type DevState, type DiffResult, type DiscoverOptions, type GenerateContext, type GenerateOptions, type GenerateResult, type MigrationRisk, type PushContext, type PushResult, type RenameAnswer, type RenameResolutionOptions, type ResetContext, type ResetOptions, type ResetResult, type RowsFinding, type RowsFindingKind, type RowsReplay, type SchemaAmbiguity, SchemaRenameRequiredError, type StatusContext, type StatusResult, type ValidateContext, type ValidateError, type ValidateResult, parseRenameSpec };
|
package/dist/cli/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { c as getDatabaseEpochs, d as getInstanceKey, f as init_state, g as runningDevServer, l as getDevEpoch, m as loadDevState, o as generateEpoch, p as loadDevMigrations, s as getDatabaseEpoch, u as getDevPaths, v as saveDevState } from "../state-UT6GH0JD.js";
|
|
2
|
+
import { _ as parseRenameSpec, u as SchemaRenameRequiredError } from "../snapshot-CY4FLqAo.js";
|
|
3
3
|
import { n as declaresSchema } from "../parser-mUnAtllk.js";
|
|
4
|
-
import { _ as
|
|
4
|
+
import { C as diffSchema, D as reportCliError, E as loadSchemaTables, O as selectDatabases, S as diffDatabases, T as loadSchema, _ as sift, a as reset, b as pushOne, c as status, d as generate, f as generateOne, g as replayWithRows, h as readAccepted, i as DevServerRunningError, l as MigrationFailsOnRowsError, m as accept, n as registerDbCommands, o as resetAndPush, p as ACCEPTED_FILE, r as validate, s as formatStatus, t as createDbCommand, u as UnsafeMigrationError, v as writeAccepted, w as discoverDatabases, x as UnknownDatabaseError, y as push } from "../cli--9cKeEka.js";
|
|
5
5
|
init_state();
|
|
6
|
-
export { DevServerRunningError, SchemaRenameRequiredError, UnknownDatabaseError, UnsafeMigrationError, createDbCommand, declaresSchema, diffDatabases, diffSchema, discoverDatabases, formatStatus, generate, generateEpoch, generateOne, getDatabaseEpoch, getDatabaseEpochs, getDevEpoch, getDevPaths, getInstanceKey, loadDevMigrations, loadDevState, loadSchema, loadSchemaTables, parseRenameSpec, push, pushOne, registerDbCommands, reportCliError, reset, resetAndPush, runningDevServer, saveDevState, selectDatabases, status, validate };
|
|
6
|
+
export { ACCEPTED_FILE, DevServerRunningError, MigrationFailsOnRowsError, SchemaRenameRequiredError, UnknownDatabaseError, UnsafeMigrationError, accept, createDbCommand, declaresSchema, diffDatabases, diffSchema, discoverDatabases, formatStatus, generate, generateEpoch, generateOne, getDatabaseEpoch, getDatabaseEpochs, getDevEpoch, getDevPaths, getInstanceKey, loadDevMigrations, loadDevState, loadSchema, loadSchemaTables, parseRenameSpec, push, pushOne, readAccepted, registerDbCommands, replayWithRows, reportCliError, reset, resetAndPush, runningDevServer, saveDevState, selectDatabases, sift, status, validate, writeAccepted };
|