ddd-ts-kit 0.23.1 → 0.24.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/CHANGELOG.md +37 -0
- package/README.fr.md +42 -7
- package/README.md +38 -6
- package/dist/check/canonical/stray-entry.d.ts +8 -0
- package/dist/check/canonical/stray-entry.d.ts.map +1 -0
- package/dist/check/canonical/stray-entry.js +75 -0
- package/dist/check/canonical/stray-entry.js.map +1 -0
- package/dist/check/catalogue/architecture-rules.d.ts.map +1 -1
- package/dist/check/catalogue/architecture-rules.js +2 -0
- package/dist/check/catalogue/architecture-rules.js.map +1 -1
- package/dist/check/catalogue/default-severities.d.ts.map +1 -1
- package/dist/check/catalogue/default-severities.js +1 -0
- package/dist/check/catalogue/default-severities.js.map +1 -1
- package/dist/check/explain/persistence-docs.js +1 -1
- package/dist/check/explain/persistence-docs.js.map +1 -1
- package/dist/check/explain/tree-docs.d.ts.map +1 -1
- package/dist/check/explain/tree-docs.js +5 -0
- package/dist/check/explain/tree-docs.js.map +1 -1
- package/dist/check/fixtures/tree-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/tree-fixtures.js +17 -0
- package/dist/check/fixtures/tree-fixtures.js.map +1 -1
- package/dist/check/migrations/drizzle-history-findings.js +1 -1
- package/dist/check/migrations/drizzle-history-findings.js.map +1 -1
- package/dist/check/rules/tree-closed.d.ts.map +1 -1
- package/dist/check/rules/tree-closed.js +4 -68
- package/dist/check/rules/tree-closed.js.map +1 -1
- package/dist/check/rules/tree-documented-paths.d.ts +3 -0
- package/dist/check/rules/tree-documented-paths.d.ts.map +1 -0
- package/dist/check/rules/tree-documented-paths.js +54 -0
- package/dist/check/rules/tree-documented-paths.js.map +1 -0
- package/dist/commands/drizzle-generate.d.ts +6 -1
- package/dist/commands/drizzle-generate.d.ts.map +1 -1
- package/dist/commands/drizzle-generate.js +39 -6
- package/dist/commands/drizzle-generate.js.map +1 -1
- package/dist/commands/plan-waves.d.ts +9 -0
- package/dist/commands/plan-waves.d.ts.map +1 -0
- package/dist/commands/plan-waves.js +36 -0
- package/dist/commands/plan-waves.js.map +1 -0
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +4 -2
- package/dist/commands/status.js.map +1 -1
- package/dist/help/notes.d.ts +1 -1
- package/dist/help/notes.d.ts.map +1 -1
- package/dist/help/notes.js +19 -3
- package/dist/help/notes.js.map +1 -1
- package/dist/help/usage.d.ts +1 -1
- package/dist/help/usage.d.ts.map +1 -1
- package/dist/help/usage.js +2 -0
- package/dist/help/usage.js.map +1 -1
- package/dist/init/files/persistence-files.d.ts.map +1 -1
- package/dist/init/files/persistence-files.js +7 -1
- package/dist/init/files/persistence-files.js.map +1 -1
- package/dist/init/manifest/versions.js +24 -24
- package/dist/migration/branch-migration.d.ts +9 -0
- package/dist/migration/branch-migration.d.ts.map +1 -0
- package/dist/migration/branch-migration.js +2 -0
- package/dist/migration/branch-migration.js.map +1 -0
- package/dist/migration/branch-migrations.d.ts +16 -0
- package/dist/migration/branch-migrations.d.ts.map +1 -0
- package/dist/migration/branch-migrations.js +48 -0
- package/dist/migration/branch-migrations.js.map +1 -0
- package/dist/migration/delete-branch-migrations.d.ts +9 -0
- package/dist/migration/delete-branch-migrations.d.ts.map +1 -0
- package/dist/migration/delete-branch-migrations.js +23 -0
- package/dist/migration/delete-branch-migrations.js.map +1 -0
- package/dist/migration/drizzle-run.d.ts +7 -0
- package/dist/migration/drizzle-run.d.ts.map +1 -0
- package/dist/migration/drizzle-run.js +2 -0
- package/dist/migration/drizzle-run.js.map +1 -0
- package/dist/migration/drizzle-silent-failures.js +1 -1
- package/dist/migration/drizzle-silent-failures.js.map +1 -1
- package/dist/migration/find-project-formatter.d.ts +8 -0
- package/dist/migration/find-project-formatter.d.ts.map +1 -0
- package/dist/migration/find-project-formatter.js +52 -0
- package/dist/migration/find-project-formatter.js.map +1 -0
- package/dist/migration/format-written-files.d.ts +9 -0
- package/dist/migration/format-written-files.d.ts.map +1 -0
- package/dist/migration/format-written-files.js +32 -0
- package/dist/migration/format-written-files.js.map +1 -0
- package/dist/migration/generate-and-read.d.ts +6 -0
- package/dist/migration/generate-and-read.d.ts.map +1 -0
- package/dist/migration/generate-and-read.js +14 -0
- package/dist/migration/generate-and-read.js.map +1 -0
- package/dist/migration/index.d.ts +4 -0
- package/dist/migration/index.d.ts.map +1 -1
- package/dist/migration/index.js +4 -0
- package/dist/migration/index.js.map +1 -1
- package/dist/migration/known-primary-keys.d.ts +3 -0
- package/dist/migration/known-primary-keys.d.ts.map +1 -0
- package/dist/migration/known-primary-keys.js +2 -0
- package/dist/migration/known-primary-keys.js.map +1 -0
- package/dist/migration/migration-files.d.ts +7 -0
- package/dist/migration/migration-files.d.ts.map +1 -0
- package/dist/migration/migration-files.js +29 -0
- package/dist/migration/migration-files.js.map +1 -0
- package/dist/migration/plan-replay.d.ts +9 -0
- package/dist/migration/plan-replay.d.ts.map +1 -0
- package/dist/migration/plan-replay.js +68 -0
- package/dist/migration/plan-replay.js.map +1 -0
- package/dist/migration/previous-primary-keys.d.ts +9 -0
- package/dist/migration/previous-primary-keys.d.ts.map +1 -0
- package/dist/migration/previous-primary-keys.js +55 -0
- package/dist/migration/previous-primary-keys.js.map +1 -0
- package/dist/migration/primary-key-order-finding.d.ts +12 -0
- package/dist/migration/primary-key-order-finding.d.ts.map +1 -0
- package/dist/migration/primary-key-order-finding.js +2 -0
- package/dist/migration/primary-key-order-finding.js.map +1 -0
- package/dist/migration/primary-key-order-findings.d.ts +12 -0
- package/dist/migration/primary-key-order-findings.d.ts.map +1 -0
- package/dist/migration/primary-key-order-findings.js +55 -0
- package/dist/migration/primary-key-order-findings.js.map +1 -0
- package/dist/migration/project-formatter.d.ts +9 -0
- package/dist/migration/project-formatter.d.ts.map +1 -0
- package/dist/migration/project-formatter.js +2 -0
- package/dist/migration/project-formatter.js.map +1 -0
- package/dist/migration/replay-drizzle-migrations.d.ts +15 -0
- package/dist/migration/replay-drizzle-migrations.d.ts.map +1 -0
- package/dist/migration/replay-drizzle-migrations.js +63 -0
- package/dist/migration/replay-drizzle-migrations.js.map +1 -0
- package/dist/migration/replay-plan.d.ts +11 -0
- package/dist/migration/replay-plan.d.ts.map +1 -0
- package/dist/migration/replay-plan.js +2 -0
- package/dist/migration/replay-plan.js.map +1 -0
- package/dist/migration/replayed-name.d.ts +7 -0
- package/dist/migration/replayed-name.d.ts.map +1 -0
- package/dist/migration/replayed-name.js +12 -0
- package/dist/migration/replayed-name.js.map +1 -0
- package/dist/migration/sql-statement.d.ts +6 -0
- package/dist/migration/sql-statement.d.ts.map +1 -0
- package/dist/migration/sql-statement.js +2 -0
- package/dist/migration/sql-statement.js.map +1 -0
- package/dist/migration/sql-statements.d.ts +4 -0
- package/dist/migration/sql-statements.d.ts.map +1 -0
- package/dist/migration/sql-statements.js +36 -0
- package/dist/migration/sql-statements.js.map +1 -0
- package/dist/migration/table-change.d.ts +12 -0
- package/dist/migration/table-change.d.ts.map +1 -0
- package/dist/migration/table-change.js +2 -0
- package/dist/migration/table-change.js.map +1 -0
- package/dist/migration/table-changes.d.ts +9 -0
- package/dist/migration/table-changes.d.ts.map +1 -0
- package/dist/migration/table-changes.js +55 -0
- package/dist/migration/table-changes.js.map +1 -0
- package/dist/migration/tidy-written-migration.d.ts +5 -0
- package/dist/migration/tidy-written-migration.d.ts.map +1 -0
- package/dist/migration/tidy-written-migration.js +8 -0
- package/dist/migration/tidy-written-migration.js.map +1 -0
- package/dist/migration/wait-for-next-second.d.ts +6 -0
- package/dist/migration/wait-for-next-second.d.ts.map +1 -0
- package/dist/migration/wait-for-next-second.js +11 -0
- package/dist/migration/wait-for-next-second.js.map +1 -0
- package/dist/migration/warn-primary-key-order.d.ts +5 -0
- package/dist/migration/warn-primary-key-order.d.ts.map +1 -0
- package/dist/migration/warn-primary-key-order.js +16 -0
- package/dist/migration/warn-primary-key-order.js.map +1 -0
- package/dist/migration/written-migration.d.ts +9 -0
- package/dist/migration/written-migration.d.ts.map +1 -0
- package/dist/migration/written-migration.js +2 -0
- package/dist/migration/written-migration.js.map +1 -0
- package/dist/migration/written-paths.d.ts +3 -0
- package/dist/migration/written-paths.d.ts.map +1 -0
- package/dist/migration/written-paths.js +5 -0
- package/dist/migration/written-paths.js.map +1 -0
- package/dist/plan/aggregates-of.d.ts +6 -0
- package/dist/plan/aggregates-of.d.ts.map +1 -0
- package/dist/plan/aggregates-of.js +13 -0
- package/dist/plan/aggregates-of.js.map +1 -0
- package/dist/plan/batched-waves.d.ts +18 -0
- package/dist/plan/batched-waves.d.ts.map +1 -0
- package/dist/plan/batched-waves.js +73 -0
- package/dist/plan/batched-waves.js.map +1 -0
- package/dist/plan/cycles-of.d.ts +8 -0
- package/dist/plan/cycles-of.d.ts.map +1 -0
- package/dist/plan/cycles-of.js +30 -0
- package/dist/plan/cycles-of.js.map +1 -0
- package/dist/plan/format-plan.d.ts +4 -0
- package/dist/plan/format-plan.d.ts.map +1 -0
- package/dist/plan/format-plan.js +53 -0
- package/dist/plan/format-plan.js.map +1 -0
- package/dist/plan/merge-order.d.ts +8 -0
- package/dist/plan/merge-order.d.ts.map +1 -0
- package/dist/plan/merge-order.js +32 -0
- package/dist/plan/merge-order.js.map +1 -0
- package/dist/plan/plan-problems.d.ts +8 -0
- package/dist/plan/plan-problems.d.ts.map +1 -0
- package/dist/plan/plan-problems.js +57 -0
- package/dist/plan/plan-problems.js.map +1 -0
- package/dist/plan/plan-waves.d.ts +16 -0
- package/dist/plan/plan-waves.d.ts.map +1 -0
- package/dist/plan/plan-waves.js +23 -0
- package/dist/plan/plan-waves.js.map +1 -0
- package/dist/plan/rows-to-plan.d.ts +7 -0
- package/dist/plan/rows-to-plan.d.ts.map +1 -0
- package/dist/plan/rows-to-plan.js +19 -0
- package/dist/plan/rows-to-plan.js.map +1 -0
- package/dist/plan/wave-numbers.d.ts +8 -0
- package/dist/plan/wave-numbers.d.ts.map +1 -0
- package/dist/plan/wave-numbers.js +27 -0
- package/dist/plan/wave-numbers.js.map +1 -0
- package/dist/plan/wave-plan.d.ts +48 -0
- package/dist/plan/wave-plan.d.ts.map +1 -0
- package/dist/plan/wave-plan.js +2 -0
- package/dist/plan/wave-plan.js.map +1 -0
- package/dist/progress/format-progress.d.ts.map +1 -1
- package/dist/progress/format-progress.js +16 -1
- package/dist/progress/format-progress.js.map +1 -1
- package/dist/progress/progress.d.ts +11 -1
- package/dist/progress/progress.d.ts.map +1 -1
- package/dist/progress/read-progress.d.ts +6 -2
- package/dist/progress/read-progress.d.ts.map +1 -1
- package/dist/progress/read-progress.js +10 -5
- package/dist/progress/read-progress.js.map +1 -1
- package/dist/progress/status-row-of.d.ts +16 -0
- package/dist/progress/status-row-of.d.ts.map +1 -0
- package/dist/progress/status-row-of.js +23 -0
- package/dist/progress/status-row-of.js.map +1 -0
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +2 -0
- package/dist/run.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worker/rows-on-branches.d.ts +8 -0
- package/dist/worker/rows-on-branches.d.ts.map +1 -0
- package/dist/worker/rows-on-branches.js +9 -0
- package/dist/worker/rows-on-branches.js.map +1 -0
- package/package.json +2 -2
- package/templates/e2e/e2e.spec.ts.tpl +2 -2
- package/templates/init/e2e/start-application.database.ts.tpl +30 -1
- package/templates/init/e2e/start-application.memory.ts.tpl +30 -1
- package/templates/init/e2e/vitest.e2e.config.ts.tpl +4 -0
- package/templates/init/platform/database/open-test-database.drizzle.ts.tpl +18 -1
- package/templates/init/platform/database/open-test-database.knex.ts.tpl +18 -1
- package/templates/init/platform/database/open-test-database.prisma.ts.tpl +18 -1
- package/templates/init/platform/database/open-test-database.typeorm.ts.tpl +18 -1
- package/templates/init/platform/database/test-database-template.ts.tpl +23 -0
- package/templates/init/rules/tests.md.tpl +1 -1
- package/templates/pipeline/package-scripts.json +1 -1
- package/templates/pipeline/vitest.config.ts.tpl +6 -0
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
/** Ranges written to the generated package.json; bumped together with the kit. */
|
|
2
2
|
export const VERSIONS = {
|
|
3
|
-
'@ddd-ts-kit/kernel': '^0.
|
|
4
|
-
'@ddd-ts-kit/validation': '^0.
|
|
5
|
-
'@ddd-ts-kit/http': '^0.
|
|
6
|
-
'@ddd-ts-kit/tracing': '^0.
|
|
7
|
-
'@ddd-ts-kit/di': '^0.
|
|
8
|
-
'@ddd-ts-kit/events': '^0.
|
|
9
|
-
'@ddd-ts-kit/testing': '^0.
|
|
10
|
-
'@ddd-ts-kit/drizzle': '^0.
|
|
11
|
-
'@ddd-ts-kit/knex': '^0.
|
|
12
|
-
'@ddd-ts-kit/prisma': '^0.
|
|
13
|
-
'@ddd-ts-kit/typeorm': '^0.
|
|
14
|
-
'@ddd-ts-kit/auth': '^0.
|
|
15
|
-
'@ddd-ts-kit/rabbitmq': '^0.
|
|
16
|
-
'@ddd-ts-kit/aspects': '^0.
|
|
17
|
-
'@ddd-ts-kit/audit': '^0.
|
|
18
|
-
'@ddd-ts-kit/redis': '^0.
|
|
19
|
-
'@ddd-ts-kit/kafka': '^0.
|
|
20
|
-
'@ddd-ts-kit/nats': '^0.
|
|
21
|
-
'@ddd-ts-kit/scheduling': '^0.
|
|
22
|
-
'@ddd-ts-kit/sentry': '^0.
|
|
23
|
-
'@ddd-ts-kit/s3': '^0.
|
|
3
|
+
'@ddd-ts-kit/kernel': '^0.24.0',
|
|
4
|
+
'@ddd-ts-kit/validation': '^0.24.0',
|
|
5
|
+
'@ddd-ts-kit/http': '^0.24.0',
|
|
6
|
+
'@ddd-ts-kit/tracing': '^0.24.0',
|
|
7
|
+
'@ddd-ts-kit/di': '^0.24.0',
|
|
8
|
+
'@ddd-ts-kit/events': '^0.24.0',
|
|
9
|
+
'@ddd-ts-kit/testing': '^0.24.0',
|
|
10
|
+
'@ddd-ts-kit/drizzle': '^0.24.0',
|
|
11
|
+
'@ddd-ts-kit/knex': '^0.24.0',
|
|
12
|
+
'@ddd-ts-kit/prisma': '^0.24.0',
|
|
13
|
+
'@ddd-ts-kit/typeorm': '^0.24.0',
|
|
14
|
+
'@ddd-ts-kit/auth': '^0.24.0',
|
|
15
|
+
'@ddd-ts-kit/rabbitmq': '^0.24.0',
|
|
16
|
+
'@ddd-ts-kit/aspects': '^0.24.0',
|
|
17
|
+
'@ddd-ts-kit/audit': '^0.24.0',
|
|
18
|
+
'@ddd-ts-kit/redis': '^0.24.0',
|
|
19
|
+
'@ddd-ts-kit/kafka': '^0.24.0',
|
|
20
|
+
'@ddd-ts-kit/nats': '^0.24.0',
|
|
21
|
+
'@ddd-ts-kit/scheduling': '^0.24.0',
|
|
22
|
+
'@ddd-ts-kit/sentry': '^0.24.0',
|
|
23
|
+
'@ddd-ts-kit/s3': '^0.24.0',
|
|
24
24
|
'@aws-sdk/client-s3': '^3.1150.0',
|
|
25
25
|
'@aws-sdk/lib-storage': '^3.1150.0',
|
|
26
26
|
'@aws-sdk/s3-request-presigner': '^3.1150.0',
|
|
27
27
|
busboy: '^1.6.0',
|
|
28
28
|
'@sentry/node': '^11.6.0',
|
|
29
|
-
'@ddd-ts-kit/pino': '^0.
|
|
29
|
+
'@ddd-ts-kit/pino': '^0.24.0',
|
|
30
30
|
pino: '^10.4.0',
|
|
31
31
|
'pino-pretty': '^13.2.0',
|
|
32
|
-
'@ddd-ts-kit/winston': '^0.
|
|
32
|
+
'@ddd-ts-kit/winston': '^0.24.0',
|
|
33
33
|
winston: '^3.19.0',
|
|
34
34
|
'@confluentinc/kafka-javascript': '^1.11.0',
|
|
35
35
|
'@nats-io/jetstream': '^3.4.0',
|
|
@@ -37,7 +37,7 @@ export const VERSIONS = {
|
|
|
37
37
|
ioredis: '^6.0.0',
|
|
38
38
|
jose: '^6.0.0',
|
|
39
39
|
amqplib: '^2.2.0',
|
|
40
|
-
'ddd-ts-kit': '^0.
|
|
40
|
+
'ddd-ts-kit': '^0.24.0',
|
|
41
41
|
tsx: '^4.23.15',
|
|
42
42
|
vitest: '^5.0.3',
|
|
43
43
|
zod: '^4.6.5',
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** A migration of the branch that its base does not have, as the branch wrote it. */
|
|
2
|
+
export interface BranchMigration {
|
|
3
|
+
/** Its file name without `.sql`: `20261015101500_working-add-invoices`. */
|
|
4
|
+
readonly tag: string;
|
|
5
|
+
readonly sql: string;
|
|
6
|
+
/** Its snapshot repeats the one before it: the schema did not change, the statements were written by hand (`--custom`). */
|
|
7
|
+
readonly custom: boolean;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=branch-migration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branch-migration.d.ts","sourceRoot":"","sources":["../../src/migration/branch-migration.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,MAAM,WAAW,eAAe;IAC9B,2EAA2E;IAC3E,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,2HAA2H;IAC3H,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branch-migration.js","sourceRoot":"","sources":["../../src/migration/branch-migration.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BranchMigration } from './branch-migration.js';
|
|
2
|
+
interface BranchFiles {
|
|
3
|
+
/** The files of the migrations folder and of its `meta/`, by path. */
|
|
4
|
+
readonly files: ReadonlyMap<string, string>;
|
|
5
|
+
readonly folder: string;
|
|
6
|
+
/** The tags of the branch's migrations, in their order. */
|
|
7
|
+
readonly tags: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The migrations of the branch with their SQL, each known as written by hand when its snapshot
|
|
11
|
+
* repeats, ids aside, the snapshot it names as `prevId`: drizzle-kit copies the last snapshot for a
|
|
12
|
+
* `--custom` migration, and writes the changed schema for any other.
|
|
13
|
+
*/
|
|
14
|
+
export declare function branchMigrations({ files, folder, tags }: BranchFiles): BranchMigration[];
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=branch-migrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branch-migrations.d.ts","sourceRoot":"","sources":["../../src/migration/branch-migrations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,UAAU,WAAW;IACnB,sEAAsE;IACtE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,2DAA2D;IAC3D,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,WAAW,GAAG,eAAe,EAAE,CAsBxF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { isRecord } from '../check/support/is-record.js';
|
|
2
|
+
/**
|
|
3
|
+
* The migrations of the branch with their SQL, each known as written by hand when its snapshot
|
|
4
|
+
* repeats, ids aside, the snapshot it names as `prevId`: drizzle-kit copies the last snapshot for a
|
|
5
|
+
* `--custom` migration, and writes the changed schema for any other.
|
|
6
|
+
*/
|
|
7
|
+
export function branchMigrations({ files, folder, tags }) {
|
|
8
|
+
const snapshots = new Map();
|
|
9
|
+
for (const [file, content] of files) {
|
|
10
|
+
const snapshot = file.startsWith(`${folder}/meta/`) && file.endsWith('_snapshot.json') ? parsed(content) : undefined;
|
|
11
|
+
if (isRecord(snapshot) && typeof snapshot['id'] === 'string') {
|
|
12
|
+
snapshots.set(snapshot['id'], withoutIds(snapshot));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return tags.map((tag) => {
|
|
16
|
+
const own = parsed(files.get(`${folder}/meta/${tag.split('_')[0] ?? ''}_snapshot.json`));
|
|
17
|
+
const parent = isRecord(own) && typeof own['prevId'] === 'string' ? snapshots.get(own['prevId']) : undefined;
|
|
18
|
+
return {
|
|
19
|
+
tag,
|
|
20
|
+
sql: files.get(`${folder}/${tag}.sql`) ?? '',
|
|
21
|
+
custom: isRecord(own) && parent !== undefined && withoutIds(own) === parent,
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/** The snapshot without its own id and its parent's, keys sorted: what two snapshots of one schema share. */
|
|
26
|
+
function withoutIds(snapshot) {
|
|
27
|
+
const schema = Object.entries(snapshot).filter(([key]) => key !== 'id' && key !== 'prevId');
|
|
28
|
+
return JSON.stringify(sorted(Object.fromEntries(schema)));
|
|
29
|
+
}
|
|
30
|
+
function sorted(value) {
|
|
31
|
+
if (Array.isArray(value)) {
|
|
32
|
+
return value.map(sorted);
|
|
33
|
+
}
|
|
34
|
+
return isRecord(value)
|
|
35
|
+
? Object.fromEntries(Object.keys(value)
|
|
36
|
+
.sort()
|
|
37
|
+
.map((key) => [key, sorted(value[key])]))
|
|
38
|
+
: value;
|
|
39
|
+
}
|
|
40
|
+
function parsed(text) {
|
|
41
|
+
try {
|
|
42
|
+
return text === undefined ? undefined : JSON.parse(text);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=branch-migrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branch-migrations.js","sourceRoot":"","sources":["../../src/migration/branch-migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAWzD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAe;IACnE,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;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C,QAAiC;IACnD,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,QAAQ,CAAC,CAAC;IAE5F,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,MAAM,CAAC,KAAc;IAC5B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO,QAAQ,CAAC,KAAK,CAAC;QACpB,CAAC,CAAC,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;aACf,IAAI,EAAE;aACN,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAC3C;QACH,CAAC,CAAC,KAAK,CAAC;AACZ,CAAC;AAED,SAAS,MAAM,CAAC,IAAwB;IACtC,IAAI,CAAC;QACH,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReplayPlan } from './replay-plan.js';
|
|
2
|
+
/**
|
|
3
|
+
* Deletes the migrations of the branch, their snapshots and their journal entries: the journal
|
|
4
|
+
* becomes the one of the base, so that its last snapshot is the parent of what drizzle-kit
|
|
5
|
+
* generates next. A file the base has under the same path (a snapshot numbered as one of the
|
|
6
|
+
* base's, under `prefix: 'index'`) takes the content of the base instead of being deleted.
|
|
7
|
+
*/
|
|
8
|
+
export declare function deleteBranchMigrations({ root, base, folder, migrations }: ReplayPlan): void;
|
|
9
|
+
//# sourceMappingURL=delete-branch-migrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-branch-migrations.d.ts","sourceRoot":"","sources":["../../src/migration/delete-branch-migrations.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,UAAU,GAAG,IAAI,CAa3F"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { runGit } from '../commit/run-git.js';
|
|
4
|
+
/**
|
|
5
|
+
* Deletes the migrations of the branch, their snapshots and their journal entries: the journal
|
|
6
|
+
* becomes the one of the base, so that its last snapshot is the parent of what drizzle-kit
|
|
7
|
+
* generates next. A file the base has under the same path (a snapshot numbered as one of the
|
|
8
|
+
* base's, under `prefix: 'index'`) takes the content of the base instead of being deleted.
|
|
9
|
+
*/
|
|
10
|
+
export function deleteBranchMigrations({ root, base, folder, migrations }) {
|
|
11
|
+
const snapshots = migrations.map((migration) => `${folder}/meta/${migration.tag.split('_')[0] ?? ''}_snapshot.json`);
|
|
12
|
+
const sqlFiles = migrations.map((migration) => `${folder}/${migration.tag}.sql`);
|
|
13
|
+
for (const file of [...sqlFiles, ...snapshots, `${folder}/meta/_journal.json`]) {
|
|
14
|
+
const onBase = runGit(root, ['show', `${base}:./${file}`]);
|
|
15
|
+
if (onBase === undefined) {
|
|
16
|
+
fs.rmSync(path.join(root, file), { force: true });
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
fs.writeFileSync(path.join(root, file), onBase);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=delete-branch-migrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-branch-migrations.js","sourceRoot":"","sources":["../../src/migration/delete-branch-migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAG9C;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAc;IACnF,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,GAAG,MAAM,SAAS,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IACrH,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,GAAG,MAAM,IAAI,SAAS,CAAC,GAAG,MAAM,CAAC,CAAC;IAEjF,KAAK,MAAM,IAAI,IAAI,CAAC,GAAG,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,MAAM,qBAAqB,CAAC,EAAE,CAAC;QAC/E,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,GAAG,IAAI,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC;QAE3D,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { WrittenMigration } from './written-migration.js';
|
|
2
|
+
/** One run of drizzle-kit generate: its exit code and what it wrote under the migrations folder. */
|
|
3
|
+
export interface DrizzleRun {
|
|
4
|
+
readonly code: number;
|
|
5
|
+
readonly written: WrittenMigration;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=drizzle-run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drizzle-run.d.ts","sourceRoot":"","sources":["../../src/migration/drizzle-run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,oGAAoG;AACpG,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;CACpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drizzle-run.js","sourceRoot":"","sources":["../../src/migration/drizzle-run.ts"],"names":[],"mappings":""}
|
|
@@ -8,7 +8,7 @@ export const DRIZZLE_SILENT_FAILURES = [
|
|
|
8
8
|
{
|
|
9
9
|
printed: 'which is a collision',
|
|
10
10
|
message: 'Two snapshots of the migrations were generated from the same one, as two branches merged without regenerating: no migration was written.',
|
|
11
|
-
fix: 'Keep the migrations of the main branch, delete the one of your branch (its .sql file, its snapshot under meta/ and its entry of meta/_journal.json), then run `npm run db:generate <name>` again on top of them; `npm run check:arch` names them (persistence/migration-history).',
|
|
11
|
+
fix: 'Keep the migrations of the main branch, delete the one of your branch (its .sql file, its snapshot under meta/ and its entry of meta/_journal.json), then run `npm run db:generate <name>` again on top of them, or let `npx ddd-ts-kit drizzle-generate --replay` do both; `npm run check:arch` names them (persistence/migration-history).',
|
|
12
12
|
},
|
|
13
13
|
];
|
|
14
14
|
//# sourceMappingURL=drizzle-silent-failures.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drizzle-silent-failures.js","sourceRoot":"","sources":["../../src/migration/drizzle-silent-failures.ts"],"names":[],"mappings":"AAOA,uCAAuC;AACvC,MAAM,CAAC,MAAM,uBAAuB,GAAoC;IACtE;QACE,OAAO,EAAE,mCAAmC;QAC5C,OAAO,EACL,8IAA8I;QAChJ,GAAG,EAAE,iXAAiX;KACvX;IACD;QACE,OAAO,EAAE,sBAAsB;QAC/B,OAAO,EACL,0IAA0I;QAC5I,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"drizzle-silent-failures.js","sourceRoot":"","sources":["../../src/migration/drizzle-silent-failures.ts"],"names":[],"mappings":"AAOA,uCAAuC;AACvC,MAAM,CAAC,MAAM,uBAAuB,GAAoC;IACtE;QACE,OAAO,EAAE,mCAAmC;QAC5C,OAAO,EACL,8IAA8I;QAChJ,GAAG,EAAE,iXAAiX;KACvX;IACD;QACE,OAAO,EAAE,sBAAsB;QAC/B,OAAO,EACL,0IAA0I;QAC5I,GAAG,EAAE,8UAA8U;KACpV;CACF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ProjectFormatter } from './project-formatter.js';
|
|
2
|
+
/**
|
|
3
|
+
* The formatter the `format` script of the project's package.json runs, Biome or Prettier, found
|
|
4
|
+
* in its node_modules; otherwise why nothing will be formatted. The script itself is not run: it
|
|
5
|
+
* formats the whole project (`biome format --write .`), where only what drizzle-kit wrote is meant.
|
|
6
|
+
*/
|
|
7
|
+
export declare function findProjectFormatter(root: string): ProjectFormatter | string;
|
|
8
|
+
//# sourceMappingURL=find-project-formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-project-formatter.d.ts","sourceRoot":"","sources":["../../src/migration/find-project-formatter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAsB/D;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,MAAM,CAa5E"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { isRecord } from '../check/support/is-record.js';
|
|
4
|
+
const KNOWN = [
|
|
5
|
+
{
|
|
6
|
+
name: 'Biome',
|
|
7
|
+
called: /\bbiome\b/,
|
|
8
|
+
packageName: '@biomejs/biome',
|
|
9
|
+
command: 'biome',
|
|
10
|
+
args: ['format', '--write', '--no-errors-on-unmatched'],
|
|
11
|
+
},
|
|
12
|
+
{ name: 'Prettier', called: /\bprettier\b/, packageName: 'prettier', command: 'prettier', args: ['--write'] },
|
|
13
|
+
];
|
|
14
|
+
/**
|
|
15
|
+
* The formatter the `format` script of the project's package.json runs, Biome or Prettier, found
|
|
16
|
+
* in its node_modules; otherwise why nothing will be formatted. The script itself is not run: it
|
|
17
|
+
* formats the whole project (`biome format --write .`), where only what drizzle-kit wrote is meant.
|
|
18
|
+
*/
|
|
19
|
+
export function findProjectFormatter(root) {
|
|
20
|
+
const script = formatScript(root);
|
|
21
|
+
const known = script === undefined ? undefined : KNOWN.find((formatter) => formatter.called.test(script));
|
|
22
|
+
if (known === undefined) {
|
|
23
|
+
return 'package.json has no `format` script that runs Biome or Prettier';
|
|
24
|
+
}
|
|
25
|
+
const bin = binOf(path.join(root, 'node_modules', known.packageName), known.command);
|
|
26
|
+
return bin === undefined
|
|
27
|
+
? `the format script runs ${known.name}, which is not installed (run \`npm install\`)`
|
|
28
|
+
: { name: known.name, bin, args: known.args };
|
|
29
|
+
}
|
|
30
|
+
function formatScript(root) {
|
|
31
|
+
const manifest = parsedFile(path.join(root, 'package.json'));
|
|
32
|
+
const scripts = isRecord(manifest) ? manifest['scripts'] : undefined;
|
|
33
|
+
const format = isRecord(scripts) ? scripts['format'] : undefined;
|
|
34
|
+
return typeof format === 'string' ? format : undefined;
|
|
35
|
+
}
|
|
36
|
+
/** The file its package.json declares for the command, as npm links it into node_modules/.bin. */
|
|
37
|
+
function binOf(directory, command) {
|
|
38
|
+
const manifest = parsedFile(path.join(directory, 'package.json'));
|
|
39
|
+
const bin = isRecord(manifest) ? manifest['bin'] : undefined;
|
|
40
|
+
const declared = isRecord(bin) ? bin[command] : bin;
|
|
41
|
+
const file = typeof declared === 'string' ? path.join(directory, declared) : undefined;
|
|
42
|
+
return file !== undefined && fs.existsSync(file) ? file : undefined;
|
|
43
|
+
}
|
|
44
|
+
function parsedFile(file) {
|
|
45
|
+
try {
|
|
46
|
+
return JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=find-project-formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-project-formatter.js","sourceRoot":"","sources":["../../src/migration/find-project-formatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAYzD,MAAM,KAAK,GAA8B;IACvC;QACE,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,WAAW;QACnB,WAAW,EAAE,gBAAgB;QAC7B,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,0BAA0B,CAAC;KACxD;IACD,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE;CAC9G,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,MAAM,MAA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G,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC;IAClE,MAAM,GAAG,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IACpD,MAAM,IAAI,GAAG,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAEvF,OAAO,IAAI,KAAK,SAAS,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACtE,CAAC;AAED,SAAS,UAAU,CAAC,IAAY;IAC9B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IACnD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Io } from '../commands/io.js';
|
|
2
|
+
import type { WrittenMigration } from './written-migration.js';
|
|
3
|
+
/**
|
|
4
|
+
* Formats the snapshot and the journal drizzle-kit wrote under `meta/` as the project formats its
|
|
5
|
+
* files, so that its format gate passes on them; the SQL is left as drizzle-kit wrote it. A
|
|
6
|
+
* formatter that fails or is missing is reported: the migration is written either way.
|
|
7
|
+
*/
|
|
8
|
+
export declare function formatWrittenFiles({ root, paths }: WrittenMigration, io: Io): void;
|
|
9
|
+
//# sourceMappingURL=format-written-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-written-files.d.ts","sourceRoot":"","sources":["../../src/migration/format-written-files.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAK/D;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,gBAAgB,EAAE,EAAE,EAAE,EAAE,GAAG,IAAI,CA8BlF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { findProjectFormatter } from './find-project-formatter.js';
|
|
3
|
+
/** Enough of a failing formatter to read the cause. */
|
|
4
|
+
const TAIL_LINES = 20;
|
|
5
|
+
/**
|
|
6
|
+
* Formats the snapshot and the journal drizzle-kit wrote under `meta/` as the project formats its
|
|
7
|
+
* files, so that its format gate passes on them; the SQL is left as drizzle-kit wrote it. A
|
|
8
|
+
* formatter that fails or is missing is reported: the migration is written either way.
|
|
9
|
+
*/
|
|
10
|
+
export function formatWrittenFiles({ root, paths }, io) {
|
|
11
|
+
const json = paths.filter((file) => file.includes('/meta/') && file.endsWith('.json'));
|
|
12
|
+
if (json.length === 0) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const formatter = findProjectFormatter(root);
|
|
16
|
+
if (typeof formatter === 'string') {
|
|
17
|
+
io.out(`Not formatted (${formatter}): ${json.join(', ')}.`);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const run = spawnSync(process.execPath, [formatter.bin, ...formatter.args, ...json], {
|
|
21
|
+
cwd: root,
|
|
22
|
+
encoding: 'utf8',
|
|
23
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
24
|
+
});
|
|
25
|
+
if (run.status === 0) {
|
|
26
|
+
io.out(`Formatted with ${formatter.name}, as the format script does: ${json.join(', ')}.`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const printed = `${run.stdout}${run.stderr}`.trimEnd().split('\n').slice(-TAIL_LINES).join('\n');
|
|
30
|
+
io.err(`Warning: ${formatter.name} failed on ${json.join(', ')}; format them before committing.\n${printed}`);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=format-written-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-written-files.js","sourceRoot":"","sources":["../../src/migration/format-written-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAGnE,uDAAuD;AACvD,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAoB,EAAE,EAAM;IAC1E,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAEvF,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO;IACT,CAAC;IAED,MAAM,SAAS,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAE7C,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAClC,EAAE,CAAC,GAAG,CAAC,kBAAkB,SAAS,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAE5D,OAAO;IACT,CAAC;IAED,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,EAAE;QACnF,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC;KAClC,CAAC,CAAC;IAEH,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,EAAE,CAAC,GAAG,CAAC,kBAAkB,SAAS,CAAC,IAAI,gCAAgC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAE3F,OAAO;IACT,CAAC;IAED,MAAM,OAAO,GAAG,GAAG,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEjG,EAAE,CAAC,GAAG,CAAC,YAAY,SAAS,CAAC,IAAI,cAAc,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,qCAAqC,OAAO,EAAE,CAAC,CAAC;AAChH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Io } from '../commands/io.js';
|
|
2
|
+
import type { DrizzleRun } from './drizzle-run.js';
|
|
3
|
+
import { type DrizzleMigration } from './generate-drizzle-migration.js';
|
|
4
|
+
/** Runs drizzle-kit generate for one migration and reads the migrations folder before and after it: what it wrote. */
|
|
5
|
+
export declare function generateAndRead(migration: DrizzleMigration, io: Io): DrizzleRun;
|
|
6
|
+
//# sourceMappingURL=generate-and-read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-and-read.d.ts","sourceRoot":"","sources":["../../src/migration/generate-and-read.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,KAAK,gBAAgB,EAA4B,MAAM,iCAAiC,CAAC;AAIlG,sHAAsH;AACtH,wBAAgB,eAAe,CAAC,SAAS,EAAE,gBAAgB,EAAE,EAAE,EAAE,EAAE,GAAG,UAAU,CAQ/E"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { drizzleOutFolder } from '../check/migrations/drizzle-out-folder.js';
|
|
2
|
+
import { generateDrizzleMigration } from './generate-drizzle-migration.js';
|
|
3
|
+
import { migrationFiles } from './migration-files.js';
|
|
4
|
+
import { writtenPaths } from './written-paths.js';
|
|
5
|
+
/** Runs drizzle-kit generate for one migration and reads the migrations folder before and after it: what it wrote. */
|
|
6
|
+
export function generateAndRead(migration, io) {
|
|
7
|
+
const { root } = migration;
|
|
8
|
+
const folder = drizzleOutFolder(root);
|
|
9
|
+
const before = migrationFiles(root, folder);
|
|
10
|
+
const code = generateDrizzleMigration(migration, io);
|
|
11
|
+
const after = migrationFiles(root, folder);
|
|
12
|
+
return { code, written: { root, paths: writtenPaths(before, after), files: after } };
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=generate-and-read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-and-read.js","sourceRoot":"","sources":["../../src/migration/generate-and-read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAG7E,OAAO,EAAyB,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAClG,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,sHAAsH;AACtH,MAAM,UAAU,eAAe,CAAC,SAA2B,EAAE,EAAM;IACjE,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC;IAC3B,MAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC5C,MAAM,IAAI,GAAG,wBAAwB,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACrD,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAE3C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC;AACvF,CAAC"}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
export { generateAndRead } from './generate-and-read.js';
|
|
1
2
|
export { generateDrizzleMigration } from './generate-drizzle-migration.js';
|
|
3
|
+
export { primaryKeyOrderFindings } from './primary-key-order-findings.js';
|
|
4
|
+
export { replayDrizzleMigrations } from './replay-drizzle-migrations.js';
|
|
5
|
+
export { tidyWrittenMigration } from './tidy-written-migration.js';
|
|
2
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC"}
|
package/dist/migration/index.js
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
export { generateAndRead } from './generate-and-read.js';
|
|
1
2
|
export { generateDrizzleMigration } from './generate-drizzle-migration.js';
|
|
3
|
+
export { primaryKeyOrderFindings } from './primary-key-order-findings.js';
|
|
4
|
+
export { replayDrizzleMigrations } from './replay-drizzle-migrations.js';
|
|
5
|
+
export { tidyWrittenMigration } from './tidy-written-migration.js';
|
|
2
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"known-primary-keys.d.ts","sourceRoot":"","sources":["../../src/migration/known-primary-keys.ts"],"names":[],"mappings":"AAAA,sHAAsH;AACtH,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"known-primary-keys.js","sourceRoot":"","sources":["../../src/migration/known-primary-keys.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The files of a drizzle-kit migrations folder and of its `meta/`, by their path relative to the
|
|
3
|
+
* project root (POSIX separators), with their content: read before and after drizzle-kit runs, they
|
|
4
|
+
* tell what it wrote.
|
|
5
|
+
*/
|
|
6
|
+
export declare function migrationFiles(root: string, folder: string): Map<string, string>;
|
|
7
|
+
//# sourceMappingURL=migration-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-files.d.ts","sourceRoot":"","sources":["../../src/migration/migration-files.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAUhF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* The files of a drizzle-kit migrations folder and of its `meta/`, by their path relative to the
|
|
5
|
+
* project root (POSIX separators), with their content: read before and after drizzle-kit runs, they
|
|
6
|
+
* tell what it wrote.
|
|
7
|
+
*/
|
|
8
|
+
export function migrationFiles(root, folder) {
|
|
9
|
+
const files = new Map();
|
|
10
|
+
for (const directory of [folder, `${folder}/meta`]) {
|
|
11
|
+
for (const name of filesIn(path.join(root, directory))) {
|
|
12
|
+
files.set(`${directory}/${name}`, fs.readFileSync(path.join(root, directory, name), 'utf8'));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return files;
|
|
16
|
+
}
|
|
17
|
+
function filesIn(directory) {
|
|
18
|
+
try {
|
|
19
|
+
return fs
|
|
20
|
+
.readdirSync(directory, { withFileTypes: true })
|
|
21
|
+
.filter((entry) => entry.isFile())
|
|
22
|
+
.map((entry) => entry.name)
|
|
23
|
+
.sort();
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=migration-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-files.js","sourceRoot":"","sources":["../../src/migration/migration-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,MAAc;IACzD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IAExC,KAAK,MAAM,SAAS,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,OAAO,CAAC,EAAE,CAAC;QACnD,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC;YACvD,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,IAAI,IAAI,EAAE,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;QAC/F,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,OAAO,CAAC,SAAiB;IAChC,IAAI,CAAC;QACH,OAAO,EAAE;aACN,WAAW,CAAC,SAAS,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;aAC/C,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;aACjC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;aAC1B,IAAI,EAAE,CAAC;IACZ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReplayPlan } from './replay-plan.js';
|
|
2
|
+
/**
|
|
3
|
+
* The migrations of the branch that `base` does not have, by their `.sql` files, read before
|
|
4
|
+
* anything is deleted. Refused, with the fix: a journal that still holds conflict markers, a base
|
|
5
|
+
* that is not a commit, a base with migrations the branch has not merged, and more than one
|
|
6
|
+
* migration of the branch that changes the schema.
|
|
7
|
+
*/
|
|
8
|
+
export declare function planReplay({ root, base }: Pick<ReplayPlan, 'root' | 'base'>): ReplayPlan;
|
|
9
|
+
//# sourceMappingURL=plan-replay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-replay.d.ts","sourceRoot":"","sources":["../../src/migration/plan-replay.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAInD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,UAAU,CAuBxF"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { drizzleOutFolder } from '../check/migrations/drizzle-out-folder.js';
|
|
4
|
+
import { CliError } from '../cli-error.js';
|
|
5
|
+
import { runGit } from '../commit/run-git.js';
|
|
6
|
+
import { branchMigrations } from './branch-migrations.js';
|
|
7
|
+
import { migrationFiles } from './migration-files.js';
|
|
8
|
+
const CONFLICT_MARKER = /^(?:<{7}|={7}|>{7})(?: |$)/m;
|
|
9
|
+
/**
|
|
10
|
+
* The migrations of the branch that `base` does not have, by their `.sql` files, read before
|
|
11
|
+
* anything is deleted. Refused, with the fix: a journal that still holds conflict markers, a base
|
|
12
|
+
* that is not a commit, a base with migrations the branch has not merged, and more than one
|
|
13
|
+
* migration of the branch that changes the schema.
|
|
14
|
+
*/
|
|
15
|
+
export function planReplay({ root, base }) {
|
|
16
|
+
const folder = drizzleOutFolder(root);
|
|
17
|
+
refuseConflictMarkers(root, `${folder}/meta/_journal.json`, base);
|
|
18
|
+
refuseUnknownBase(root, base);
|
|
19
|
+
const onBase = sqlTags(runGit(root, ['ls-tree', '--name-only', base, '--', `${folder}/`]) ?? '');
|
|
20
|
+
const files = migrationFiles(root, folder);
|
|
21
|
+
const here = sqlTags([...files.keys()].join('\n'));
|
|
22
|
+
const notMerged = onBase.filter((tag) => !here.includes(tag));
|
|
23
|
+
if (notMerged.length > 0) {
|
|
24
|
+
throw new CliError(`${base} has migrations this branch does not have: ${notMerged.join(', ')}.`, `Merge it first (\`git merge ${base}\`), then run the replay again.`);
|
|
25
|
+
}
|
|
26
|
+
const migrations = branchMigrations({ files, folder, tags: here.filter((tag) => !onBase.includes(tag)) });
|
|
27
|
+
refuseSeveralSchemaChanges(migrations);
|
|
28
|
+
return { root, base, folder, migrations };
|
|
29
|
+
}
|
|
30
|
+
function refuseConflictMarkers(root, journal, base) {
|
|
31
|
+
if (CONFLICT_MARKER.test(readIfPresent(path.join(root, journal)))) {
|
|
32
|
+
throw new CliError(`${journal} still holds the conflict markers of a merge.`, `Take the journal of the base, \`git checkout ${base} -- ${journal}\`, then run the replay again: it finds the migrations of the branch by their files.`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function refuseUnknownBase(root, base) {
|
|
36
|
+
if (runGit(root, ['rev-parse', '--verify', '--quiet', `${base}^{commit}`]) === undefined) {
|
|
37
|
+
throw new CliError(`${base} is not a commit of this repository.`, 'Fetch it (`git fetch origin`), or name the trunk the branch merged with `--base <ref>`.');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* drizzle-kit generates the difference between the schema files, as they are at the end of the
|
|
42
|
+
* branch, and the last snapshot: it can generate the changes of the branch again as one migration,
|
|
43
|
+
* never as the steps they were.
|
|
44
|
+
*/
|
|
45
|
+
function refuseSeveralSchemaChanges(migrations) {
|
|
46
|
+
const changing = migrations.filter((migration) => !migration.custom).map((migration) => migration.tag);
|
|
47
|
+
if (changing.length > 1) {
|
|
48
|
+
throw new CliError(`${changing.length} migrations of this branch change the schema (${changing.join(', ')}): drizzle-kit generates the difference between the schema files and the last snapshot, so it can generate them again only as one.`, 'Delete them (each .sql file, its snapshot under meta/ and its journal entry) and run `npm run db:generate <what-it-does>` once, then the replay again for the custom ones. A worker keeps one working migration and generates it again when its slice changes the schema again.');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** The names without `.sql` of the files listed one per line directly under the migrations folder. */
|
|
52
|
+
function sqlTags(listing) {
|
|
53
|
+
return listing
|
|
54
|
+
.split('\n')
|
|
55
|
+
.map((line) => line.trim())
|
|
56
|
+
.filter((line) => line.endsWith('.sql') && !line.includes('/meta/'))
|
|
57
|
+
.map((line) => path.posix.basename(line, '.sql'))
|
|
58
|
+
.sort();
|
|
59
|
+
}
|
|
60
|
+
function readIfPresent(file) {
|
|
61
|
+
try {
|
|
62
|
+
return fs.readFileSync(file, 'utf8');
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return '';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=plan-replay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-replay.js","sourceRoot":"","sources":["../../src/migration/plan-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,MAAM,eAAe,GAAG,6BAA6B,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,EAAE,IAAI,EAAE,IAAI,EAAqC;IAC1E,MAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAEtC,qBAAqB,CAAC,IAAI,EAAE,GAAG,MAAM,qBAAqB,EAAE,IAAI,CAAC,CAAC;IAClE,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAE9B,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,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,CAAC;AAED,SAAS,aAAa,CAAC,IAAY;IACjC,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { KnownPrimaryKeys } from './known-primary-keys.js';
|
|
2
|
+
/**
|
|
3
|
+
* The primary keys recorded by the snapshot a migration was generated from (the one its own
|
|
4
|
+
* snapshot names as `prevId`), read from the files of the migrations folder: a column marked
|
|
5
|
+
* `primaryKey` gives `<table>_pkey`, as PostgreSQL names it, and `compositePrimaryKeys` their own
|
|
6
|
+
* names. Empty when a snapshot is missing or of another shape.
|
|
7
|
+
*/
|
|
8
|
+
export declare function previousPrimaryKeys(files: ReadonlyMap<string, string>, sqlPath: string): KnownPrimaryKeys;
|
|
9
|
+
//# sourceMappingURL=previous-primary-keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"previous-primary-keys.d.ts","sourceRoot":"","sources":["../../src/migration/previous-primary-keys.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,gBAAgB,CAezG"}
|