drizzle-kit 0.22.7-28915b7 → 0.22.7-7d90fee
Sign up to get free protection for your applications and to get access to all the features.
- package/bin.cjs +20 -11
- package/package.json +1 -1
- package/payload.js +18 -11
- package/payload.mjs +18 -11
package/bin.cjs
CHANGED
@@ -22390,7 +22390,6 @@ function mapSqlToSqliteType(sqlType) {
|
|
22390
22390
|
}
|
22391
22391
|
}
|
22392
22392
|
function extractGeneratedColumns(input) {
|
22393
|
-
console.log("input", input);
|
22394
22393
|
const columns = {};
|
22395
22394
|
const lines = input.split(/,\s*(?![^()]*\))/);
|
22396
22395
|
for (const line of lines) {
|
@@ -22412,7 +22411,6 @@ function extractGeneratedColumns(input) {
|
|
22412
22411
|
};
|
22413
22412
|
}
|
22414
22413
|
}
|
22415
|
-
console.log("columns", columns);
|
22416
22414
|
return columns;
|
22417
22415
|
}
|
22418
22416
|
var import_drizzle_orm7, import_sqlite_core2, dialect6, generateSqliteSnapshot, fromDatabase3;
|
@@ -23285,8 +23283,6 @@ var init_sqlgenerator = __esm({
|
|
23285
23283
|
const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
|
23286
23284
|
const unsquashedIdentity = PgSquasher.unsquashIdentity(identity);
|
23287
23285
|
const unsquashedOldIdentity = PgSquasher.unsquashIdentity(oldIdentity);
|
23288
|
-
const identityWithSchema = schema5 ? `"${schema5}"."${unsquashedIdentity == null ? void 0 : unsquashedIdentity.name}"` : `"${unsquashedIdentity == null ? void 0 : unsquashedIdentity.name}"`;
|
23289
|
-
const oldIdentityWithSchema = schema5 ? `"${schema5}"."${unsquashedOldIdentity == null ? void 0 : unsquashedOldIdentity.name}"` : `"${unsquashedOldIdentity == null ? void 0 : unsquashedOldIdentity.name}"`;
|
23290
23286
|
const statementsToReturn = [];
|
23291
23287
|
if (unsquashedOldIdentity.type !== unsquashedIdentity.type) {
|
23292
23288
|
statementsToReturn.push(
|
@@ -23595,14 +23591,18 @@ var init_sqlgenerator = __esm({
|
|
23595
23591
|
}
|
23596
23592
|
convert(statement) {
|
23597
23593
|
const { tableName, column: column7, schema: schema5 } = statement;
|
23598
|
-
const { name, type, notNull, generated } = column7;
|
23594
|
+
const { name, type, notNull, generated, primaryKey, identity } = column7;
|
23595
|
+
const primaryKeyStatement = primaryKey ? " PRIMARY KEY" : "";
|
23599
23596
|
const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
|
23600
23597
|
const defaultStatement = `${column7.default !== void 0 ? ` DEFAULT ${column7.default}` : ""}`;
|
23601
23598
|
const schemaPrefix = column7.typeSchema && column7.typeSchema !== "public" ? `"${column7.typeSchema}".` : "";
|
23602
23599
|
const fixedType = isPgNativeType(column7.type) ? column7.type : `${schemaPrefix}"${column7.type}"`;
|
23603
23600
|
const notNullStatement = `${notNull ? " NOT NULL" : ""}`;
|
23601
|
+
const unsquashedIdentity = identity ? PgSquasher.unsquashIdentity(identity) : void 0;
|
23602
|
+
const identityWithSchema = schema5 ? `"${schema5}"."${unsquashedIdentity == null ? void 0 : unsquashedIdentity.name}"` : `"${unsquashedIdentity == null ? void 0 : unsquashedIdentity.name}"`;
|
23603
|
+
const identityStatement = unsquashedIdentity ? ` GENERATED ${unsquashedIdentity.type === "always" ? "ALWAYS" : "BY DEFAULT"} AS IDENTITY (sequence name ${identityWithSchema}${unsquashedIdentity.increment ? ` INCREMENT BY ${unsquashedIdentity.increment}` : ""}${unsquashedIdentity.minValue ? ` MINVALUE ${unsquashedIdentity.minValue}` : ""}${unsquashedIdentity.maxValue ? ` MAXVALUE ${unsquashedIdentity.maxValue}` : ""}${unsquashedIdentity.startWith ? ` START WITH ${unsquashedIdentity.startWith}` : ""}${unsquashedIdentity.cache ? ` CACHE ${unsquashedIdentity.cache}` : ""}${unsquashedIdentity.cycle ? ` CYCLE` : ""})` : "";
|
23604
23604
|
const generatedStatement = ` GENERATED ALWAYS AS (${generated == null ? void 0 : generated.as}) STORED`;
|
23605
|
-
return `ALTER TABLE ${tableNameWithSchema} ADD COLUMN "${name}" ${fixedType}${defaultStatement}${notNullStatement}${generated ? generatedStatement : ""};`;
|
23605
|
+
return `ALTER TABLE ${tableNameWithSchema} ADD COLUMN "${name}" ${fixedType}${primaryKeyStatement}${defaultStatement}${notNullStatement}${generated ? generatedStatement : ""}${identityStatement};`;
|
23606
23606
|
}
|
23607
23607
|
};
|
23608
23608
|
MySqlAlterTableAddColumnConvertor = class extends Convertor {
|
@@ -23930,8 +23930,8 @@ var init_sqlgenerator = __esm({
|
|
23930
23930
|
columnPk,
|
23931
23931
|
columnGenerated
|
23932
23932
|
} = statement;
|
23933
|
-
const tableNameWithSchema = schema5 ?
|
23934
|
-
const addColumnStatement = new
|
23933
|
+
const tableNameWithSchema = schema5 ? `\`${schema5}\`.\`${tableName}\`` : `\`${tableName}\``;
|
23934
|
+
const addColumnStatement = new MySqlAlterTableAddColumnConvertor().convert({
|
23935
23935
|
schema: schema5,
|
23936
23936
|
tableName,
|
23937
23937
|
column: {
|
@@ -23947,7 +23947,7 @@ var init_sqlgenerator = __esm({
|
|
23947
23947
|
type: "alter_table_add_column"
|
23948
23948
|
});
|
23949
23949
|
return [
|
23950
|
-
`ALTER TABLE ${tableNameWithSchema} drop column
|
23950
|
+
`ALTER TABLE ${tableNameWithSchema} drop column \`${columnName}\`;`,
|
23951
23951
|
addColumnStatement
|
23952
23952
|
];
|
23953
23953
|
}
|
@@ -29557,6 +29557,13 @@ var init_snapshotsDiffer = __esm({
|
|
29557
29557
|
return false;
|
29558
29558
|
}
|
29559
29559
|
}
|
29560
|
+
if (st.type === "alter_table_alter_column_set_notnull") {
|
29561
|
+
if (jsonStatements.find(
|
29562
|
+
(it) => it.type === "alter_table_alter_column_set_identity" && it.tableName === st.tableName && it.schema === st.schema
|
29563
|
+
)) {
|
29564
|
+
return false;
|
29565
|
+
}
|
29566
|
+
}
|
29560
29567
|
return true;
|
29561
29568
|
});
|
29562
29569
|
const sqlStatements = fromJson(filteredJsonStatements, "postgresql");
|
@@ -122123,7 +122130,7 @@ var init_pgPushUtils = __esm({
|
|
122123
122130
|
}
|
122124
122131
|
}
|
122125
122132
|
}
|
122126
|
-
const stmnt = fromJson([statement], "postgresql")
|
122133
|
+
const stmnt = fromJson([statement], "postgresql");
|
122127
122134
|
if (typeof stmnt !== "undefined") {
|
122128
122135
|
if (statement.type === "drop_table") {
|
122129
122136
|
statementsToExecute.push(
|
@@ -122133,7 +122140,7 @@ var init_pgPushUtils = __esm({
|
|
122133
122140
|
)} CASCADE;`
|
122134
122141
|
);
|
122135
122142
|
} else {
|
122136
|
-
statementsToExecute.push(stmnt);
|
122143
|
+
statementsToExecute.push(...stmnt);
|
122137
122144
|
}
|
122138
122145
|
}
|
122139
122146
|
}
|
@@ -124256,7 +124263,9 @@ var init_push = __esm({
|
|
124256
124263
|
}
|
124257
124264
|
await db2.query("commit");
|
124258
124265
|
} catch (e2) {
|
124266
|
+
console.error(e2);
|
124259
124267
|
await db2.query("rollback");
|
124268
|
+
process.exit(1);
|
124260
124269
|
}
|
124261
124270
|
} else if (credentials2.driver === "turso") {
|
124262
124271
|
await db2.batch(statementsToExecute.map((it) => ({ query: it })));
|
package/package.json
CHANGED
package/payload.js
CHANGED
@@ -23102,6 +23102,13 @@ var init_snapshotsDiffer = __esm({
|
|
23102
23102
|
return false;
|
23103
23103
|
}
|
23104
23104
|
}
|
23105
|
+
if (st.type === "alter_table_alter_column_set_notnull") {
|
23106
|
+
if (jsonStatements.find(
|
23107
|
+
(it) => it.type === "alter_table_alter_column_set_identity" && it.tableName === st.tableName && it.schema === st.schema
|
23108
|
+
)) {
|
23109
|
+
return false;
|
23110
|
+
}
|
23111
|
+
}
|
23105
23112
|
return true;
|
23106
23113
|
});
|
23107
23114
|
const sqlStatements = fromJson(filteredJsonStatements, "postgresql");
|
@@ -24231,8 +24238,6 @@ var init_sqlgenerator = __esm({
|
|
24231
24238
|
const tableNameWithSchema = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
|
24232
24239
|
const unsquashedIdentity = PgSquasher.unsquashIdentity(identity);
|
24233
24240
|
const unsquashedOldIdentity = PgSquasher.unsquashIdentity(oldIdentity);
|
24234
|
-
const identityWithSchema = schema4 ? `"${schema4}"."${unsquashedIdentity?.name}"` : `"${unsquashedIdentity?.name}"`;
|
24235
|
-
const oldIdentityWithSchema = schema4 ? `"${schema4}"."${unsquashedOldIdentity?.name}"` : `"${unsquashedOldIdentity?.name}"`;
|
24236
24241
|
const statementsToReturn = [];
|
24237
24242
|
if (unsquashedOldIdentity.type !== unsquashedIdentity.type) {
|
24238
24243
|
statementsToReturn.push(
|
@@ -24541,14 +24546,18 @@ var init_sqlgenerator = __esm({
|
|
24541
24546
|
}
|
24542
24547
|
convert(statement) {
|
24543
24548
|
const { tableName, column: column4, schema: schema4 } = statement;
|
24544
|
-
const { name: name2, type, notNull, generated } = column4;
|
24549
|
+
const { name: name2, type, notNull, generated, primaryKey, identity } = column4;
|
24550
|
+
const primaryKeyStatement = primaryKey ? " PRIMARY KEY" : "";
|
24545
24551
|
const tableNameWithSchema = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
|
24546
24552
|
const defaultStatement = `${column4.default !== void 0 ? ` DEFAULT ${column4.default}` : ""}`;
|
24547
24553
|
const schemaPrefix = column4.typeSchema && column4.typeSchema !== "public" ? `"${column4.typeSchema}".` : "";
|
24548
24554
|
const fixedType = isPgNativeType(column4.type) ? column4.type : `${schemaPrefix}"${column4.type}"`;
|
24549
24555
|
const notNullStatement = `${notNull ? " NOT NULL" : ""}`;
|
24556
|
+
const unsquashedIdentity = identity ? PgSquasher.unsquashIdentity(identity) : void 0;
|
24557
|
+
const identityWithSchema = schema4 ? `"${schema4}"."${unsquashedIdentity?.name}"` : `"${unsquashedIdentity?.name}"`;
|
24558
|
+
const identityStatement = unsquashedIdentity ? ` GENERATED ${unsquashedIdentity.type === "always" ? "ALWAYS" : "BY DEFAULT"} AS IDENTITY (sequence name ${identityWithSchema}${unsquashedIdentity.increment ? ` INCREMENT BY ${unsquashedIdentity.increment}` : ""}${unsquashedIdentity.minValue ? ` MINVALUE ${unsquashedIdentity.minValue}` : ""}${unsquashedIdentity.maxValue ? ` MAXVALUE ${unsquashedIdentity.maxValue}` : ""}${unsquashedIdentity.startWith ? ` START WITH ${unsquashedIdentity.startWith}` : ""}${unsquashedIdentity.cache ? ` CACHE ${unsquashedIdentity.cache}` : ""}${unsquashedIdentity.cycle ? ` CYCLE` : ""})` : "";
|
24550
24559
|
const generatedStatement = ` GENERATED ALWAYS AS (${generated?.as}) STORED`;
|
24551
|
-
return `ALTER TABLE ${tableNameWithSchema} ADD COLUMN "${name2}" ${fixedType}${defaultStatement}${notNullStatement}${generated ? generatedStatement : ""};`;
|
24560
|
+
return `ALTER TABLE ${tableNameWithSchema} ADD COLUMN "${name2}" ${fixedType}${primaryKeyStatement}${defaultStatement}${notNullStatement}${generated ? generatedStatement : ""}${identityStatement};`;
|
24552
24561
|
}
|
24553
24562
|
};
|
24554
24563
|
MySqlAlterTableAddColumnConvertor = class extends Convertor {
|
@@ -24876,8 +24885,8 @@ var init_sqlgenerator = __esm({
|
|
24876
24885
|
columnPk,
|
24877
24886
|
columnGenerated
|
24878
24887
|
} = statement;
|
24879
|
-
const tableNameWithSchema = schema4 ?
|
24880
|
-
const addColumnStatement = new
|
24888
|
+
const tableNameWithSchema = schema4 ? `\`${schema4}\`.\`${tableName}\`` : `\`${tableName}\``;
|
24889
|
+
const addColumnStatement = new MySqlAlterTableAddColumnConvertor().convert({
|
24881
24890
|
schema: schema4,
|
24882
24891
|
tableName,
|
24883
24892
|
column: {
|
@@ -24893,7 +24902,7 @@ var init_sqlgenerator = __esm({
|
|
24893
24902
|
type: "alter_table_add_column"
|
24894
24903
|
});
|
24895
24904
|
return [
|
24896
|
-
`ALTER TABLE ${tableNameWithSchema} drop column
|
24905
|
+
`ALTER TABLE ${tableNameWithSchema} drop column \`${columnName}\`;`,
|
24897
24906
|
addColumnStatement
|
24898
24907
|
];
|
24899
24908
|
}
|
@@ -29069,7 +29078,6 @@ function mapSqlToSqliteType(sqlType) {
|
|
29069
29078
|
}
|
29070
29079
|
}
|
29071
29080
|
function extractGeneratedColumns(input) {
|
29072
|
-
console.log("input", input);
|
29073
29081
|
const columns = {};
|
29074
29082
|
const lines = input.split(/,\s*(?![^()]*\))/);
|
29075
29083
|
for (const line of lines) {
|
@@ -29091,7 +29099,6 @@ function extractGeneratedColumns(input) {
|
|
29091
29099
|
};
|
29092
29100
|
}
|
29093
29101
|
}
|
29094
|
-
console.log("columns", columns);
|
29095
29102
|
return columns;
|
29096
29103
|
}
|
29097
29104
|
var dialect5, generateSqliteSnapshot, fromDatabase2;
|
@@ -34672,7 +34679,7 @@ var pgSuggestions = async (db, statements) => {
|
|
34672
34679
|
}
|
34673
34680
|
}
|
34674
34681
|
}
|
34675
|
-
const stmnt = fromJson([statement], "postgresql")
|
34682
|
+
const stmnt = fromJson([statement], "postgresql");
|
34676
34683
|
if (typeof stmnt !== "undefined") {
|
34677
34684
|
if (statement.type === "drop_table") {
|
34678
34685
|
statementsToExecute.push(
|
@@ -34682,7 +34689,7 @@ var pgSuggestions = async (db, statements) => {
|
|
34682
34689
|
)} CASCADE;`
|
34683
34690
|
);
|
34684
34691
|
} else {
|
34685
|
-
statementsToExecute.push(stmnt);
|
34692
|
+
statementsToExecute.push(...stmnt);
|
34686
34693
|
}
|
34687
34694
|
}
|
34688
34695
|
}
|
package/payload.mjs
CHANGED
@@ -23107,6 +23107,13 @@ var init_snapshotsDiffer = __esm({
|
|
23107
23107
|
return false;
|
23108
23108
|
}
|
23109
23109
|
}
|
23110
|
+
if (st.type === "alter_table_alter_column_set_notnull") {
|
23111
|
+
if (jsonStatements.find(
|
23112
|
+
(it) => it.type === "alter_table_alter_column_set_identity" && it.tableName === st.tableName && it.schema === st.schema
|
23113
|
+
)) {
|
23114
|
+
return false;
|
23115
|
+
}
|
23116
|
+
}
|
23110
23117
|
return true;
|
23111
23118
|
});
|
23112
23119
|
const sqlStatements = fromJson(filteredJsonStatements, "postgresql");
|
@@ -24236,8 +24243,6 @@ var init_sqlgenerator = __esm({
|
|
24236
24243
|
const tableNameWithSchema = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
|
24237
24244
|
const unsquashedIdentity = PgSquasher.unsquashIdentity(identity);
|
24238
24245
|
const unsquashedOldIdentity = PgSquasher.unsquashIdentity(oldIdentity);
|
24239
|
-
const identityWithSchema = schema4 ? `"${schema4}"."${unsquashedIdentity?.name}"` : `"${unsquashedIdentity?.name}"`;
|
24240
|
-
const oldIdentityWithSchema = schema4 ? `"${schema4}"."${unsquashedOldIdentity?.name}"` : `"${unsquashedOldIdentity?.name}"`;
|
24241
24246
|
const statementsToReturn = [];
|
24242
24247
|
if (unsquashedOldIdentity.type !== unsquashedIdentity.type) {
|
24243
24248
|
statementsToReturn.push(
|
@@ -24546,14 +24551,18 @@ var init_sqlgenerator = __esm({
|
|
24546
24551
|
}
|
24547
24552
|
convert(statement) {
|
24548
24553
|
const { tableName, column: column4, schema: schema4 } = statement;
|
24549
|
-
const { name: name2, type, notNull, generated } = column4;
|
24554
|
+
const { name: name2, type, notNull, generated, primaryKey, identity } = column4;
|
24555
|
+
const primaryKeyStatement = primaryKey ? " PRIMARY KEY" : "";
|
24550
24556
|
const tableNameWithSchema = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
|
24551
24557
|
const defaultStatement = `${column4.default !== void 0 ? ` DEFAULT ${column4.default}` : ""}`;
|
24552
24558
|
const schemaPrefix = column4.typeSchema && column4.typeSchema !== "public" ? `"${column4.typeSchema}".` : "";
|
24553
24559
|
const fixedType = isPgNativeType(column4.type) ? column4.type : `${schemaPrefix}"${column4.type}"`;
|
24554
24560
|
const notNullStatement = `${notNull ? " NOT NULL" : ""}`;
|
24561
|
+
const unsquashedIdentity = identity ? PgSquasher.unsquashIdentity(identity) : void 0;
|
24562
|
+
const identityWithSchema = schema4 ? `"${schema4}"."${unsquashedIdentity?.name}"` : `"${unsquashedIdentity?.name}"`;
|
24563
|
+
const identityStatement = unsquashedIdentity ? ` GENERATED ${unsquashedIdentity.type === "always" ? "ALWAYS" : "BY DEFAULT"} AS IDENTITY (sequence name ${identityWithSchema}${unsquashedIdentity.increment ? ` INCREMENT BY ${unsquashedIdentity.increment}` : ""}${unsquashedIdentity.minValue ? ` MINVALUE ${unsquashedIdentity.minValue}` : ""}${unsquashedIdentity.maxValue ? ` MAXVALUE ${unsquashedIdentity.maxValue}` : ""}${unsquashedIdentity.startWith ? ` START WITH ${unsquashedIdentity.startWith}` : ""}${unsquashedIdentity.cache ? ` CACHE ${unsquashedIdentity.cache}` : ""}${unsquashedIdentity.cycle ? ` CYCLE` : ""})` : "";
|
24555
24564
|
const generatedStatement = ` GENERATED ALWAYS AS (${generated?.as}) STORED`;
|
24556
|
-
return `ALTER TABLE ${tableNameWithSchema} ADD COLUMN "${name2}" ${fixedType}${defaultStatement}${notNullStatement}${generated ? generatedStatement : ""};`;
|
24565
|
+
return `ALTER TABLE ${tableNameWithSchema} ADD COLUMN "${name2}" ${fixedType}${primaryKeyStatement}${defaultStatement}${notNullStatement}${generated ? generatedStatement : ""}${identityStatement};`;
|
24557
24566
|
}
|
24558
24567
|
};
|
24559
24568
|
MySqlAlterTableAddColumnConvertor = class extends Convertor {
|
@@ -24881,8 +24890,8 @@ var init_sqlgenerator = __esm({
|
|
24881
24890
|
columnPk,
|
24882
24891
|
columnGenerated
|
24883
24892
|
} = statement;
|
24884
|
-
const tableNameWithSchema = schema4 ?
|
24885
|
-
const addColumnStatement = new
|
24893
|
+
const tableNameWithSchema = schema4 ? `\`${schema4}\`.\`${tableName}\`` : `\`${tableName}\``;
|
24894
|
+
const addColumnStatement = new MySqlAlterTableAddColumnConvertor().convert({
|
24886
24895
|
schema: schema4,
|
24887
24896
|
tableName,
|
24888
24897
|
column: {
|
@@ -24898,7 +24907,7 @@ var init_sqlgenerator = __esm({
|
|
24898
24907
|
type: "alter_table_add_column"
|
24899
24908
|
});
|
24900
24909
|
return [
|
24901
|
-
`ALTER TABLE ${tableNameWithSchema} drop column
|
24910
|
+
`ALTER TABLE ${tableNameWithSchema} drop column \`${columnName}\`;`,
|
24902
24911
|
addColumnStatement
|
24903
24912
|
];
|
24904
24913
|
}
|
@@ -29074,7 +29083,6 @@ function mapSqlToSqliteType(sqlType) {
|
|
29074
29083
|
}
|
29075
29084
|
}
|
29076
29085
|
function extractGeneratedColumns(input) {
|
29077
|
-
console.log("input", input);
|
29078
29086
|
const columns = {};
|
29079
29087
|
const lines = input.split(/,\s*(?![^()]*\))/);
|
29080
29088
|
for (const line of lines) {
|
@@ -29096,7 +29104,6 @@ function extractGeneratedColumns(input) {
|
|
29096
29104
|
};
|
29097
29105
|
}
|
29098
29106
|
}
|
29099
|
-
console.log("columns", columns);
|
29100
29107
|
return columns;
|
29101
29108
|
}
|
29102
29109
|
var dialect5, generateSqliteSnapshot, fromDatabase2;
|
@@ -34663,7 +34670,7 @@ var pgSuggestions = async (db, statements) => {
|
|
34663
34670
|
}
|
34664
34671
|
}
|
34665
34672
|
}
|
34666
|
-
const stmnt = fromJson([statement], "postgresql")
|
34673
|
+
const stmnt = fromJson([statement], "postgresql");
|
34667
34674
|
if (typeof stmnt !== "undefined") {
|
34668
34675
|
if (statement.type === "drop_table") {
|
34669
34676
|
statementsToExecute.push(
|
@@ -34673,7 +34680,7 @@ var pgSuggestions = async (db, statements) => {
|
|
34673
34680
|
)} CASCADE;`
|
34674
34681
|
);
|
34675
34682
|
} else {
|
34676
|
-
statementsToExecute.push(stmnt);
|
34683
|
+
statementsToExecute.push(...stmnt);
|
34677
34684
|
}
|
34678
34685
|
}
|
34679
34686
|
}
|