drizzle-kit 0.19.0-07024c4 → 0.19.0-9770e22
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/index.cjs +69 -20
- package/package.json +2 -2
- package/utils.js +4 -4
package/index.cjs
CHANGED
|
@@ -6127,22 +6127,23 @@ var init_pgSerializer = __esm({
|
|
|
6127
6127
|
--end;
|
|
6128
6128
|
return start > 0 || end < str.length ? str.substring(start, end) : str.toString();
|
|
6129
6129
|
};
|
|
6130
|
-
fromDatabase2 = async (db, progressCallback) => {
|
|
6130
|
+
fromDatabase2 = async (db, tablesFilter = (table4) => true, progressCallback) => {
|
|
6131
6131
|
const result = {};
|
|
6132
6132
|
const allTables = await db.query(
|
|
6133
6133
|
`SELECT table_schema, table_name FROM information_schema.tables WHERE table_schema = 'public';`
|
|
6134
6134
|
);
|
|
6135
6135
|
const schemas = new Set(allTables.rows.map((it) => it.table_schema));
|
|
6136
6136
|
schemas.delete("public");
|
|
6137
|
-
if (progressCallback) {
|
|
6138
|
-
progressCallback("tables", allTables.rows.length, "done");
|
|
6139
|
-
}
|
|
6140
6137
|
let columnsCount = 0;
|
|
6141
6138
|
let indexesCount = 0;
|
|
6142
6139
|
let foreignKeysCount = 0;
|
|
6140
|
+
let tableCount = 0;
|
|
6143
6141
|
const all = allTables.rows.map((row) => {
|
|
6144
6142
|
return new Promise(async (res, rej) => {
|
|
6145
6143
|
const tableName = row.table_name;
|
|
6144
|
+
if (!tablesFilter(tableName))
|
|
6145
|
+
return res("");
|
|
6146
|
+
tableCount += 1;
|
|
6146
6147
|
const tableSchema = row.table_schema;
|
|
6147
6148
|
try {
|
|
6148
6149
|
const columnToReturn = {};
|
|
@@ -6350,6 +6351,9 @@ var init_pgSerializer = __esm({
|
|
|
6350
6351
|
res("");
|
|
6351
6352
|
});
|
|
6352
6353
|
});
|
|
6354
|
+
if (progressCallback) {
|
|
6355
|
+
progressCallback("tables", tableCount, "done");
|
|
6356
|
+
}
|
|
6353
6357
|
for await (const _ of all) {
|
|
6354
6358
|
}
|
|
6355
6359
|
if (progressCallback) {
|
|
@@ -7821,7 +7825,7 @@ var init_words = __esm({
|
|
|
7821
7825
|
"mesmero",
|
|
7822
7826
|
"metal_master",
|
|
7823
7827
|
"meteorite",
|
|
7824
|
-
"
|
|
7828
|
+
"micromacro",
|
|
7825
7829
|
"microbe",
|
|
7826
7830
|
"microchip",
|
|
7827
7831
|
"micromax",
|
|
@@ -8822,7 +8826,7 @@ var init_sqlgenerator = __esm({
|
|
|
8822
8826
|
const primaryKeyStatement = column7.primaryKey ? "PRIMARY KEY" : "";
|
|
8823
8827
|
const notNullStatement = column7.notNull ? "NOT NULL" : "";
|
|
8824
8828
|
const defaultStatement = column7.default !== void 0 ? `DEFAULT ${column7.default}` : "";
|
|
8825
|
-
const type = isPgNativeType(column7.type) ? column7.type :
|
|
8829
|
+
const type = isPgNativeType(column7.type) ? column7.type : `"${column7.type}"`;
|
|
8826
8830
|
statement += " " + `"${column7.name}" ${type} ${primaryKeyStatement} ${defaultStatement} ${notNullStatement}`.replace(/ +/g, " ").trim();
|
|
8827
8831
|
statement += (i === columns.length - 1 ? "" : ",") + "\n";
|
|
8828
8832
|
}
|
|
@@ -8986,9 +8990,9 @@ var init_sqlgenerator = __esm({
|
|
|
8986
8990
|
return statement.type === "rename_table" && dialect6 === "pg";
|
|
8987
8991
|
}
|
|
8988
8992
|
convert(statement) {
|
|
8989
|
-
const { tableNameFrom, tableNameTo, toSchema
|
|
8990
|
-
const from =
|
|
8991
|
-
const to =
|
|
8993
|
+
const { tableNameFrom, tableNameTo, toSchema, fromSchema } = statement;
|
|
8994
|
+
const from = fromSchema ? `"${fromSchema}"."${tableNameFrom}"` : `"${tableNameFrom}"`;
|
|
8995
|
+
const to = `"${tableNameTo}"`;
|
|
8992
8996
|
return `ALTER TABLE ${from} RENAME TO ${to};`;
|
|
8993
8997
|
}
|
|
8994
8998
|
};
|
|
@@ -30585,15 +30589,28 @@ var init_mysqlIntrospect = __esm({
|
|
|
30585
30589
|
await client.connect();
|
|
30586
30590
|
return { client, databaseName };
|
|
30587
30591
|
};
|
|
30588
|
-
mysqlIntrospect = async (config) => {
|
|
30592
|
+
mysqlIntrospect = async (config, filters) => {
|
|
30589
30593
|
const { client, databaseName } = await connectToMySQL(config);
|
|
30594
|
+
const matchers = filters.map((it) => {
|
|
30595
|
+
return new Minimatch(it);
|
|
30596
|
+
});
|
|
30597
|
+
const filter2 = (tableName) => {
|
|
30598
|
+
if (matchers.length === 0)
|
|
30599
|
+
return true;
|
|
30600
|
+
for (let i = 0; i < matchers.length; i++) {
|
|
30601
|
+
const matcher = matchers[i];
|
|
30602
|
+
if (matcher.match(tableName))
|
|
30603
|
+
return true;
|
|
30604
|
+
}
|
|
30605
|
+
return false;
|
|
30606
|
+
};
|
|
30590
30607
|
const progress = new IntrospectProgress();
|
|
30591
30608
|
const res = await (0, import_hanji5.renderWithTask)(
|
|
30592
30609
|
progress,
|
|
30593
30610
|
fromDatabase(
|
|
30594
30611
|
client,
|
|
30595
30612
|
databaseName,
|
|
30596
|
-
|
|
30613
|
+
filter2,
|
|
30597
30614
|
(stage, count, status) => {
|
|
30598
30615
|
progress.update(stage, count, status);
|
|
30599
30616
|
}
|
|
@@ -39489,14 +39506,27 @@ var init_sqliteIntrospect = __esm({
|
|
|
39489
39506
|
}
|
|
39490
39507
|
return {};
|
|
39491
39508
|
};
|
|
39492
|
-
sqliteIntrospect = async (config) => {
|
|
39509
|
+
sqliteIntrospect = async (config, filters) => {
|
|
39493
39510
|
const { client } = await connectToSQLite(config);
|
|
39511
|
+
const matchers = filters.map((it) => {
|
|
39512
|
+
return new Minimatch(it);
|
|
39513
|
+
});
|
|
39514
|
+
const filter2 = (tableName) => {
|
|
39515
|
+
if (matchers.length === 0)
|
|
39516
|
+
return true;
|
|
39517
|
+
for (let i = 0; i < matchers.length; i++) {
|
|
39518
|
+
const matcher = matchers[i];
|
|
39519
|
+
if (matcher.match(tableName))
|
|
39520
|
+
return true;
|
|
39521
|
+
}
|
|
39522
|
+
return false;
|
|
39523
|
+
};
|
|
39494
39524
|
const progress = new IntrospectProgress();
|
|
39495
39525
|
const res = await (0, import_hanji6.renderWithTask)(
|
|
39496
39526
|
progress,
|
|
39497
39527
|
fromDatabase3(
|
|
39498
39528
|
client,
|
|
39499
|
-
|
|
39529
|
+
filter2,
|
|
39500
39530
|
(stage, count, status) => {
|
|
39501
39531
|
progress.update(stage, count, status);
|
|
39502
39532
|
}
|
|
@@ -44610,12 +44640,26 @@ var init_pgIntrospect = __esm({
|
|
|
44610
44640
|
init_pgSerializer();
|
|
44611
44641
|
init_introspect();
|
|
44612
44642
|
init_global();
|
|
44613
|
-
|
|
44643
|
+
init_mjs();
|
|
44644
|
+
pgIntrospect = async (config, filters) => {
|
|
44614
44645
|
const pool = new import_pg.Pool(config.dbCredentials);
|
|
44646
|
+
const matchers = filters.map((it) => {
|
|
44647
|
+
return new Minimatch(it);
|
|
44648
|
+
});
|
|
44649
|
+
const filter2 = (tableName) => {
|
|
44650
|
+
if (matchers.length === 0)
|
|
44651
|
+
return true;
|
|
44652
|
+
for (let i = 0; i < matchers.length; i++) {
|
|
44653
|
+
const matcher = matchers[i];
|
|
44654
|
+
if (matcher.match(tableName))
|
|
44655
|
+
return true;
|
|
44656
|
+
}
|
|
44657
|
+
return false;
|
|
44658
|
+
};
|
|
44615
44659
|
const progress = new IntrospectProgress();
|
|
44616
44660
|
const res = await (0, import_hanji7.renderWithTask)(
|
|
44617
44661
|
progress,
|
|
44618
|
-
fromDatabase2(pool, (stage, count, status) => {
|
|
44662
|
+
fromDatabase2(pool, filter2, (stage, count, status) => {
|
|
44619
44663
|
progress.update(stage, count, status);
|
|
44620
44664
|
})
|
|
44621
44665
|
);
|
|
@@ -44805,7 +44849,7 @@ var package_default = {
|
|
|
44805
44849
|
"better-sqlite3": "^8.4.0",
|
|
44806
44850
|
dockerode: "^3.3.4",
|
|
44807
44851
|
dotenv: "^16.0.3",
|
|
44808
|
-
"drizzle-orm": "0.
|
|
44852
|
+
"drizzle-orm": "0.27.0-56b9edc",
|
|
44809
44853
|
esbuild: "^0.17.19",
|
|
44810
44854
|
"esbuild-register": "^3.4.2",
|
|
44811
44855
|
eslint: "^8.29.0",
|
|
@@ -45687,7 +45731,6 @@ var validateIntrospect = async (options) => {
|
|
|
45687
45731
|
if (collisionRes.action === "config") {
|
|
45688
45732
|
const drizzleConfig = await readDrizzleConfig(options.config);
|
|
45689
45733
|
const configRes = sqliteCliConfigSchema.safeParse(drizzleConfig);
|
|
45690
|
-
console.log(configRes);
|
|
45691
45734
|
if (!configRes.success) {
|
|
45692
45735
|
printConfigConnectionIssues(drizzleConfig);
|
|
45693
45736
|
process.exit(1);
|
|
@@ -46446,7 +46489,9 @@ var introspectPgCommand = new import_commander.Command("introspect:pg").option("
|
|
|
46446
46489
|
options
|
|
46447
46490
|
);
|
|
46448
46491
|
const { snapshots, journal } = prepareOutFolder2(validatedConfig.out, "pg");
|
|
46449
|
-
const
|
|
46492
|
+
const filterConfig = validatedConfig.tablesFilter;
|
|
46493
|
+
const tablesFilter = filterConfig ? typeof filterConfig === "string" ? [filterConfig] : filterConfig : [];
|
|
46494
|
+
const { schema: schema4, ts } = await pgIntrospect2(validatedConfig, tablesFilter);
|
|
46450
46495
|
const schemaFile = import_path7.default.join(validatedConfig.out, "schema.ts");
|
|
46451
46496
|
(0, import_fs11.writeFileSync)(schemaFile, ts);
|
|
46452
46497
|
console.log();
|
|
@@ -46497,7 +46542,9 @@ var introspectMySqlCommand = new import_commander.Command("introspect:mysql").op
|
|
|
46497
46542
|
const res = await validateMySqlIntrospect(options);
|
|
46498
46543
|
const out = res.out;
|
|
46499
46544
|
const { snapshots, journal } = prepareOutFolder2(out, "mysql");
|
|
46500
|
-
const
|
|
46545
|
+
const filterConfig = res.tablesFilter;
|
|
46546
|
+
const tablesFilter = filterConfig ? typeof filterConfig === "string" ? [filterConfig] : filterConfig : [];
|
|
46547
|
+
const { schema: schema4, ts } = await mysqlIntrospect2(res, tablesFilter);
|
|
46501
46548
|
const schemaFile = import_path7.default.join(out, "schema.ts");
|
|
46502
46549
|
(0, import_fs11.writeFileSync)(schemaFile, ts);
|
|
46503
46550
|
console.log();
|
|
@@ -46548,7 +46595,9 @@ var introspectSQLiteCommand = new import_commander.Command("introspect:sqlite").
|
|
|
46548
46595
|
const res = await validateIntrospect(options);
|
|
46549
46596
|
const out = res.out;
|
|
46550
46597
|
const { snapshots, journal } = prepareOutFolder2(out, "sqlite");
|
|
46551
|
-
const
|
|
46598
|
+
const filterConfig = res.tablesFilter;
|
|
46599
|
+
const tablesFilter = filterConfig ? typeof filterConfig === "string" ? [filterConfig] : filterConfig : [];
|
|
46600
|
+
const { schema: schema4, ts } = await sqliteIntrospect2(res, tablesFilter);
|
|
46552
46601
|
const schemaFile = import_path7.default.join(out, "schema.ts");
|
|
46553
46602
|
(0, import_fs11.writeFileSync)(schemaFile, ts);
|
|
46554
46603
|
console.log();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drizzle-kit",
|
|
3
|
-
"version": "0.19.0-
|
|
3
|
+
"version": "0.19.0-9770e22",
|
|
4
4
|
"repository": "https://github.com/drizzle-team/drizzle-kit-mirror",
|
|
5
5
|
"author": "Drizzle Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"better-sqlite3": "^8.4.0",
|
|
76
76
|
"dockerode": "^3.3.4",
|
|
77
77
|
"dotenv": "^16.0.3",
|
|
78
|
-
"drizzle-orm": "0.
|
|
78
|
+
"drizzle-orm": "0.27.0-56b9edc",
|
|
79
79
|
"esbuild": "^0.17.19",
|
|
80
80
|
"esbuild-register": "^3.4.2",
|
|
81
81
|
"eslint": "^8.29.0",
|
package/utils.js
CHANGED
|
@@ -13602,7 +13602,7 @@ var PgCreateTableConvertor = class extends Convertor {
|
|
|
13602
13602
|
const primaryKeyStatement = column4.primaryKey ? "PRIMARY KEY" : "";
|
|
13603
13603
|
const notNullStatement = column4.notNull ? "NOT NULL" : "";
|
|
13604
13604
|
const defaultStatement = column4.default !== void 0 ? `DEFAULT ${column4.default}` : "";
|
|
13605
|
-
const type = isPgNativeType(column4.type) ? column4.type :
|
|
13605
|
+
const type = isPgNativeType(column4.type) ? column4.type : `"${column4.type}"`;
|
|
13606
13606
|
statement += " " + `"${column4.name}" ${type} ${primaryKeyStatement} ${defaultStatement} ${notNullStatement}`.replace(/ +/g, " ").trim();
|
|
13607
13607
|
statement += (i === columns.length - 1 ? "" : ",") + "\n";
|
|
13608
13608
|
}
|
|
@@ -13766,9 +13766,9 @@ var PgRenameTableConvertor = class extends Convertor {
|
|
|
13766
13766
|
return statement.type === "rename_table" && dialect3 === "pg";
|
|
13767
13767
|
}
|
|
13768
13768
|
convert(statement) {
|
|
13769
|
-
const { tableNameFrom, tableNameTo, toSchema
|
|
13770
|
-
const from =
|
|
13771
|
-
const to =
|
|
13769
|
+
const { tableNameFrom, tableNameTo, toSchema, fromSchema } = statement;
|
|
13770
|
+
const from = fromSchema ? `"${fromSchema}"."${tableNameFrom}"` : `"${tableNameFrom}"`;
|
|
13771
|
+
const to = `"${tableNameTo}"`;
|
|
13772
13772
|
return `ALTER TABLE ${from} RENAME TO ${to};`;
|
|
13773
13773
|
}
|
|
13774
13774
|
};
|