drizzle-kit 0.22.0-3b0ba5f → 0.22.0-407e2e6
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/bin.cjs +16869 -10261
- package/index.d.mts +9 -1
- package/index.d.ts +9 -1
- package/package.json +2 -1
- package/payload.js +182 -97
- package/payload.mjs +167 -82
- package/utils-studio.js +591 -12
- package/utils-studio.mjs +591 -12
- package/utils.js +29 -1
- package/utils.mjs +28 -1
package/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { SslOptions } from 'mysql2';
|
|
|
2
2
|
import * as zod from 'zod';
|
|
3
3
|
import { TypeOf } from 'zod';
|
|
4
4
|
|
|
5
|
-
declare const driver: zod.ZodUnion<[zod.ZodUnion<[zod.ZodLiteral<"better-sqlite">, zod.ZodLiteral<"turso">, zod.ZodLiteral<"libsql">, zod.ZodLiteral<"d1">, zod.ZodLiteral<"expo">]>, zod.ZodLiteral<"aws-data-api">, zod.ZodLiteral<"mysql2">]>;
|
|
5
|
+
declare const driver: zod.ZodUnion<[zod.ZodUnion<[zod.ZodLiteral<"better-sqlite">, zod.ZodLiteral<"turso">, zod.ZodLiteral<"libsql">, zod.ZodLiteral<"d1">, zod.ZodLiteral<"d1-http">, zod.ZodLiteral<"expo">]>, zod.ZodLiteral<"aws-data-api">, zod.ZodLiteral<"mysql2">]>;
|
|
6
6
|
type Driver = TypeOf<typeof driver>;
|
|
7
7
|
|
|
8
8
|
declare const dialect: zod.ZodEnum<["postgresql", "mysql", "sqlite"]>;
|
|
@@ -169,6 +169,14 @@ type Config = {
|
|
|
169
169
|
wranglerConfigPath: string;
|
|
170
170
|
dbName: string;
|
|
171
171
|
};
|
|
172
|
+
} | {
|
|
173
|
+
dialect: Verify<Dialect, "sqlite">;
|
|
174
|
+
driver: Verify<Driver, "d1-http">;
|
|
175
|
+
dbCredentials: {
|
|
176
|
+
accountId: string;
|
|
177
|
+
databaseId: string;
|
|
178
|
+
token: string;
|
|
179
|
+
};
|
|
172
180
|
} | {
|
|
173
181
|
dialect: Verify<Dialect, "sqlite">;
|
|
174
182
|
driver: Verify<Driver, "expo">;
|
package/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { SslOptions } from 'mysql2';
|
|
|
2
2
|
import * as zod from 'zod';
|
|
3
3
|
import { TypeOf } from 'zod';
|
|
4
4
|
|
|
5
|
-
declare const driver: zod.ZodUnion<[zod.ZodUnion<[zod.ZodLiteral<"better-sqlite">, zod.ZodLiteral<"turso">, zod.ZodLiteral<"libsql">, zod.ZodLiteral<"d1">, zod.ZodLiteral<"expo">]>, zod.ZodLiteral<"aws-data-api">, zod.ZodLiteral<"mysql2">]>;
|
|
5
|
+
declare const driver: zod.ZodUnion<[zod.ZodUnion<[zod.ZodLiteral<"better-sqlite">, zod.ZodLiteral<"turso">, zod.ZodLiteral<"libsql">, zod.ZodLiteral<"d1">, zod.ZodLiteral<"d1-http">, zod.ZodLiteral<"expo">]>, zod.ZodLiteral<"aws-data-api">, zod.ZodLiteral<"mysql2">]>;
|
|
6
6
|
type Driver = TypeOf<typeof driver>;
|
|
7
7
|
|
|
8
8
|
declare const dialect: zod.ZodEnum<["postgresql", "mysql", "sqlite"]>;
|
|
@@ -169,6 +169,14 @@ type Config = {
|
|
|
169
169
|
wranglerConfigPath: string;
|
|
170
170
|
dbName: string;
|
|
171
171
|
};
|
|
172
|
+
} | {
|
|
173
|
+
dialect: Verify<Dialect, "sqlite">;
|
|
174
|
+
driver: Verify<Driver, "d1-http">;
|
|
175
|
+
dbCredentials: {
|
|
176
|
+
accountId: string;
|
|
177
|
+
databaseId: string;
|
|
178
|
+
token: string;
|
|
179
|
+
};
|
|
172
180
|
} | {
|
|
173
181
|
dialect: Verify<Dialect, "sqlite">;
|
|
174
182
|
driver: Verify<Driver, "expo">;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drizzle-kit",
|
|
3
|
-
"version": "0.22.0-
|
|
3
|
+
"version": "0.22.0-407e2e6",
|
|
4
4
|
"repository": "https://github.com/drizzle-team/drizzle-kit-mirror",
|
|
5
5
|
"author": "Drizzle Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"hono": "^4.1.5",
|
|
71
71
|
"minimatch": "^7.4.3",
|
|
72
72
|
"mysql2": "2.3.3",
|
|
73
|
+
"node-fetch": "^3.3.2",
|
|
73
74
|
"pg": "^8.11.3",
|
|
74
75
|
"pluralize": "^8.0.0",
|
|
75
76
|
"postgres": "^3.4.4",
|
package/payload.js
CHANGED
|
@@ -8495,7 +8495,7 @@ var init_utils4 = __esm({
|
|
|
8495
8495
|
});
|
|
8496
8496
|
|
|
8497
8497
|
// src/cli/views.ts
|
|
8498
|
-
var import_hanji, error, isRenamePromptItem, ResolveColumnSelect, tableKey, ResolveSelect, ResolveSchemasSelect;
|
|
8498
|
+
var import_hanji, error, isRenamePromptItem, ResolveColumnSelect, tableKey, ResolveSelect, ResolveSchemasSelect, Spinner, ProgressView;
|
|
8499
8499
|
var init_views = __esm({
|
|
8500
8500
|
"src/cli/views.ts"() {
|
|
8501
8501
|
"use strict";
|
|
@@ -8648,6 +8648,42 @@ Is ${source_default.bold.blue(
|
|
|
8648
8648
|
return this.state.items[this.state.selectedIdx];
|
|
8649
8649
|
}
|
|
8650
8650
|
};
|
|
8651
|
+
Spinner = class {
|
|
8652
|
+
constructor(frames) {
|
|
8653
|
+
this.frames = frames;
|
|
8654
|
+
this.offset = 0;
|
|
8655
|
+
this.tick = () => {
|
|
8656
|
+
this.iterator();
|
|
8657
|
+
};
|
|
8658
|
+
this.value = () => {
|
|
8659
|
+
return this.frames[this.offset];
|
|
8660
|
+
};
|
|
8661
|
+
this.iterator = () => {
|
|
8662
|
+
this.offset += 1;
|
|
8663
|
+
this.offset %= frames.length - 1;
|
|
8664
|
+
};
|
|
8665
|
+
}
|
|
8666
|
+
};
|
|
8667
|
+
ProgressView = class extends import_hanji.TaskView {
|
|
8668
|
+
constructor(progressText, successText) {
|
|
8669
|
+
super();
|
|
8670
|
+
this.progressText = progressText;
|
|
8671
|
+
this.successText = successText;
|
|
8672
|
+
this.spinner = new Spinner("\u28F7\u28EF\u28DF\u287F\u28BF\u28FB\u28FD\u28FE".split(""));
|
|
8673
|
+
this.timeout = setInterval(() => {
|
|
8674
|
+
this.spinner.tick();
|
|
8675
|
+
this.requestLayout();
|
|
8676
|
+
}, 128);
|
|
8677
|
+
this.on("detach", () => clearInterval(this.timeout));
|
|
8678
|
+
}
|
|
8679
|
+
render(status) {
|
|
8680
|
+
if (status === "pending") {
|
|
8681
|
+
const spin = this.spinner.value();
|
|
8682
|
+
return `[${spin}] ${this.progressText}`;
|
|
8683
|
+
}
|
|
8684
|
+
return `[${source_default.green("\u2713")}] ${this.successText}`;
|
|
8685
|
+
}
|
|
8686
|
+
};
|
|
8651
8687
|
}
|
|
8652
8688
|
});
|
|
8653
8689
|
|
|
@@ -8768,6 +8804,12 @@ var init_sqlite = __esm({
|
|
|
8768
8804
|
url: (0, import_zod6.string)(),
|
|
8769
8805
|
authToken: (0, import_zod6.string)()
|
|
8770
8806
|
}),
|
|
8807
|
+
(0, import_zod6.object)({
|
|
8808
|
+
driver: (0, import_zod6.literal)("d1-http"),
|
|
8809
|
+
accountId: (0, import_zod6.string)(),
|
|
8810
|
+
databaseId: (0, import_zod6.string)(),
|
|
8811
|
+
token: (0, import_zod6.string)()
|
|
8812
|
+
}),
|
|
8771
8813
|
(0, import_zod6.object)({
|
|
8772
8814
|
url: (0, import_zod6.string)()
|
|
8773
8815
|
})
|
|
@@ -8811,6 +8853,7 @@ var init_common2 = __esm({
|
|
|
8811
8853
|
(0, import_zod8.literal)("turso"),
|
|
8812
8854
|
(0, import_zod8.literal)("libsql"),
|
|
8813
8855
|
(0, import_zod8.literal)("d1"),
|
|
8856
|
+
(0, import_zod8.literal)("d1-http"),
|
|
8814
8857
|
(0, import_zod8.literal)("expo")
|
|
8815
8858
|
]);
|
|
8816
8859
|
postgresDriver = (0, import_zod8.literal)("aws-data-api");
|
|
@@ -9797,6 +9840,7 @@ ${withStyle.errorWarning(
|
|
|
9797
9840
|
"time without time zone": "::time without time zone",
|
|
9798
9841
|
// "timestamp with time zone": "::timestamp with time zone",
|
|
9799
9842
|
"timestamp without time zone": "::timestamp without time zone",
|
|
9843
|
+
"timestamp(": "::timestamp without time zone",
|
|
9800
9844
|
// date: "::date",
|
|
9801
9845
|
// interval: "::interval",
|
|
9802
9846
|
// character: "::bpchar",
|
|
@@ -9809,15 +9853,15 @@ ${withStyle.errorWarning(
|
|
|
9809
9853
|
"character(": "::bpchar"
|
|
9810
9854
|
};
|
|
9811
9855
|
defaultForColumn = (column4) => {
|
|
9856
|
+
if (column4.column_default === null) {
|
|
9857
|
+
return void 0;
|
|
9858
|
+
}
|
|
9812
9859
|
if (column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
|
|
9813
9860
|
return void 0;
|
|
9814
9861
|
}
|
|
9815
9862
|
const hasDifferentDefaultCast = Object.keys(columnToDefault).find(
|
|
9816
9863
|
(it) => column4.data_type.startsWith(it)
|
|
9817
9864
|
);
|
|
9818
|
-
if (column4.column_default === null) {
|
|
9819
|
-
return void 0;
|
|
9820
|
-
}
|
|
9821
9865
|
const columnDefaultAsString = column4.column_default.toString();
|
|
9822
9866
|
if (columnDefaultAsString.endsWith(
|
|
9823
9867
|
hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : column4.data_type
|
|
@@ -11299,8 +11343,7 @@ var init_jsonDiffer = __esm({
|
|
|
11299
11343
|
};
|
|
11300
11344
|
findAlternationsInTable = (table4) => {
|
|
11301
11345
|
const columns = table4.columns ?? {};
|
|
11302
|
-
const
|
|
11303
|
-
const altered = Object.keys(columns).filter((it) => !(it.includes("__deleted") || it.includes("__added") || isSemanticallyEqual(it))).map((it) => {
|
|
11346
|
+
const altered = Object.keys(columns).filter((it) => !(it.includes("__deleted") || it.includes("__added"))).map((it) => {
|
|
11304
11347
|
return { name: it, ...columns[it] };
|
|
11305
11348
|
});
|
|
11306
11349
|
const deletedIndexes = Object.fromEntries(
|
|
@@ -11402,6 +11445,9 @@ var init_jsonDiffer = __esm({
|
|
|
11402
11445
|
return it;
|
|
11403
11446
|
}).map((it) => {
|
|
11404
11447
|
if ("type" in it) {
|
|
11448
|
+
if (it.type.__old.replace(" (", "(") === it.type.__new.replace(" (", "(")) {
|
|
11449
|
+
return void 0;
|
|
11450
|
+
}
|
|
11405
11451
|
return {
|
|
11406
11452
|
...it,
|
|
11407
11453
|
type: { type: "changed", old: it.type.__old, new: it.type.__new }
|
|
@@ -11564,7 +11610,7 @@ var init_jsonDiffer = __esm({
|
|
|
11564
11610
|
};
|
|
11565
11611
|
}
|
|
11566
11612
|
return it;
|
|
11567
|
-
});
|
|
11613
|
+
}).filter(Boolean);
|
|
11568
11614
|
return result[0];
|
|
11569
11615
|
};
|
|
11570
11616
|
}
|
|
@@ -12386,20 +12432,21 @@ var init_jsonStatements = __esm({
|
|
|
12386
12432
|
});
|
|
12387
12433
|
};
|
|
12388
12434
|
prepareAlterReferencesJson = (tableName, schema4, foreignKeys) => {
|
|
12389
|
-
const keys = Object.keys(foreignKeys);
|
|
12390
12435
|
const stmts = [];
|
|
12391
|
-
|
|
12392
|
-
stmts.push(
|
|
12393
|
-
|
|
12394
|
-
|
|
12395
|
-
|
|
12396
|
-
|
|
12397
|
-
|
|
12398
|
-
|
|
12399
|
-
|
|
12400
|
-
|
|
12401
|
-
|
|
12402
|
-
|
|
12436
|
+
Object.values(foreignKeys).map((val) => {
|
|
12437
|
+
stmts.push({
|
|
12438
|
+
type: "delete_reference",
|
|
12439
|
+
tableName,
|
|
12440
|
+
schema: schema4,
|
|
12441
|
+
data: val.__old
|
|
12442
|
+
});
|
|
12443
|
+
stmts.push({
|
|
12444
|
+
type: "create_reference",
|
|
12445
|
+
tableName,
|
|
12446
|
+
schema: schema4,
|
|
12447
|
+
data: val.__new
|
|
12448
|
+
});
|
|
12449
|
+
});
|
|
12403
12450
|
return stmts;
|
|
12404
12451
|
};
|
|
12405
12452
|
prepareDropIndexesJson = (tableName, schema4, indexes) => {
|
|
@@ -12448,7 +12495,7 @@ var init_jsonStatements = __esm({
|
|
|
12448
12495
|
tableName,
|
|
12449
12496
|
data: it,
|
|
12450
12497
|
schema: schema4,
|
|
12451
|
-
constraintName: json2.tables[`${schema4}.${tableName}`].compositePrimaryKeys[unsquashed.name].name
|
|
12498
|
+
constraintName: json2.tables[`${schema4 || "public"}.${tableName}`].compositePrimaryKeys[unsquashed.name].name
|
|
12452
12499
|
};
|
|
12453
12500
|
});
|
|
12454
12501
|
};
|
|
@@ -12471,8 +12518,8 @@ var init_jsonStatements = __esm({
|
|
|
12471
12518
|
old: it.__old,
|
|
12472
12519
|
new: it.__new,
|
|
12473
12520
|
schema: schema4,
|
|
12474
|
-
oldConstraintName: json1.tables[`${schema4}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it.__old).name].name,
|
|
12475
|
-
newConstraintName: json2.tables[`${schema4}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it.__new).name].name
|
|
12521
|
+
oldConstraintName: json1.tables[`${schema4 || "public"}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it.__old).name].name,
|
|
12522
|
+
newConstraintName: json2.tables[`${schema4 || "public"}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it.__new).name].name
|
|
12476
12523
|
};
|
|
12477
12524
|
});
|
|
12478
12525
|
};
|
|
@@ -12742,7 +12789,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
12742
12789
|
for (let ren of renamedTables) {
|
|
12743
12790
|
if (table4.name === ren.from.name && table4.schema === ren.from.schema) {
|
|
12744
12791
|
return {
|
|
12745
|
-
key: `${ren.to.schema}.${ren.to.name}`,
|
|
12792
|
+
key: `${ren.to.schema || "public"}.${ren.to.name}`,
|
|
12746
12793
|
name: ren.to.name,
|
|
12747
12794
|
schema: ren.to.schema
|
|
12748
12795
|
};
|
|
@@ -13779,13 +13826,13 @@ var init_words = __esm({
|
|
|
13779
13826
|
});
|
|
13780
13827
|
|
|
13781
13828
|
// src/cli/commands/migrate.ts
|
|
13782
|
-
var
|
|
13829
|
+
var import_hanji4, schemasResolver, tablesResolver, enumsResolver, columnsResolver, promptColumnsConflicts, promptNamedWithSchemasConflict, promptSchemasConflict, BREAKPOINT;
|
|
13783
13830
|
var init_migrate = __esm({
|
|
13784
13831
|
"src/cli/commands/migrate.ts"() {
|
|
13785
13832
|
"use strict";
|
|
13786
13833
|
init_migrationPreparator();
|
|
13787
13834
|
init_snapshotsDiffer();
|
|
13788
|
-
|
|
13835
|
+
import_hanji4 = require("hanji");
|
|
13789
13836
|
init_views();
|
|
13790
13837
|
init_source();
|
|
13791
13838
|
init_pgSchema();
|
|
@@ -13869,7 +13916,7 @@ var init_migrate = __esm({
|
|
|
13869
13916
|
return { from: it, to: created };
|
|
13870
13917
|
});
|
|
13871
13918
|
const promptData = [created, ...renames];
|
|
13872
|
-
const { status, data } = await (0,
|
|
13919
|
+
const { status, data } = await (0, import_hanji4.render)(
|
|
13873
13920
|
new ResolveColumnSelect(tableName, created, promptData)
|
|
13874
13921
|
);
|
|
13875
13922
|
if (status === "aborted") {
|
|
@@ -13920,7 +13967,7 @@ var init_migrate = __esm({
|
|
|
13920
13967
|
return { from: it, to: created };
|
|
13921
13968
|
});
|
|
13922
13969
|
const promptData = [created, ...renames];
|
|
13923
|
-
const { status, data } = await (0,
|
|
13970
|
+
const { status, data } = await (0, import_hanji4.render)(
|
|
13924
13971
|
new ResolveSelect(created, promptData, entity)
|
|
13925
13972
|
);
|
|
13926
13973
|
if (status === "aborted") {
|
|
@@ -13975,7 +14022,7 @@ var init_migrate = __esm({
|
|
|
13975
14022
|
return { from: it, to: created };
|
|
13976
14023
|
});
|
|
13977
14024
|
const promptData = [created, ...renames];
|
|
13978
|
-
const { status, data } = await (0,
|
|
14025
|
+
const { status, data } = await (0, import_hanji4.render)(
|
|
13979
14026
|
new ResolveSchemasSelect(created, promptData)
|
|
13980
14027
|
);
|
|
13981
14028
|
if (status === "aborted") {
|
|
@@ -14114,8 +14161,7 @@ var init_sqlgenerator = __esm({
|
|
|
14114
14161
|
convert(st) {
|
|
14115
14162
|
const { tableName, columns, schema: schema4, compositePKs, uniqueConstraints } = st;
|
|
14116
14163
|
let statement = "";
|
|
14117
|
-
|
|
14118
|
-
statement += `CREATE TABLE ${tName} (
|
|
14164
|
+
statement += `CREATE TABLE \`${tableName}\` (
|
|
14119
14165
|
`;
|
|
14120
14166
|
for (let i = 0; i < columns.length; i++) {
|
|
14121
14167
|
const column4 = columns[i];
|
|
@@ -14235,8 +14281,7 @@ var init_sqlgenerator = __esm({
|
|
|
14235
14281
|
}
|
|
14236
14282
|
convert(statement) {
|
|
14237
14283
|
const unsquashed = MySqlSquasher.unsquashUnique(statement.data);
|
|
14238
|
-
|
|
14239
|
-
return `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT \`${unsquashed.name}\` UNIQUE(\`${unsquashed.columns.join("`,`")}\`);`;
|
|
14284
|
+
return `ALTER TABLE \`${statement.tableName}\` ADD CONSTRAINT \`${unsquashed.name}\` UNIQUE(\`${unsquashed.columns.join("`,`")}\`);`;
|
|
14240
14285
|
}
|
|
14241
14286
|
};
|
|
14242
14287
|
MySQLAlterTableDropUniqueConstraintConvertor = class extends Convertor {
|
|
@@ -14245,8 +14290,7 @@ var init_sqlgenerator = __esm({
|
|
|
14245
14290
|
}
|
|
14246
14291
|
convert(statement) {
|
|
14247
14292
|
const unsquashed = MySqlSquasher.unsquashUnique(statement.data);
|
|
14248
|
-
|
|
14249
|
-
return `ALTER TABLE ${tableNameWithSchema} DROP INDEX \`${unsquashed.name}\`;`;
|
|
14293
|
+
return `ALTER TABLE \`${statement.tableName}\` DROP INDEX \`${unsquashed.name}\`;`;
|
|
14250
14294
|
}
|
|
14251
14295
|
};
|
|
14252
14296
|
SQLiteAlterTableAddUniqueConstraintConvertor = class extends Convertor {
|
|
@@ -14361,10 +14405,8 @@ var init_sqlgenerator = __esm({
|
|
|
14361
14405
|
return statement.type === "rename_table" && dialect7 === "mysql";
|
|
14362
14406
|
}
|
|
14363
14407
|
convert(statement) {
|
|
14364
|
-
const { tableNameFrom, tableNameTo
|
|
14365
|
-
|
|
14366
|
-
const to = fromSchema ? `\`${fromSchema}\`.\`${tableNameTo}\`` : `\`${tableNameTo}\``;
|
|
14367
|
-
return `RENAME TABLE ${from} TO ${to};`;
|
|
14408
|
+
const { tableNameFrom, tableNameTo } = statement;
|
|
14409
|
+
return `RENAME TABLE \`${tableNameFrom}\` TO \`${tableNameTo}\`;`;
|
|
14368
14410
|
}
|
|
14369
14411
|
};
|
|
14370
14412
|
PgAlterTableRenameColumnConvertor = class extends Convertor {
|
|
@@ -15172,9 +15214,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
15172
15214
|
return statement.type === "drop_index" && dialect7 === "mysql";
|
|
15173
15215
|
}
|
|
15174
15216
|
convert(statement) {
|
|
15175
|
-
const tableName = typeof statement.schema === "undefined" ? `\`${statement.tableName}\`` : `\`${statement.schema}\`.\`${statement.tableName}\``;
|
|
15176
15217
|
const { name: name2 } = MySqlSquasher.unsquashIdx(statement.data);
|
|
15177
|
-
return `DROP INDEX \`${name2}\` ON
|
|
15218
|
+
return `DROP INDEX \`${name2}\` ON \`${statement.tableName}\`;`;
|
|
15178
15219
|
}
|
|
15179
15220
|
};
|
|
15180
15221
|
convertors = [];
|
|
@@ -15291,18 +15332,18 @@ drop type __venum;
|
|
|
15291
15332
|
});
|
|
15292
15333
|
|
|
15293
15334
|
// src/cli/selector-ui.ts
|
|
15294
|
-
var
|
|
15335
|
+
var import_hanji5, Select;
|
|
15295
15336
|
var init_selector_ui = __esm({
|
|
15296
15337
|
"src/cli/selector-ui.ts"() {
|
|
15297
15338
|
"use strict";
|
|
15298
15339
|
init_source();
|
|
15299
|
-
|
|
15300
|
-
Select = class extends
|
|
15340
|
+
import_hanji5 = require("hanji");
|
|
15341
|
+
Select = class extends import_hanji5.Prompt {
|
|
15301
15342
|
constructor(items) {
|
|
15302
15343
|
super();
|
|
15303
15344
|
this.on("attach", (terminal) => terminal.toggleCursor("hide"));
|
|
15304
15345
|
this.on("detach", (terminal) => terminal.toggleCursor("show"));
|
|
15305
|
-
this.data = new
|
|
15346
|
+
this.data = new import_hanji5.SelectState(
|
|
15306
15347
|
items.map((it) => ({ label: it, value: `${it}-value` }))
|
|
15307
15348
|
);
|
|
15308
15349
|
this.data.bind(this);
|
|
@@ -18829,12 +18870,24 @@ The unique constraint ${source_default.underline.blue(
|
|
|
18829
18870
|
`SELECT
|
|
18830
18871
|
m.name as "tableName", p.name as "columnName", p.type as "columnType", p."notnull" as "notNull", p.dflt_value as "defaultValue", p.pk as pk
|
|
18831
18872
|
FROM sqlite_master AS m JOIN pragma_table_info(m.name) AS p
|
|
18832
|
-
WHERE m.type = 'table'
|
|
18873
|
+
WHERE m.type = 'table'
|
|
18874
|
+
and m.tbl_name != 'sqlite_sequence'
|
|
18875
|
+
and m.tbl_name != 'sqlite_stat1'
|
|
18876
|
+
and m.tbl_name != '_litestream_seq'
|
|
18877
|
+
and m.tbl_name != '_litestream_lock'
|
|
18878
|
+
and m.tbl_name != 'libsql_wasm_func_table'
|
|
18879
|
+
and m.tbl_name != '__drizzle_migrations'
|
|
18880
|
+
and m.tbl_name != '_cf_KV';
|
|
18833
18881
|
`
|
|
18834
18882
|
);
|
|
18835
18883
|
const tablesWithSeq = [];
|
|
18836
18884
|
const seq = await db.query(
|
|
18837
|
-
`SELECT * FROM sqlite_master WHERE name != 'sqlite_sequence'
|
|
18885
|
+
`SELECT * FROM sqlite_master WHERE name != 'sqlite_sequence'
|
|
18886
|
+
and name != 'sqlite_stat1'
|
|
18887
|
+
and name != '_litestream_seq'
|
|
18888
|
+
and name != '_litestream_lock'
|
|
18889
|
+
and tbl_name != '_cf_KV'
|
|
18890
|
+
and sql GLOB '*[ *' || CHAR(9) || CHAR(10) || CHAR(13) || ']AUTOINCREMENT[^'']*';`
|
|
18838
18891
|
);
|
|
18839
18892
|
for (const s of seq) {
|
|
18840
18893
|
tablesWithSeq.push(s.name);
|
|
@@ -18919,7 +18972,8 @@ The unique constraint ${source_default.underline.blue(
|
|
|
18919
18972
|
try {
|
|
18920
18973
|
const fks = await db.query(
|
|
18921
18974
|
`SELECT m.name as "tableFrom", f.id as "id", f."table" as "tableTo", f."from", f."to", f."on_update" as "onUpdate", f."on_delete" as "onDelete", f.seq as "seq"
|
|
18922
|
-
FROM sqlite_master m, pragma_foreign_key_list(m.name) as f
|
|
18975
|
+
FROM sqlite_master m, pragma_foreign_key_list(m.name) as f
|
|
18976
|
+
where m.tbl_name != '_cf_KV';`
|
|
18923
18977
|
);
|
|
18924
18978
|
const fkByTableName = {};
|
|
18925
18979
|
for (const fkRow of fks) {
|
|
@@ -18978,7 +19032,9 @@ FROM sqlite_master AS m,
|
|
|
18978
19032
|
pragma_index_list(m.name) AS il,
|
|
18979
19033
|
pragma_index_info(il.name) AS ii
|
|
18980
19034
|
WHERE
|
|
18981
|
-
m.type = 'table'
|
|
19035
|
+
m.type = 'table'
|
|
19036
|
+
and il.name NOT LIKE 'sqlite_autoindex_%'
|
|
19037
|
+
and m.tbl_name != '_cf_KV';`
|
|
18982
19038
|
);
|
|
18983
19039
|
for (const idxRow of idxs) {
|
|
18984
19040
|
const tableName = idxRow.tableName;
|
|
@@ -23636,12 +23692,12 @@ __export(mysqlPushUtils_exports, {
|
|
|
23636
23692
|
filterStatements: () => filterStatements,
|
|
23637
23693
|
logSuggestionsAndReturn: () => logSuggestionsAndReturn2
|
|
23638
23694
|
});
|
|
23639
|
-
var
|
|
23695
|
+
var import_hanji8, filterStatements, logSuggestionsAndReturn2;
|
|
23640
23696
|
var init_mysqlPushUtils = __esm({
|
|
23641
23697
|
"src/cli/commands/mysqlPushUtils.ts"() {
|
|
23642
23698
|
"use strict";
|
|
23643
23699
|
init_source();
|
|
23644
|
-
|
|
23700
|
+
import_hanji8 = require("hanji");
|
|
23645
23701
|
init_mysqlSchema();
|
|
23646
23702
|
init_selector_ui();
|
|
23647
23703
|
init_outputs();
|
|
@@ -23855,7 +23911,7 @@ var init_mysqlPushUtils = __esm({
|
|
|
23855
23911
|
)} table?
|
|
23856
23912
|
`
|
|
23857
23913
|
);
|
|
23858
|
-
const { status, data } = await (0,
|
|
23914
|
+
const { status, data } = await (0, import_hanji8.render)(
|
|
23859
23915
|
new Select([
|
|
23860
23916
|
"No, add the constraint without truncating the table",
|
|
23861
23917
|
`Yes, truncate the table`
|
|
@@ -23887,13 +23943,15 @@ var mysqlIntrospect_exports = {};
|
|
|
23887
23943
|
__export(mysqlIntrospect_exports, {
|
|
23888
23944
|
mysqlPushIntrospect: () => mysqlPushIntrospect
|
|
23889
23945
|
});
|
|
23890
|
-
var mysqlPushIntrospect;
|
|
23946
|
+
var import_hanji9, mysqlPushIntrospect;
|
|
23891
23947
|
var init_mysqlIntrospect = __esm({
|
|
23892
23948
|
"src/cli/commands/mysqlIntrospect.ts"() {
|
|
23893
23949
|
"use strict";
|
|
23894
23950
|
init_mysqlSerializer();
|
|
23895
23951
|
init_global();
|
|
23896
23952
|
init_mjs();
|
|
23953
|
+
init_views();
|
|
23954
|
+
import_hanji9 = require("hanji");
|
|
23897
23955
|
mysqlPushIntrospect = async (db, databaseName, filters) => {
|
|
23898
23956
|
const matchers = filters.map((it) => {
|
|
23899
23957
|
return new Minimatch(it);
|
|
@@ -23908,7 +23966,14 @@ var init_mysqlIntrospect = __esm({
|
|
|
23908
23966
|
}
|
|
23909
23967
|
return false;
|
|
23910
23968
|
};
|
|
23911
|
-
const
|
|
23969
|
+
const progress = new ProgressView(
|
|
23970
|
+
"Pulling schema from database...",
|
|
23971
|
+
"Pulling schema from database..."
|
|
23972
|
+
);
|
|
23973
|
+
const res = await (0, import_hanji9.renderWithTask)(
|
|
23974
|
+
progress,
|
|
23975
|
+
fromDatabase3(db, databaseName, filter2)
|
|
23976
|
+
);
|
|
23912
23977
|
const schema4 = { id: originUUID, prevId: "", ...res };
|
|
23913
23978
|
const { internal, ...schemaWithoutInternals } = schema4;
|
|
23914
23979
|
return { schema: schemaWithoutInternals };
|
|
@@ -23943,6 +24008,8 @@ init_mysqlSchema();
|
|
|
23943
24008
|
init_pgSerializer();
|
|
23944
24009
|
init_global();
|
|
23945
24010
|
init_mjs();
|
|
24011
|
+
init_views();
|
|
24012
|
+
var import_hanji3 = require("hanji");
|
|
23946
24013
|
var pgPushIntrospect = async (db, filters, schemaFilters) => {
|
|
23947
24014
|
const matchers = filters.map((it) => {
|
|
23948
24015
|
return new Minimatch(it);
|
|
@@ -23957,7 +24024,14 @@ var pgPushIntrospect = async (db, filters, schemaFilters) => {
|
|
|
23957
24024
|
}
|
|
23958
24025
|
return false;
|
|
23959
24026
|
};
|
|
23960
|
-
const
|
|
24027
|
+
const progress = new ProgressView(
|
|
24028
|
+
"Pulling schema from database...",
|
|
24029
|
+
"Pulling schema from database..."
|
|
24030
|
+
);
|
|
24031
|
+
const res = await (0, import_hanji3.renderWithTask)(
|
|
24032
|
+
progress,
|
|
24033
|
+
fromDatabase(db, filter2, schemaFilters)
|
|
24034
|
+
);
|
|
23961
24035
|
const schema4 = { id: originUUID, prevId: "", ...res };
|
|
23962
24036
|
const { internal, ...schemaWithoutInternals } = schema4;
|
|
23963
24037
|
return { schema: schemaWithoutInternals };
|
|
@@ -23965,7 +24039,7 @@ var pgPushIntrospect = async (db, filters, schemaFilters) => {
|
|
|
23965
24039
|
|
|
23966
24040
|
// src/cli/commands/pgPushUtils.ts
|
|
23967
24041
|
init_source();
|
|
23968
|
-
var
|
|
24042
|
+
var import_hanji6 = require("hanji");
|
|
23969
24043
|
init_pgSchema();
|
|
23970
24044
|
init_sqlgenerator();
|
|
23971
24045
|
init_selector_ui();
|
|
@@ -24215,7 +24289,7 @@ var pgSuggestions = async (db, statements) => {
|
|
|
24215
24289
|
)} table?
|
|
24216
24290
|
`
|
|
24217
24291
|
);
|
|
24218
|
-
const { status, data } = await (0,
|
|
24292
|
+
const { status, data } = await (0, import_hanji6.render)(
|
|
24219
24293
|
new Select([
|
|
24220
24294
|
"No, add the constraint without truncating the table",
|
|
24221
24295
|
`Yes, truncate the table`
|
|
@@ -24375,7 +24449,7 @@ Array.prototype.random = function() {
|
|
|
24375
24449
|
|
|
24376
24450
|
// src/cli/commands/sqliteIntrospect.ts
|
|
24377
24451
|
init_mjs();
|
|
24378
|
-
var
|
|
24452
|
+
var import_hanji7 = require("hanji");
|
|
24379
24453
|
var sqlitePushIntrospect = async (db, filters) => {
|
|
24380
24454
|
const matchers = filters.map((it) => {
|
|
24381
24455
|
return new Minimatch(it);
|
|
@@ -24390,7 +24464,14 @@ var sqlitePushIntrospect = async (db, filters) => {
|
|
|
24390
24464
|
}
|
|
24391
24465
|
return false;
|
|
24392
24466
|
};
|
|
24393
|
-
const
|
|
24467
|
+
const progress = new ProgressView(
|
|
24468
|
+
"Pulling schema from database...",
|
|
24469
|
+
"Pulling schema from database..."
|
|
24470
|
+
);
|
|
24471
|
+
const res = await (0, import_hanji7.renderWithTask)(
|
|
24472
|
+
progress,
|
|
24473
|
+
fromDatabase2(db, filter2)
|
|
24474
|
+
);
|
|
24394
24475
|
const schema4 = { id: originUUID, prevId: "", ...res };
|
|
24395
24476
|
return { schema: schema4 };
|
|
24396
24477
|
};
|
|
@@ -24507,7 +24588,7 @@ var logSuggestionsAndReturn = async (connection, statements, json1, json2, meta)
|
|
|
24507
24588
|
).find(
|
|
24508
24589
|
(c) => SQLiteSquasher.unsquashIdx(c).columns.includes(statement.columnName)
|
|
24509
24590
|
);
|
|
24510
|
-
const columnIsPk =
|
|
24591
|
+
const columnIsPk = json2.tables[newTableName].columns[statement.columnName].primaryKey;
|
|
24511
24592
|
const columnIsPartOfFk = Object.values(
|
|
24512
24593
|
json1.tables[newTableName].foreignKeys
|
|
24513
24594
|
).find(
|
|
@@ -24591,48 +24672,52 @@ var logSuggestionsAndReturn = async (connection, statements, json1, json2, meta)
|
|
|
24591
24672
|
}
|
|
24592
24673
|
}
|
|
24593
24674
|
} else if (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_pk" || statement.type === "alter_table_alter_column_set_pk") {
|
|
24594
|
-
|
|
24595
|
-
|
|
24596
|
-
|
|
24597
|
-
|
|
24598
|
-
|
|
24599
|
-
const count2 = Number(res[0].count);
|
|
24600
|
-
if (count2 > 0) {
|
|
24601
|
-
infoToPrint.push(
|
|
24602
|
-
`\xB7 You're about to add not-null constraint to ${source_default.underline(
|
|
24603
|
-
statement.columnName
|
|
24604
|
-
)} column without default value, which contains ${count2} items`
|
|
24675
|
+
if (!(statement.type === "alter_table_alter_column_set_notnull" && statement.columnPk)) {
|
|
24676
|
+
const newTableName = getOldTableName(statement.tableName, meta);
|
|
24677
|
+
if (statement.type === "alter_table_alter_column_set_notnull" && typeof statement.columnDefault === "undefined") {
|
|
24678
|
+
const res = await connection.query(
|
|
24679
|
+
`select count(*) as count from \`${newTableName}\``
|
|
24605
24680
|
);
|
|
24606
|
-
|
|
24607
|
-
|
|
24608
|
-
|
|
24609
|
-
|
|
24610
|
-
|
|
24611
|
-
|
|
24612
|
-
|
|
24613
|
-
|
|
24614
|
-
|
|
24615
|
-
|
|
24681
|
+
const count2 = Number(res[0].count);
|
|
24682
|
+
if (count2 > 0) {
|
|
24683
|
+
infoToPrint.push(
|
|
24684
|
+
`\xB7 You're about to add not-null constraint to ${source_default.underline(
|
|
24685
|
+
statement.columnName
|
|
24686
|
+
)} column without default value, which contains ${count2} items`
|
|
24687
|
+
);
|
|
24688
|
+
tablesToTruncate.push(newTableName);
|
|
24689
|
+
shouldAskForApprove = true;
|
|
24690
|
+
}
|
|
24616
24691
|
tablesContext[newTableName] = _moveDataStatements(
|
|
24617
24692
|
statement.tableName,
|
|
24618
|
-
json2
|
|
24693
|
+
json2,
|
|
24694
|
+
true
|
|
24619
24695
|
);
|
|
24696
|
+
} else {
|
|
24697
|
+
if (typeof tablesContext[newTableName] === "undefined") {
|
|
24698
|
+
tablesContext[newTableName] = _moveDataStatements(
|
|
24699
|
+
statement.tableName,
|
|
24700
|
+
json2
|
|
24701
|
+
);
|
|
24702
|
+
}
|
|
24620
24703
|
}
|
|
24621
|
-
|
|
24622
|
-
|
|
24623
|
-
|
|
24624
|
-
|
|
24625
|
-
|
|
24626
|
-
|
|
24627
|
-
|
|
24628
|
-
|
|
24629
|
-
|
|
24630
|
-
|
|
24631
|
-
|
|
24632
|
-
|
|
24633
|
-
|
|
24634
|
-
|
|
24635
|
-
tablesContext[table4]
|
|
24704
|
+
const tablesReferncingCurrent = [];
|
|
24705
|
+
for (const table4 of Object.values(json1.tables)) {
|
|
24706
|
+
const tablesRefs = Object.values(json1.tables[table4.name].foreignKeys).filter(
|
|
24707
|
+
(t) => SQLiteSquasher.unsquashFK(t).tableTo === newTableName
|
|
24708
|
+
).map((t) => {
|
|
24709
|
+
return getNewTableName(
|
|
24710
|
+
SQLiteSquasher.unsquashFK(t).tableFrom,
|
|
24711
|
+
meta
|
|
24712
|
+
);
|
|
24713
|
+
});
|
|
24714
|
+
tablesReferncingCurrent.push(...tablesRefs);
|
|
24715
|
+
}
|
|
24716
|
+
const uniqueTableRefs = [...new Set(tablesReferncingCurrent)];
|
|
24717
|
+
for (const table4 of uniqueTableRefs) {
|
|
24718
|
+
if (typeof tablesContext[table4] === "undefined") {
|
|
24719
|
+
tablesContext[table4] = [..._moveDataStatements(table4, json2)];
|
|
24720
|
+
}
|
|
24636
24721
|
}
|
|
24637
24722
|
}
|
|
24638
24723
|
} else if (statement.type === "create_reference" || statement.type === "delete_reference" || statement.type === "alter_reference") {
|