drizzle-kit 0.22.7-7d5e8a9 → 0.22.7-a16c9a1
Sign up to get free protection for your applications and to get access to all the features.
- package/bin.cjs +26 -31
- package/package.json +1 -1
- package/payload.js +11 -17
- package/payload.mjs +11 -17
package/bin.cjs
CHANGED
@@ -22391,19 +22391,13 @@ function mapSqlToSqliteType(sqlType) {
|
|
22391
22391
|
}
|
22392
22392
|
function extractGeneratedColumns(input) {
|
22393
22393
|
const columns = {};
|
22394
|
-
const lines = input.split(
|
22394
|
+
const lines = input.split("\n");
|
22395
22395
|
for (const line of lines) {
|
22396
22396
|
if (line.includes("GENERATED ALWAYS AS")) {
|
22397
22397
|
const parts = line.trim().split(/\s+/);
|
22398
|
-
const columnName = parts[0].
|
22398
|
+
const columnName = parts[0].slice(1, parts[0].length - 1);
|
22399
22399
|
const expression = line.substring(line.indexOf("("), line.indexOf(")") + 1).trim();
|
22400
|
-
const
|
22401
|
-
(part) => part.match(/(stored|virtual)/i)
|
22402
|
-
);
|
22403
|
-
let type = "virtual";
|
22404
|
-
if (typeIndex !== -1) {
|
22405
|
-
type = parts[typeIndex].replace(/[^a-z]/gi, "").toLowerCase();
|
22406
|
-
}
|
22400
|
+
const type = parts[parts.length - 1].replace(/(^,)|(,$)/g, "").toLowerCase();
|
22407
22401
|
columns[columnName] = {
|
22408
22402
|
columnName,
|
22409
22403
|
expression,
|
@@ -22451,7 +22445,7 @@ var init_sqliteSerializer = __esm({
|
|
22451
22445
|
notNull,
|
22452
22446
|
autoincrement: (0, import_drizzle_orm7.is)(column7, import_sqlite_core2.SQLiteBaseInteger) ? column7.autoIncrement : false,
|
22453
22447
|
generated: generated ? {
|
22454
|
-
as: (0, import_drizzle_orm7.is)(generated.as, import_drizzle_orm7.SQL) ?
|
22448
|
+
as: (0, import_drizzle_orm7.is)(generated.as, import_drizzle_orm7.SQL) ? dialect6.sqlToQuery(generated.as, "indexes").sql : typeof generated.as === "function" ? dialect6.sqlToQuery(generated.as(), "indexes").sql : generated.as,
|
22455
22449
|
type: generated.mode ?? "virtual"
|
22456
22450
|
} : void 0
|
22457
22451
|
};
|
@@ -23208,7 +23202,7 @@ var init_sqlgenerator = __esm({
|
|
23208
23202
|
const notNullStatement = column7.notNull ? " NOT NULL" : "";
|
23209
23203
|
const defaultStatement = column7.default !== void 0 ? ` DEFAULT ${column7.default}` : "";
|
23210
23204
|
const autoincrementStatement = column7.autoincrement ? " AUTOINCREMENT" : "";
|
23211
|
-
const generatedStatement = column7.generated ? ` GENERATED ALWAYS AS ${column7.generated.as} ${column7.generated.type.toUpperCase()}` : "";
|
23205
|
+
const generatedStatement = column7.generated ? ` GENERATED ALWAYS AS (${column7.generated.as}) ${column7.generated.type.toUpperCase()}` : "";
|
23212
23206
|
statement += " ";
|
23213
23207
|
statement += `\`${column7.name}\` ${column7.type}${primaryKeyStatement}${autoincrementStatement}${defaultStatement}${notNullStatement}${generatedStatement}`;
|
23214
23208
|
statement += i2 === columns.length - 1 ? "" : ",\n";
|
@@ -23639,7 +23633,7 @@ var init_sqlgenerator = __esm({
|
|
23639
23633
|
const primaryKeyStatement = `${primaryKey ? " PRIMARY KEY" : ""}`;
|
23640
23634
|
const referenceAsObject = referenceData ? SQLiteSquasher.unsquashFK(referenceData) : void 0;
|
23641
23635
|
const referenceStatement = `${referenceAsObject ? ` REFERENCES ${referenceAsObject.tableTo}(${referenceAsObject.columnsTo})` : ""}`;
|
23642
|
-
const generatedStatement = generated ? ` GENERATED ALWAYS AS ${generated.as} ${generated.type.toUpperCase()}` : "";
|
23636
|
+
const generatedStatement = generated ? ` GENERATED ALWAYS AS (${generated.as}) ${generated.type.toUpperCase()}` : "";
|
23643
23637
|
return `ALTER TABLE \`${tableName}\` ADD \`${name}\` ${type}${primaryKeyStatement}${defaultStatement}${notNullStatement}${generatedStatement}${referenceStatement};`;
|
23644
23638
|
}
|
23645
23639
|
};
|
@@ -122363,14 +122357,14 @@ var init_sqlitePushUtils = __esm({
|
|
122363
122357
|
}
|
122364
122358
|
tablesContext[newTableName] = _moveDataStatements(
|
122365
122359
|
statement.tableName,
|
122366
|
-
|
122360
|
+
json2,
|
122367
122361
|
true
|
122368
122362
|
);
|
122369
122363
|
} else {
|
122370
122364
|
if (typeof tablesContext[newTableName] === "undefined") {
|
122371
122365
|
tablesContext[newTableName] = _moveDataStatements(
|
122372
122366
|
statement.tableName,
|
122373
|
-
|
122367
|
+
json2
|
122374
122368
|
);
|
122375
122369
|
}
|
122376
122370
|
}
|
@@ -122389,7 +122383,7 @@ var init_sqlitePushUtils = __esm({
|
|
122389
122383
|
const uniqueTableRefs = [...new Set(tablesReferncingCurrent)];
|
122390
122384
|
for (const table4 of uniqueTableRefs) {
|
122391
122385
|
if (typeof tablesContext[table4] === "undefined") {
|
122392
|
-
tablesContext[table4] = [..._moveDataStatements(table4,
|
122386
|
+
tablesContext[table4] = [..._moveDataStatements(table4, json2)];
|
122393
122387
|
}
|
122394
122388
|
}
|
122395
122389
|
}
|
@@ -122410,9 +122404,9 @@ var init_sqlitePushUtils = __esm({
|
|
122410
122404
|
);
|
122411
122405
|
}
|
122412
122406
|
} else {
|
122413
|
-
const stmnt = fromJson([statement], "sqlite");
|
122407
|
+
const stmnt = fromJson([statement], "sqlite")[0];
|
122414
122408
|
if (typeof stmnt !== "undefined") {
|
122415
|
-
statementsToExecute.push(
|
122409
|
+
statementsToExecute.push(stmnt);
|
122416
122410
|
}
|
122417
122411
|
}
|
122418
122412
|
}
|
@@ -124242,24 +124236,25 @@ var init_push = __esm({
|
|
124242
124236
|
process.exit(0);
|
124243
124237
|
}
|
124244
124238
|
}
|
124239
|
+
if (!("driver" in credentials2)) {
|
124240
|
+
await db2.query("begin");
|
124241
|
+
try {
|
124242
|
+
for (const dStmnt of statementsToExecute) {
|
124243
|
+
await db2.query(dStmnt);
|
124244
|
+
}
|
124245
|
+
await db2.query("commit");
|
124246
|
+
} catch (e2) {
|
124247
|
+
await db2.query("rollback");
|
124248
|
+
}
|
124249
|
+
} else if (credentials2.driver === "turso") {
|
124250
|
+
await db2.batch(statementsToExecute.map((it) => ({ query: it })));
|
124251
|
+
}
|
124245
124252
|
if (statementsToExecute.length === 0) {
|
124246
124253
|
(0, import_hanji11.render)(`
|
124247
124254
|
[${source_default.blue("i")}] No changes detected`);
|
124248
124255
|
} else {
|
124249
|
-
|
124250
|
-
await db2.
|
124251
|
-
try {
|
124252
|
-
for (const dStmnt of statementsToExecute) {
|
124253
|
-
await db2.query(dStmnt);
|
124254
|
-
}
|
124255
|
-
await db2.query("commit");
|
124256
|
-
} catch (e2) {
|
124257
|
-
console.error(e2);
|
124258
|
-
await db2.query("rollback");
|
124259
|
-
process.exit(1);
|
124260
|
-
}
|
124261
|
-
} else if (credentials2.driver === "turso") {
|
124262
|
-
await db2.batch(statementsToExecute.map((it) => ({ query: it })));
|
124256
|
+
for (const dStmnt of statementsToExecute) {
|
124257
|
+
await db2.run(dStmnt);
|
124263
124258
|
}
|
124264
124259
|
(0, import_hanji11.render)(`[${source_default.green("\u2713")}] Changes applied`);
|
124265
124260
|
}
|
package/package.json
CHANGED
package/payload.js
CHANGED
@@ -24156,7 +24156,7 @@ var init_sqlgenerator = __esm({
|
|
24156
24156
|
const notNullStatement = column4.notNull ? " NOT NULL" : "";
|
24157
24157
|
const defaultStatement = column4.default !== void 0 ? ` DEFAULT ${column4.default}` : "";
|
24158
24158
|
const autoincrementStatement = column4.autoincrement ? " AUTOINCREMENT" : "";
|
24159
|
-
const generatedStatement = column4.generated ? ` GENERATED ALWAYS AS ${column4.generated.as} ${column4.generated.type.toUpperCase()}` : "";
|
24159
|
+
const generatedStatement = column4.generated ? ` GENERATED ALWAYS AS (${column4.generated.as}) ${column4.generated.type.toUpperCase()}` : "";
|
24160
24160
|
statement += " ";
|
24161
24161
|
statement += `\`${column4.name}\` ${column4.type}${primaryKeyStatement}${autoincrementStatement}${defaultStatement}${notNullStatement}${generatedStatement}`;
|
24162
24162
|
statement += i === columns.length - 1 ? "" : ",\n";
|
@@ -24587,7 +24587,7 @@ var init_sqlgenerator = __esm({
|
|
24587
24587
|
const primaryKeyStatement = `${primaryKey ? " PRIMARY KEY" : ""}`;
|
24588
24588
|
const referenceAsObject = referenceData ? SQLiteSquasher.unsquashFK(referenceData) : void 0;
|
24589
24589
|
const referenceStatement = `${referenceAsObject ? ` REFERENCES ${referenceAsObject.tableTo}(${referenceAsObject.columnsTo})` : ""}`;
|
24590
|
-
const generatedStatement = generated ? ` GENERATED ALWAYS AS ${generated.as} ${generated.type.toUpperCase()}` : "";
|
24590
|
+
const generatedStatement = generated ? ` GENERATED ALWAYS AS (${generated.as}) ${generated.type.toUpperCase()}` : "";
|
24591
24591
|
return `ALTER TABLE \`${tableName}\` ADD \`${name2}\` ${type}${primaryKeyStatement}${defaultStatement}${notNullStatement}${generatedStatement}${referenceStatement};`;
|
24592
24592
|
}
|
24593
24593
|
};
|
@@ -29070,19 +29070,13 @@ function mapSqlToSqliteType(sqlType) {
|
|
29070
29070
|
}
|
29071
29071
|
function extractGeneratedColumns(input) {
|
29072
29072
|
const columns = {};
|
29073
|
-
const lines = input.split(
|
29073
|
+
const lines = input.split("\n");
|
29074
29074
|
for (const line of lines) {
|
29075
29075
|
if (line.includes("GENERATED ALWAYS AS")) {
|
29076
29076
|
const parts = line.trim().split(/\s+/);
|
29077
|
-
const columnName = parts[0].
|
29077
|
+
const columnName = parts[0].slice(1, parts[0].length - 1);
|
29078
29078
|
const expression = line.substring(line.indexOf("("), line.indexOf(")") + 1).trim();
|
29079
|
-
const
|
29080
|
-
(part) => part.match(/(stored|virtual)/i)
|
29081
|
-
);
|
29082
|
-
let type = "virtual";
|
29083
|
-
if (typeIndex !== -1) {
|
29084
|
-
type = parts[typeIndex].replace(/[^a-z]/gi, "").toLowerCase();
|
29085
|
-
}
|
29079
|
+
const type = parts[parts.length - 1].replace(/(^,)|(,$)/g, "").toLowerCase();
|
29086
29080
|
columns[columnName] = {
|
29087
29081
|
columnName,
|
29088
29082
|
expression,
|
@@ -29130,7 +29124,7 @@ var init_sqliteSerializer = __esm({
|
|
29130
29124
|
notNull,
|
29131
29125
|
autoincrement: is(column4, SQLiteBaseInteger) ? column4.autoIncrement : false,
|
29132
29126
|
generated: generated ? {
|
29133
|
-
as: is(generated.as, SQL) ?
|
29127
|
+
as: is(generated.as, SQL) ? dialect5.sqlToQuery(generated.as, "indexes").sql : typeof generated.as === "function" ? dialect5.sqlToQuery(generated.as(), "indexes").sql : generated.as,
|
29134
29128
|
type: generated.mode ?? "virtual"
|
29135
29129
|
} : void 0
|
29136
29130
|
};
|
@@ -35054,14 +35048,14 @@ var logSuggestionsAndReturn = async (connection, statements, json1, json2, meta)
|
|
35054
35048
|
}
|
35055
35049
|
tablesContext[newTableName] = _moveDataStatements(
|
35056
35050
|
statement.tableName,
|
35057
|
-
|
35051
|
+
json2,
|
35058
35052
|
true
|
35059
35053
|
);
|
35060
35054
|
} else {
|
35061
35055
|
if (typeof tablesContext[newTableName] === "undefined") {
|
35062
35056
|
tablesContext[newTableName] = _moveDataStatements(
|
35063
35057
|
statement.tableName,
|
35064
|
-
|
35058
|
+
json2
|
35065
35059
|
);
|
35066
35060
|
}
|
35067
35061
|
}
|
@@ -35080,7 +35074,7 @@ var logSuggestionsAndReturn = async (connection, statements, json1, json2, meta)
|
|
35080
35074
|
const uniqueTableRefs = [...new Set(tablesReferncingCurrent)];
|
35081
35075
|
for (const table4 of uniqueTableRefs) {
|
35082
35076
|
if (typeof tablesContext[table4] === "undefined") {
|
35083
|
-
tablesContext[table4] = [..._moveDataStatements(table4,
|
35077
|
+
tablesContext[table4] = [..._moveDataStatements(table4, json2)];
|
35084
35078
|
}
|
35085
35079
|
}
|
35086
35080
|
}
|
@@ -35101,9 +35095,9 @@ var logSuggestionsAndReturn = async (connection, statements, json1, json2, meta)
|
|
35101
35095
|
);
|
35102
35096
|
}
|
35103
35097
|
} else {
|
35104
|
-
const stmnt = fromJson([statement], "sqlite");
|
35098
|
+
const stmnt = fromJson([statement], "sqlite")[0];
|
35105
35099
|
if (typeof stmnt !== "undefined") {
|
35106
|
-
statementsToExecute.push(
|
35100
|
+
statementsToExecute.push(stmnt);
|
35107
35101
|
}
|
35108
35102
|
}
|
35109
35103
|
}
|
package/payload.mjs
CHANGED
@@ -24161,7 +24161,7 @@ var init_sqlgenerator = __esm({
|
|
24161
24161
|
const notNullStatement = column4.notNull ? " NOT NULL" : "";
|
24162
24162
|
const defaultStatement = column4.default !== void 0 ? ` DEFAULT ${column4.default}` : "";
|
24163
24163
|
const autoincrementStatement = column4.autoincrement ? " AUTOINCREMENT" : "";
|
24164
|
-
const generatedStatement = column4.generated ? ` GENERATED ALWAYS AS ${column4.generated.as} ${column4.generated.type.toUpperCase()}` : "";
|
24164
|
+
const generatedStatement = column4.generated ? ` GENERATED ALWAYS AS (${column4.generated.as}) ${column4.generated.type.toUpperCase()}` : "";
|
24165
24165
|
statement += " ";
|
24166
24166
|
statement += `\`${column4.name}\` ${column4.type}${primaryKeyStatement}${autoincrementStatement}${defaultStatement}${notNullStatement}${generatedStatement}`;
|
24167
24167
|
statement += i === columns.length - 1 ? "" : ",\n";
|
@@ -24592,7 +24592,7 @@ var init_sqlgenerator = __esm({
|
|
24592
24592
|
const primaryKeyStatement = `${primaryKey ? " PRIMARY KEY" : ""}`;
|
24593
24593
|
const referenceAsObject = referenceData ? SQLiteSquasher.unsquashFK(referenceData) : void 0;
|
24594
24594
|
const referenceStatement = `${referenceAsObject ? ` REFERENCES ${referenceAsObject.tableTo}(${referenceAsObject.columnsTo})` : ""}`;
|
24595
|
-
const generatedStatement = generated ? ` GENERATED ALWAYS AS ${generated.as} ${generated.type.toUpperCase()}` : "";
|
24595
|
+
const generatedStatement = generated ? ` GENERATED ALWAYS AS (${generated.as}) ${generated.type.toUpperCase()}` : "";
|
24596
24596
|
return `ALTER TABLE \`${tableName}\` ADD \`${name2}\` ${type}${primaryKeyStatement}${defaultStatement}${notNullStatement}${generatedStatement}${referenceStatement};`;
|
24597
24597
|
}
|
24598
24598
|
};
|
@@ -29075,19 +29075,13 @@ function mapSqlToSqliteType(sqlType) {
|
|
29075
29075
|
}
|
29076
29076
|
function extractGeneratedColumns(input) {
|
29077
29077
|
const columns = {};
|
29078
|
-
const lines = input.split(
|
29078
|
+
const lines = input.split("\n");
|
29079
29079
|
for (const line of lines) {
|
29080
29080
|
if (line.includes("GENERATED ALWAYS AS")) {
|
29081
29081
|
const parts = line.trim().split(/\s+/);
|
29082
|
-
const columnName = parts[0].
|
29082
|
+
const columnName = parts[0].slice(1, parts[0].length - 1);
|
29083
29083
|
const expression = line.substring(line.indexOf("("), line.indexOf(")") + 1).trim();
|
29084
|
-
const
|
29085
|
-
(part) => part.match(/(stored|virtual)/i)
|
29086
|
-
);
|
29087
|
-
let type = "virtual";
|
29088
|
-
if (typeIndex !== -1) {
|
29089
|
-
type = parts[typeIndex].replace(/[^a-z]/gi, "").toLowerCase();
|
29090
|
-
}
|
29084
|
+
const type = parts[parts.length - 1].replace(/(^,)|(,$)/g, "").toLowerCase();
|
29091
29085
|
columns[columnName] = {
|
29092
29086
|
columnName,
|
29093
29087
|
expression,
|
@@ -29135,7 +29129,7 @@ var init_sqliteSerializer = __esm({
|
|
29135
29129
|
notNull,
|
29136
29130
|
autoincrement: is(column4, SQLiteBaseInteger) ? column4.autoIncrement : false,
|
29137
29131
|
generated: generated ? {
|
29138
|
-
as: is(generated.as, SQL) ?
|
29132
|
+
as: is(generated.as, SQL) ? dialect5.sqlToQuery(generated.as, "indexes").sql : typeof generated.as === "function" ? dialect5.sqlToQuery(generated.as(), "indexes").sql : generated.as,
|
29139
29133
|
type: generated.mode ?? "virtual"
|
29140
29134
|
} : void 0
|
29141
29135
|
};
|
@@ -35045,14 +35039,14 @@ var logSuggestionsAndReturn = async (connection, statements, json1, json2, meta)
|
|
35045
35039
|
}
|
35046
35040
|
tablesContext[newTableName] = _moveDataStatements(
|
35047
35041
|
statement.tableName,
|
35048
|
-
|
35042
|
+
json2,
|
35049
35043
|
true
|
35050
35044
|
);
|
35051
35045
|
} else {
|
35052
35046
|
if (typeof tablesContext[newTableName] === "undefined") {
|
35053
35047
|
tablesContext[newTableName] = _moveDataStatements(
|
35054
35048
|
statement.tableName,
|
35055
|
-
|
35049
|
+
json2
|
35056
35050
|
);
|
35057
35051
|
}
|
35058
35052
|
}
|
@@ -35071,7 +35065,7 @@ var logSuggestionsAndReturn = async (connection, statements, json1, json2, meta)
|
|
35071
35065
|
const uniqueTableRefs = [...new Set(tablesReferncingCurrent)];
|
35072
35066
|
for (const table4 of uniqueTableRefs) {
|
35073
35067
|
if (typeof tablesContext[table4] === "undefined") {
|
35074
|
-
tablesContext[table4] = [..._moveDataStatements(table4,
|
35068
|
+
tablesContext[table4] = [..._moveDataStatements(table4, json2)];
|
35075
35069
|
}
|
35076
35070
|
}
|
35077
35071
|
}
|
@@ -35092,9 +35086,9 @@ var logSuggestionsAndReturn = async (connection, statements, json1, json2, meta)
|
|
35092
35086
|
);
|
35093
35087
|
}
|
35094
35088
|
} else {
|
35095
|
-
const stmnt = fromJson([statement], "sqlite");
|
35089
|
+
const stmnt = fromJson([statement], "sqlite")[0];
|
35096
35090
|
if (typeof stmnt !== "undefined") {
|
35097
|
-
statementsToExecute.push(
|
35091
|
+
statementsToExecute.push(stmnt);
|
35098
35092
|
}
|
35099
35093
|
}
|
35100
35094
|
}
|