@onreza/sqlx-js 0.5.0 → 0.6.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 +59 -19
- package/ROADMAP.md +1 -1
- package/dist/bin/sqlx-js-diagnostics.d.ts +2 -0
- package/dist/bin/sqlx-js-diagnostics.js +96 -0
- package/dist/bin/sqlx-js.js +258 -81
- package/dist/src/commands/init.js +87 -3
- package/dist/src/commands/migrate.d.ts +2 -101
- package/dist/src/commands/migrate.js +6 -546
- package/dist/src/commands/prepare.d.ts +2 -1
- package/dist/src/commands/prepare.js +104 -5
- package/dist/src/commands/schema.js +1 -1
- package/dist/src/config.d.ts +1 -0
- package/dist/src/config.js +8 -0
- package/dist/src/migration-core.d.ts +157 -0
- package/dist/src/migration-core.js +578 -0
- package/dist/src/runtime.js +1 -1
- package/dist/src/scan/scanner.d.ts +1 -1
- package/dist/src/scan/scanner.js +4 -4
- package/dist/src/type-inspection.d.ts +1 -0
- package/dist/src/type-inspection.js +20 -0
- package/package.json +6 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PgClient } from "../pg/wire.js";
|
|
2
|
+
export * from "../migration-core.js";
|
|
2
3
|
export type MigrateOptions = {
|
|
3
4
|
databaseUrl: string;
|
|
4
5
|
migrationsDir: string;
|
|
@@ -12,91 +13,7 @@ export type MigrationWorkflowOptions = MigrateOptions & {
|
|
|
12
13
|
shadowAdminUrl?: string;
|
|
13
14
|
lockKey?: number | bigint;
|
|
14
15
|
lockTimeoutMs?: number;
|
|
15
|
-
|
|
16
|
-
export type MigrationStore = {
|
|
17
|
-
table: string;
|
|
18
|
-
};
|
|
19
|
-
export declare const DEFAULT_MIGRATE_LOCK_KEY = 18750938867203960n;
|
|
20
|
-
export declare function ensureTable(c: PgClient): Promise<MigrationStore>;
|
|
21
|
-
export declare function listApplied(c: PgClient, store?: MigrationStore): Promise<Map<number, {
|
|
22
|
-
name: string;
|
|
23
|
-
hash: string;
|
|
24
|
-
}>>;
|
|
25
|
-
export type ApplyOutcome = {
|
|
26
|
-
kind: "applied";
|
|
27
|
-
version: number;
|
|
28
|
-
name: string;
|
|
29
|
-
} | {
|
|
30
|
-
kind: "adopted";
|
|
31
|
-
version: number;
|
|
32
|
-
name: string;
|
|
33
|
-
replaced: number;
|
|
34
|
-
} | {
|
|
35
|
-
kind: "tampered";
|
|
36
|
-
version: number;
|
|
37
|
-
name: string;
|
|
38
|
-
applied: string;
|
|
39
|
-
current: string;
|
|
40
|
-
} | {
|
|
41
|
-
kind: "failed";
|
|
42
|
-
version: number;
|
|
43
|
-
name: string;
|
|
44
|
-
error: string;
|
|
45
|
-
};
|
|
46
|
-
export type PlanOutcome = {
|
|
47
|
-
kind: "pending";
|
|
48
|
-
version: number;
|
|
49
|
-
name: string;
|
|
50
|
-
} | {
|
|
51
|
-
kind: "adoptable";
|
|
52
|
-
version: number;
|
|
53
|
-
name: string;
|
|
54
|
-
replaced: number;
|
|
55
|
-
} | {
|
|
56
|
-
kind: "tampered";
|
|
57
|
-
version: number;
|
|
58
|
-
name: string;
|
|
59
|
-
applied: string;
|
|
60
|
-
current: string;
|
|
61
|
-
} | {
|
|
62
|
-
kind: "failed";
|
|
63
|
-
version: number;
|
|
64
|
-
name: string;
|
|
65
|
-
error: string;
|
|
66
|
-
};
|
|
67
|
-
export type MigrationPlanItem = {
|
|
68
|
-
kind: "apply";
|
|
69
|
-
version: number;
|
|
70
|
-
name: string;
|
|
71
|
-
} | {
|
|
72
|
-
kind: "adopt";
|
|
73
|
-
version: number;
|
|
74
|
-
name: string;
|
|
75
|
-
replaced: number;
|
|
76
|
-
};
|
|
77
|
-
export type MigrationPlanDiagnostic = Extract<PlanOutcome, {
|
|
78
|
-
kind: "tampered" | "failed";
|
|
79
|
-
}>;
|
|
80
|
-
export type MigrationPlanSnapshot = {
|
|
81
|
-
ok: boolean;
|
|
82
|
-
pending: number;
|
|
83
|
-
adoptable: number;
|
|
84
|
-
tampered: number;
|
|
85
|
-
failed: number;
|
|
86
|
-
steps: MigrationPlanItem[];
|
|
87
|
-
diagnostics: MigrationPlanDiagnostic[];
|
|
88
|
-
};
|
|
89
|
-
export type MigrationInfoStatus = "applied" | "pending" | "adoptable" | "superseded" | "tampered" | "failed";
|
|
90
|
-
export type MigrationInfoItem = {
|
|
91
|
-
version: number;
|
|
92
|
-
name: string;
|
|
93
|
-
status: MigrationInfoStatus;
|
|
94
|
-
detail?: string;
|
|
95
|
-
};
|
|
96
|
-
export type MigrationInfoSnapshot = {
|
|
97
|
-
historyTable: string | null;
|
|
98
|
-
summary: Record<MigrationInfoStatus, number>;
|
|
99
|
-
items: MigrationInfoItem[];
|
|
16
|
+
strictInference?: boolean;
|
|
100
17
|
};
|
|
101
18
|
export type MigrationArchive = {
|
|
102
19
|
name: string;
|
|
@@ -151,22 +68,6 @@ export type RevertDryRunOutcome = {
|
|
|
151
68
|
error: string;
|
|
152
69
|
};
|
|
153
70
|
export declare function checkMigrationFiles(migrationsDir: string): MigrationCheckReport;
|
|
154
|
-
export declare function planPending(c: PgClient, migrationsDir: string, onEvent?: (e: PlanOutcome) => void): Promise<{
|
|
155
|
-
pending: number;
|
|
156
|
-
adoptable: number;
|
|
157
|
-
tampered: number;
|
|
158
|
-
failed: number;
|
|
159
|
-
steps: MigrationPlanItem[];
|
|
160
|
-
}>;
|
|
161
|
-
export declare function inspectMigrationPlan(c: PgClient, migrationsDir: string): Promise<MigrationPlanSnapshot>;
|
|
162
|
-
export declare function inspectMigrations(c: PgClient, migrationsDir: string): Promise<MigrationInfoSnapshot>;
|
|
163
|
-
export declare function applyPending(c: PgClient, migrationsDir: string, onEvent?: (e: ApplyOutcome) => void): Promise<{
|
|
164
|
-
applied: number;
|
|
165
|
-
tampered: number;
|
|
166
|
-
failed: number;
|
|
167
|
-
}>;
|
|
168
|
-
export declare function acquireMigrateLock(c: PgClient, lockKey?: number | bigint, timeoutMs?: number): Promise<void>;
|
|
169
|
-
export declare function releaseMigrateLock(c: PgClient, lockKey?: number | bigint): Promise<void>;
|
|
170
71
|
export declare function sanitizePgDumpSchema(sql: string): string;
|
|
171
72
|
export declare function listMigrationArchives(migrationsDir: string): MigrationArchive[];
|
|
172
73
|
export declare function restoreMigrationArchive(migrationsDir: string, archiveName: string, opts?: {
|