drizzle-kit 0.19.5-0b8d69c → 0.19.5-10646d0
Sign up to get free protection for your applications and to get access to all the features.
- package/index.cjs +20 -10
- package/package.json +1 -1
- package/utils.js +0 -2
package/index.cjs
CHANGED
@@ -11692,7 +11692,6 @@ The unique constraint ${source_default.underline.blue(
|
|
11692
11692
|
let tablesCount = /* @__PURE__ */ new Set();
|
11693
11693
|
let indexesCount = 0;
|
11694
11694
|
let foreignKeysCount = 0;
|
11695
|
-
const tableToPk = {};
|
11696
11695
|
for (const column7 of response) {
|
11697
11696
|
if (!tablesFilter(column7["TABLE_NAME"]))
|
11698
11697
|
continue;
|
@@ -11721,13 +11720,6 @@ The unique constraint ${source_default.underline.blue(
|
|
11721
11720
|
isAutoincrement = column7["EXTRA"] === "auto_increment";
|
11722
11721
|
isDefaultAnExpression = column7["EXTRA"].includes("DEFAULT_GENERATED");
|
11723
11722
|
}
|
11724
|
-
if (isPrimary) {
|
11725
|
-
if (typeof tableToPk[tableName] === "undefined") {
|
11726
|
-
tableToPk[tableName] = [columnName];
|
11727
|
-
} else {
|
11728
|
-
tableToPk[tableName].push(columnName);
|
11729
|
-
}
|
11730
|
-
}
|
11731
11723
|
if (schema4 !== inputSchema) {
|
11732
11724
|
schemas.push(schema4);
|
11733
11725
|
}
|
@@ -11765,6 +11757,26 @@ The unique constraint ${source_default.underline.blue(
|
|
11765
11757
|
result[tableName].columns[columnName] = newColumn;
|
11766
11758
|
}
|
11767
11759
|
}
|
11760
|
+
const tablePks = await db.execute(
|
11761
|
+
`SELECT table_name, column_name
|
11762
|
+
FROM information_schema.table_constraints t
|
11763
|
+
LEFT JOIN information_schema.key_column_usage k
|
11764
|
+
USING(constraint_name,table_schema,table_name)
|
11765
|
+
WHERE t.constraint_type='PRIMARY KEY'
|
11766
|
+
AND t.table_schema='${inputSchema}'`,
|
11767
|
+
[]
|
11768
|
+
);
|
11769
|
+
const tableToPk = {};
|
11770
|
+
const tableToPkRows = tablePks[0];
|
11771
|
+
for (const tableToPkRow of tableToPkRows) {
|
11772
|
+
const tableName = tableToPkRow["TABLE_NAME"];
|
11773
|
+
const columnName = tableToPkRow["COLUMN_NAME"];
|
11774
|
+
if (typeof tableToPk[tableName] === "undefined") {
|
11775
|
+
tableToPk[tableName] = [columnName];
|
11776
|
+
} else {
|
11777
|
+
tableToPk[tableName].push(columnName);
|
11778
|
+
}
|
11779
|
+
}
|
11768
11780
|
for (const [key, value] of Object.entries(tableToPk)) {
|
11769
11781
|
if (value.length > 1) {
|
11770
11782
|
result[key].compositePrimaryKeys = {
|
@@ -15659,7 +15671,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
15659
15671
|
}
|
15660
15672
|
convert(statement) {
|
15661
15673
|
const { tableName, columnName } = statement;
|
15662
|
-
console.log(statement);
|
15663
15674
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
15664
15675
|
return `ALTER TABLE ${tableNameWithSchema} ADD PRIMARY KEY ("${columnName}");`;
|
15665
15676
|
}
|
@@ -17350,7 +17361,6 @@ var init_snapshotsDiffer = __esm({
|
|
17350
17361
|
jsonStatements.push(...jsonSQLiteCreateTables);
|
17351
17362
|
} else if (dialect6 === "pg") {
|
17352
17363
|
const jsonPgCreateTables = created.map((it) => {
|
17353
|
-
console.log(it);
|
17354
17364
|
return preparePgCreateTableJson(it, curFull);
|
17355
17365
|
});
|
17356
17366
|
jsonStatements.push(...jsonPgCreateTables);
|
package/package.json
CHANGED
package/utils.js
CHANGED
@@ -14373,7 +14373,6 @@ var PgAlterTableAlterColumnSetPrimaryKeyConvertor = class extends Convertor {
|
|
14373
14373
|
}
|
14374
14374
|
convert(statement) {
|
14375
14375
|
const { tableName, columnName } = statement;
|
14376
|
-
console.log(statement);
|
14377
14376
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
14378
14377
|
return `ALTER TABLE ${tableNameWithSchema} ADD PRIMARY KEY ("${columnName}");`;
|
14379
14378
|
}
|
@@ -16047,7 +16046,6 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
|
|
16047
16046
|
jsonStatements.push(...jsonSQLiteCreateTables);
|
16048
16047
|
} else if (dialect3 === "pg") {
|
16049
16048
|
const jsonPgCreateTables = created.map((it) => {
|
16050
|
-
console.log(it);
|
16051
16049
|
return preparePgCreateTableJson(it, curFull);
|
16052
16050
|
});
|
16053
16051
|
jsonStatements.push(...jsonPgCreateTables);
|