drizzle-kit 0.24.0-6205f01 → 0.24.0-bb966f7
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/api.js +1219 -656
 - package/api.mjs +1219 -656
 - package/bin.cjs +1616 -641
 - package/package.json +2 -2
 - package/utils.js +9 -0
 - package/utils.mjs +8 -0
 
    
        package/bin.cjs
    CHANGED
    
    | 
         @@ -6564,6 +6564,13 @@ var init_sqliteSchema = __esm({ 
     | 
|
| 
       6564 
6564 
     | 
    
         
             
            function isPgArrayType(sqlType) {
         
     | 
| 
       6565 
6565 
     | 
    
         
             
              return sqlType.match(/.*\[\d*\].*|.*\[\].*/g) !== null;
         
     | 
| 
       6566 
6566 
     | 
    
         
             
            }
         
     | 
| 
      
 6567 
     | 
    
         
            +
            function findAddedAndRemoved(columnNames1, columnNames2) {
         
     | 
| 
      
 6568 
     | 
    
         
            +
              const set1 = new Set(columnNames1);
         
     | 
| 
      
 6569 
     | 
    
         
            +
              const set2 = new Set(columnNames2);
         
     | 
| 
      
 6570 
     | 
    
         
            +
              const addedColumns = columnNames2.filter((it) => !set1.has(it));
         
     | 
| 
      
 6571 
     | 
    
         
            +
              const removedColumns = columnNames1.filter((it) => !set2.has(it));
         
     | 
| 
      
 6572 
     | 
    
         
            +
              return { addedColumns, removedColumns };
         
     | 
| 
      
 6573 
     | 
    
         
            +
            }
         
     | 
| 
       6567 
6574 
     | 
    
         
             
            var import_fs, import_path, import_url, copy, objectValues, assertV1OutFolder, dryJournal, prepareOutFolder, validatorForDialect, validateWithReport, prepareMigrationFolder, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey, normaliseSQLiteUrl;
         
     | 
| 
       6568 
6575 
     | 
    
         
             
            var init_utils = __esm({
         
     | 
| 
       6569 
6576 
     | 
    
         
             
              "src/utils.ts"() {
         
     | 
| 
         @@ -11361,7 +11368,8 @@ var init_cli = __esm({ 
     | 
|
| 
       11361 
11368 
     | 
    
         
             
                  schemaFilter: unionType([stringType(), stringType().array()]).optional().default(["public"]),
         
     | 
| 
       11362 
11369 
     | 
    
         
             
                  extensionsFilters: literalType("postgis").array().optional(),
         
     | 
| 
       11363 
11370 
     | 
    
         
             
                  verbose: booleanType().optional(),
         
     | 
| 
       11364 
     | 
    
         
            -
                  strict: booleanType().optional()
         
     | 
| 
      
 11371 
     | 
    
         
            +
                  strict: booleanType().optional(),
         
     | 
| 
      
 11372 
     | 
    
         
            +
                  driver: driver.optional()
         
     | 
| 
       11365 
11373 
     | 
    
         
             
                }).passthrough();
         
     | 
| 
       11366 
11374 
     | 
    
         
             
                pullParams = objectType({
         
     | 
| 
       11367 
11375 
     | 
    
         
             
                  config: stringType().optional(),
         
     | 
| 
         @@ -17365,7 +17373,8 @@ var init_utils4 = __esm({ 
     | 
|
| 
       17365 
17373 
     | 
    
         
             
                    breakpoints: breakpoints || true,
         
     | 
| 
       17366 
17374 
     | 
    
         
             
                    schema: schema5,
         
     | 
| 
       17367 
17375 
     | 
    
         
             
                    out: out || "drizzle",
         
     | 
| 
       17368 
     | 
    
         
            -
                    bundle: driver2 === "expo"
         
     | 
| 
      
 17376 
     | 
    
         
            +
                    bundle: driver2 === "expo",
         
     | 
| 
      
 17377 
     | 
    
         
            +
                    driver: driver2
         
     | 
| 
       17369 
17378 
     | 
    
         
             
                  };
         
     | 
| 
       17370 
17379 
     | 
    
         
             
                };
         
     | 
| 
       17371 
17380 
     | 
    
         
             
                flattenDatabaseCredentials = (config) => {
         
     | 
| 
         @@ -17393,6 +17402,7 @@ var init_utils4 = __esm({ 
     | 
|
| 
       17393 
17402 
     | 
    
         
             
                  const raw2 = flattenDatabaseCredentials(
         
     | 
| 
       17394 
17403 
     | 
    
         
             
                    from === "config" ? await drizzleConfigFromFile(options.config) : options
         
     | 
| 
       17395 
17404 
     | 
    
         
             
                  );
         
     | 
| 
      
 17405 
     | 
    
         
            +
                  raw2.driver ||= options.driver;
         
     | 
| 
       17396 
17406 
     | 
    
         
             
                  raw2.verbose ||= options.verbose;
         
     | 
| 
       17397 
17407 
     | 
    
         
             
                  raw2.strict ||= options.strict;
         
     | 
| 
       17398 
17408 
     | 
    
         
             
                  const parsed = pushParams.safeParse(raw2);
         
     | 
| 
         @@ -17467,7 +17477,8 @@ var init_utils4 = __esm({ 
     | 
|
| 
       17467 
17477 
     | 
    
         
             
                      force: options.force ?? false,
         
     | 
| 
       17468 
17478 
     | 
    
         
             
                      credentials: parsed2.data,
         
     | 
| 
       17469 
17479 
     | 
    
         
             
                      tablesFilter,
         
     | 
| 
       17470 
     | 
    
         
            -
                      schemasFilter
         
     | 
| 
      
 17480 
     | 
    
         
            +
                      schemasFilter,
         
     | 
| 
      
 17481 
     | 
    
         
            +
                      driver: config.driver
         
     | 
| 
       17471 
17482 
     | 
    
         
             
                    };
         
     | 
| 
       17472 
17483 
     | 
    
         
             
                  }
         
     | 
| 
       17473 
17484 
     | 
    
         
             
                  assertUnreachable(config.dialect);
         
     | 
| 
         @@ -22852,7 +22863,20 @@ var init_jsonDiffer = __esm({ 
     | 
|
| 
       22852 
22863 
     | 
    
         
             
            });
         
     | 
| 
       22853 
22864 
     | 
    
         | 
| 
       22854 
22865 
     | 
    
         
             
            // src/sqlgenerator.ts
         
     | 
| 
       22855 
     | 
    
         
            -
             
     | 
| 
      
 22866 
     | 
    
         
            +
            function fromJson(statements, dialect7, action, driver2, json2) {
         
     | 
| 
      
 22867 
     | 
    
         
            +
              const result = statements.flatMap((statement) => {
         
     | 
| 
      
 22868 
     | 
    
         
            +
                const filtered = convertors.filter((it) => {
         
     | 
| 
      
 22869 
     | 
    
         
            +
                  return it.can(statement, dialect7, driver2);
         
     | 
| 
      
 22870 
     | 
    
         
            +
                });
         
     | 
| 
      
 22871 
     | 
    
         
            +
                const convertor = filtered.length === 1 ? filtered[0] : void 0;
         
     | 
| 
      
 22872 
     | 
    
         
            +
                if (!convertor) {
         
     | 
| 
      
 22873 
     | 
    
         
            +
                  return "";
         
     | 
| 
      
 22874 
     | 
    
         
            +
                }
         
     | 
| 
      
 22875 
     | 
    
         
            +
                return convertor.convert(statement, json2, action);
         
     | 
| 
      
 22876 
     | 
    
         
            +
              }).filter((it) => it !== "");
         
     | 
| 
      
 22877 
     | 
    
         
            +
              return result;
         
     | 
| 
      
 22878 
     | 
    
         
            +
            }
         
     | 
| 
      
 22879 
     | 
    
         
            +
            var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, CreatePgSequenceConvertor, DropPgSequenceConvertor, RenamePgSequenceConvertor, MovePgSequenceConvertor, AlterPgSequenceConvertor, CreateTypeEnumConvertor, AlterTypeAddValueConvertor, PgDropTableConvertor, MySQLDropTableConvertor, SQLiteDropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, PgAlterTableAlterColumnDropGeneratedConvertor, PgAlterTableAlterColumnSetExpressionConvertor, PgAlterTableAlterColumnAlterrGeneratedConvertor, SqliteAlterTableAlterColumnDropGeneratedConvertor, SqliteAlterTableAlterColumnSetExpressionConvertor, SqliteAlterTableAlterColumnAlterGeneratedConvertor, MySqlAlterTableAlterColumnAlterrGeneratedConvertor, MySqlAlterTableAddPk, MySqlAlterTableDropPk, LibSQLModifyColumn, MySqlModifyColumn, PgAlterTableCreateCompositePrimaryKeyConvertor, PgAlterTableDeleteCompositePrimaryKeyConvertor, PgAlterTableAlterCompositePrimaryKeyConvertor, MySqlAlterTableCreateCompositePrimaryKeyConvertor, MySqlAlterTableDeleteCompositePrimaryKeyConvertor, MySqlAlterTableAlterCompositePrimaryKeyConvertor, PgAlterTableAlterColumnSetPrimaryKeyConvertor, PgAlterTableAlterColumnDropPrimaryKeyConvertor, PgAlterTableAlterColumnSetNotNullConvertor, PgAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, LibSQLCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, PgCreateSchemaConvertor, PgRenameSchemaConvertor, PgDropSchemaConvertor, PgAlterTableSetSchemaConvertor, PgAlterTableSetNewSchemaConvertor, PgAlterTableRemoveFromSchemaConvertor, SqliteDropIndexConvertor, MySqlDropIndexConvertor, SQLiteRecreateTableConvertor, LibSQLRecreateTableConvertor, convertors;
         
     | 
| 
       22856 
22880 
     | 
    
         
             
            var init_sqlgenerator = __esm({
         
     | 
| 
       22857 
22881 
     | 
    
         
             
              "src/sqlgenerator.ts"() {
         
     | 
| 
       22858 
22882 
     | 
    
         
             
                "use strict";
         
     | 
| 
         @@ -23177,32 +23201,6 @@ var init_sqlgenerator = __esm({ 
     | 
|
| 
       23177 
23201 
     | 
    
         
             
                    return `ALTER TABLE \`${statement.tableName}\` DROP INDEX \`${unsquashed.name}\`;`;
         
     | 
| 
       23178 
23202 
     | 
    
         
             
                  }
         
     | 
| 
       23179 
23203 
     | 
    
         
             
                };
         
     | 
| 
       23180 
     | 
    
         
            -
                SQLiteAlterTableAddUniqueConstraintConvertor = class extends Convertor {
         
     | 
| 
       23181 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       23182 
     | 
    
         
            -
                    return statement.type === "create_unique_constraint" && dialect7 === "sqlite";
         
     | 
| 
       23183 
     | 
    
         
            -
                  }
         
     | 
| 
       23184 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       23185 
     | 
    
         
            -
                    return `/*
         
     | 
| 
       23186 
     | 
    
         
            -
             SQLite does not support "Adding unique constraint to an existing table" out of the box, we do not generate automatic migration for that, so it has to be done manually
         
     | 
| 
       23187 
     | 
    
         
            -
             Please refer to: https://www.techonthenet.com/sqlite/unique.php
         
     | 
| 
       23188 
     | 
    
         
            -
             
     | 
| 
       23189 
     | 
    
         
            -
             Due to that we don't generate migration automatically and it has to be done manually
         
     | 
| 
       23190 
     | 
    
         
            -
            */`;
         
     | 
| 
       23191 
     | 
    
         
            -
                  }
         
     | 
| 
       23192 
     | 
    
         
            -
                };
         
     | 
| 
       23193 
     | 
    
         
            -
                SQLiteAlterTableDropUniqueConstraintConvertor = class extends Convertor {
         
     | 
| 
       23194 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       23195 
     | 
    
         
            -
                    return statement.type === "delete_unique_constraint" && dialect7 === "sqlite";
         
     | 
| 
       23196 
     | 
    
         
            -
                  }
         
     | 
| 
       23197 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       23198 
     | 
    
         
            -
                    return `/*
         
     | 
| 
       23199 
     | 
    
         
            -
             SQLite does not support "Dropping unique constraint from an existing table" out of the box, we do not generate automatic migration for that, so it has to be done manually
         
     | 
| 
       23200 
     | 
    
         
            -
             Please refer to: https://www.techonthenet.com/sqlite/unique.php
         
     | 
| 
       23201 
     | 
    
         
            -
             
     | 
| 
       23202 
     | 
    
         
            -
             Due to that we don't generate migration automatically and it has to be done manually
         
     | 
| 
       23203 
     | 
    
         
            -
            */`;
         
     | 
| 
       23204 
     | 
    
         
            -
                  }
         
     | 
| 
       23205 
     | 
    
         
            -
                };
         
     | 
| 
       23206 
23204 
     | 
    
         
             
                CreatePgSequenceConvertor = class extends Convertor {
         
     | 
| 
       23207 
23205 
     | 
    
         
             
                  can(statement, dialect7) {
         
     | 
| 
       23208 
23206 
     | 
    
         
             
                    return statement.type === "create_sequence" && dialect7 === "postgresql";
         
     | 
| 
         @@ -23371,7 +23369,7 @@ var init_sqlgenerator = __esm({ 
     | 
|
| 
       23371 
23369 
     | 
    
         
             
                  }
         
     | 
| 
       23372 
23370 
     | 
    
         
             
                  convert(statement) {
         
     | 
| 
       23373 
23371 
     | 
    
         
             
                    const { tableName, oldColumnName, newColumnName } = statement;
         
     | 
| 
       23374 
     | 
    
         
            -
                    return `ALTER TABLE \`${tableName}\` RENAME COLUMN  
     | 
| 
      
 23372 
     | 
    
         
            +
                    return `ALTER TABLE \`${tableName}\` RENAME COLUMN "${oldColumnName}" TO "${newColumnName}";`;
         
     | 
| 
       23375 
23373 
     | 
    
         
             
                  }
         
     | 
| 
       23376 
23374 
     | 
    
         
             
                };
         
     | 
| 
       23377 
23375 
     | 
    
         
             
                PgAlterTableDropColumnConvertor = class extends Convertor {
         
     | 
| 
         @@ -23472,21 +23470,6 @@ var init_sqlgenerator = __esm({ 
     | 
|
| 
       23472 
23470 
     | 
    
         
             
                    return `ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${columnName}" SET DATA TYPE ${newDataType};`;
         
     | 
| 
       23473 
23471 
     | 
    
         
             
                  }
         
     | 
| 
       23474 
23472 
     | 
    
         
             
                };
         
     | 
| 
       23475 
     | 
    
         
            -
                SQLiteAlterTableAlterColumnSetTypeConvertor = class extends Convertor {
         
     | 
| 
       23476 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       23477 
     | 
    
         
            -
                    return statement.type === "alter_table_alter_column_set_type" && dialect7 === "sqlite";
         
     | 
| 
       23478 
     | 
    
         
            -
                  }
         
     | 
| 
       23479 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       23480 
     | 
    
         
            -
                    return `/*
         
     | 
| 
       23481 
     | 
    
         
            -
             SQLite does not support "Changing existing column type" out of the box, we do not generate automatic migration for that, so it has to be done manually
         
     | 
| 
       23482 
     | 
    
         
            -
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         
     | 
| 
       23483 
     | 
    
         
            -
                              https://www.sqlite.org/lang_altertable.html
         
     | 
| 
       23484 
     | 
    
         
            -
                              https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
         
     | 
| 
       23485 
     | 
    
         
            -
             
     | 
| 
       23486 
     | 
    
         
            -
             Due to that we don't generate migration automatically and it has to be done manually
         
     | 
| 
       23487 
     | 
    
         
            -
            */`;
         
     | 
| 
       23488 
     | 
    
         
            -
                  }
         
     | 
| 
       23489 
     | 
    
         
            -
                };
         
     | 
| 
       23490 
23473 
     | 
    
         
             
                PgAlterTableAlterColumnSetDefaultConvertor = class extends Convertor {
         
     | 
| 
       23491 
23474 
     | 
    
         
             
                  can(statement, dialect7) {
         
     | 
| 
       23492 
23475 
     | 
    
         
             
                    return statement.type === "alter_table_alter_column_set_default" && dialect7 === "postgresql";
         
     | 
| 
         @@ -23497,21 +23480,6 @@ var init_sqlgenerator = __esm({ 
     | 
|
| 
       23497 
23480 
     | 
    
         
             
                    return `ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${columnName}" SET DEFAULT ${statement.newDefaultValue};`;
         
     | 
| 
       23498 
23481 
     | 
    
         
             
                  }
         
     | 
| 
       23499 
23482 
     | 
    
         
             
                };
         
     | 
| 
       23500 
     | 
    
         
            -
                SqliteAlterTableAlterColumnSetDefaultConvertor = class extends Convertor {
         
     | 
| 
       23501 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       23502 
     | 
    
         
            -
                    return statement.type === "alter_table_alter_column_set_default" && dialect7 === "sqlite";
         
     | 
| 
       23503 
     | 
    
         
            -
                  }
         
     | 
| 
       23504 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       23505 
     | 
    
         
            -
                    return `/*
         
     | 
| 
       23506 
     | 
    
         
            -
             SQLite does not support "Set default to column" out of the box, we do not generate automatic migration for that, so it has to be done manually
         
     | 
| 
       23507 
     | 
    
         
            -
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         
     | 
| 
       23508 
     | 
    
         
            -
                              https://www.sqlite.org/lang_altertable.html
         
     | 
| 
       23509 
     | 
    
         
            -
                              https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
         
     | 
| 
       23510 
     | 
    
         
            -
             
     | 
| 
       23511 
     | 
    
         
            -
             Due to that we don't generate migration automatically and it has to be done manually
         
     | 
| 
       23512 
     | 
    
         
            -
            */`;
         
     | 
| 
       23513 
     | 
    
         
            -
                  }
         
     | 
| 
       23514 
     | 
    
         
            -
                };
         
     | 
| 
       23515 
23483 
     | 
    
         
             
                PgAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
         
     | 
| 
       23516 
23484 
     | 
    
         
             
                  can(statement, dialect7) {
         
     | 
| 
       23517 
23485 
     | 
    
         
             
                    return statement.type === "alter_table_alter_column_drop_default" && dialect7 === "postgresql";
         
     | 
| 
         @@ -23785,6 +23753,67 @@ var init_sqlgenerator = __esm({ 
     | 
|
| 
       23785 
23753 
     | 
    
         
             
                    return `ALTER TABLE \`${statement.tableName}\` DROP PRIMARY KEY`;
         
     | 
| 
       23786 
23754 
     | 
    
         
             
                  }
         
     | 
| 
       23787 
23755 
     | 
    
         
             
                };
         
     | 
| 
      
 23756 
     | 
    
         
            +
                LibSQLModifyColumn = class extends Convertor {
         
     | 
| 
      
 23757 
     | 
    
         
            +
                  can(statement, dialect7, driver2) {
         
     | 
| 
      
 23758 
     | 
    
         
            +
                    return (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default") && dialect7 === "sqlite" && driver2 === "turso";
         
     | 
| 
      
 23759 
     | 
    
         
            +
                  }
         
     | 
| 
      
 23760 
     | 
    
         
            +
                  convert(statement, json2, action) {
         
     | 
| 
      
 23761 
     | 
    
         
            +
                    const { tableName, columnName } = statement;
         
     | 
| 
      
 23762 
     | 
    
         
            +
                    let columnType = ``;
         
     | 
| 
      
 23763 
     | 
    
         
            +
                    let columnDefault = "";
         
     | 
| 
      
 23764 
     | 
    
         
            +
                    let columnNotNull = "";
         
     | 
| 
      
 23765 
     | 
    
         
            +
                    const sqlStatements = [];
         
     | 
| 
      
 23766 
     | 
    
         
            +
                    const indexes = [];
         
     | 
| 
      
 23767 
     | 
    
         
            +
                    for (const table4 of Object.values(json2.tables)) {
         
     | 
| 
      
 23768 
     | 
    
         
            +
                      for (const index4 of Object.values(table4.indexes)) {
         
     | 
| 
      
 23769 
     | 
    
         
            +
                        const unsquashed = SQLiteSquasher.unsquashIdx(index4);
         
     | 
| 
      
 23770 
     | 
    
         
            +
                        sqlStatements.push(`DROP INDEX IF EXISTS "${unsquashed.name}";`);
         
     | 
| 
      
 23771 
     | 
    
         
            +
                        indexes.push({ ...unsquashed, tableName: table4.name });
         
     | 
| 
      
 23772 
     | 
    
         
            +
                      }
         
     | 
| 
      
 23773 
     | 
    
         
            +
                    }
         
     | 
| 
      
 23774 
     | 
    
         
            +
                    switch (statement.type) {
         
     | 
| 
      
 23775 
     | 
    
         
            +
                      case "alter_table_alter_column_set_type":
         
     | 
| 
      
 23776 
     | 
    
         
            +
                        columnType = ` ${statement.newDataType}`;
         
     | 
| 
      
 23777 
     | 
    
         
            +
                        columnDefault = statement.columnDefault ? ` DEFAULT ${statement.columnDefault}` : "";
         
     | 
| 
      
 23778 
     | 
    
         
            +
                        columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
         
     | 
| 
      
 23779 
     | 
    
         
            +
                        break;
         
     | 
| 
      
 23780 
     | 
    
         
            +
                      case "alter_table_alter_column_drop_notnull":
         
     | 
| 
      
 23781 
     | 
    
         
            +
                        columnType = ` ${statement.newDataType}`;
         
     | 
| 
      
 23782 
     | 
    
         
            +
                        columnDefault = statement.columnDefault ? ` DEFAULT ${statement.columnDefault}` : "";
         
     | 
| 
      
 23783 
     | 
    
         
            +
                        columnNotNull = "";
         
     | 
| 
      
 23784 
     | 
    
         
            +
                        break;
         
     | 
| 
      
 23785 
     | 
    
         
            +
                      case "alter_table_alter_column_set_notnull":
         
     | 
| 
      
 23786 
     | 
    
         
            +
                        columnType = ` ${statement.newDataType}`;
         
     | 
| 
      
 23787 
     | 
    
         
            +
                        columnDefault = statement.columnDefault ? ` DEFAULT ${statement.columnDefault}` : "";
         
     | 
| 
      
 23788 
     | 
    
         
            +
                        columnNotNull = ` NOT NULL`;
         
     | 
| 
      
 23789 
     | 
    
         
            +
                        break;
         
     | 
| 
      
 23790 
     | 
    
         
            +
                      case "alter_table_alter_column_set_default":
         
     | 
| 
      
 23791 
     | 
    
         
            +
                        columnType = ` ${statement.newDataType}`;
         
     | 
| 
      
 23792 
     | 
    
         
            +
                        columnDefault = ` DEFAULT ${statement.newDefaultValue}`;
         
     | 
| 
      
 23793 
     | 
    
         
            +
                        columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
         
     | 
| 
      
 23794 
     | 
    
         
            +
                        break;
         
     | 
| 
      
 23795 
     | 
    
         
            +
                      case "alter_table_alter_column_drop_default":
         
     | 
| 
      
 23796 
     | 
    
         
            +
                        columnType = ` ${statement.newDataType}`;
         
     | 
| 
      
 23797 
     | 
    
         
            +
                        columnDefault = "";
         
     | 
| 
      
 23798 
     | 
    
         
            +
                        columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
         
     | 
| 
      
 23799 
     | 
    
         
            +
                        break;
         
     | 
| 
      
 23800 
     | 
    
         
            +
                    }
         
     | 
| 
      
 23801 
     | 
    
         
            +
                    columnDefault = columnDefault instanceof Date ? columnDefault.toISOString() : columnDefault;
         
     | 
| 
      
 23802 
     | 
    
         
            +
                    sqlStatements.push(
         
     | 
| 
      
 23803 
     | 
    
         
            +
                      `ALTER TABLE \`${tableName}\` ALTER COLUMN "${columnName}" TO "${columnName}"${columnType}${columnNotNull}${columnDefault};`
         
     | 
| 
      
 23804 
     | 
    
         
            +
                    );
         
     | 
| 
      
 23805 
     | 
    
         
            +
                    for (const index4 of indexes) {
         
     | 
| 
      
 23806 
     | 
    
         
            +
                      const indexPart = index4.isUnique ? "UNIQUE INDEX" : "INDEX";
         
     | 
| 
      
 23807 
     | 
    
         
            +
                      const whereStatement = index4.where ? ` WHERE ${index4.where}` : "";
         
     | 
| 
      
 23808 
     | 
    
         
            +
                      const uniqueString = index4.columns.map((it) => `\`${it}\``).join(",");
         
     | 
| 
      
 23809 
     | 
    
         
            +
                      const tableName2 = index4.tableName;
         
     | 
| 
      
 23810 
     | 
    
         
            +
                      sqlStatements.push(
         
     | 
| 
      
 23811 
     | 
    
         
            +
                        `CREATE ${indexPart} \`${index4.name}\` ON \`${tableName2}\` (${uniqueString})${whereStatement};`
         
     | 
| 
      
 23812 
     | 
    
         
            +
                      );
         
     | 
| 
      
 23813 
     | 
    
         
            +
                    }
         
     | 
| 
      
 23814 
     | 
    
         
            +
                    return sqlStatements;
         
     | 
| 
      
 23815 
     | 
    
         
            +
                  }
         
     | 
| 
      
 23816 
     | 
    
         
            +
                };
         
     | 
| 
       23788 
23817 
     | 
    
         
             
                MySqlModifyColumn = class extends Convertor {
         
     | 
| 
       23789 
23818 
     | 
    
         
             
                  can(statement, dialect7) {
         
     | 
| 
       23790 
23819 
     | 
    
         
             
                    return (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_drop_on_update" || statement.type === "alter_table_alter_column_set_on_update" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default" || statement.type === "alter_table_alter_column_set_generated" || statement.type === "alter_table_alter_column_drop_generated") && dialect7 === "mysql";
         
     | 
| 
         @@ -23923,21 +23952,6 @@ var init_sqlgenerator = __esm({ 
     | 
|
| 
       23923 
23952 
     | 
    
         
             
                    return `ALTER TABLE \`${tableName}\` MODIFY COLUMN \`${columnName}\`${columnType}${columnAutoincrement}${columnNotNull}${columnDefault}${columnOnUpdate}${columnGenerated};`;
         
     | 
| 
       23924 
23953 
     | 
    
         
             
                  }
         
     | 
| 
       23925 
23954 
     | 
    
         
             
                };
         
     | 
| 
       23926 
     | 
    
         
            -
                SqliteAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
         
     | 
| 
       23927 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       23928 
     | 
    
         
            -
                    return statement.type === "alter_table_alter_column_drop_default" && dialect7 === "sqlite";
         
     | 
| 
       23929 
     | 
    
         
            -
                  }
         
     | 
| 
       23930 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       23931 
     | 
    
         
            -
                    return `/*
         
     | 
| 
       23932 
     | 
    
         
            -
             SQLite does not support "Drop default from column" out of the box, we do not generate automatic migration for that, so it has to be done manually
         
     | 
| 
       23933 
     | 
    
         
            -
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         
     | 
| 
       23934 
     | 
    
         
            -
                              https://www.sqlite.org/lang_altertable.html
         
     | 
| 
       23935 
     | 
    
         
            -
                              https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
         
     | 
| 
       23936 
     | 
    
         
            -
             
     | 
| 
       23937 
     | 
    
         
            -
             Due to that we don't generate migration automatically and it has to be done manually
         
     | 
| 
       23938 
     | 
    
         
            -
            */`;
         
     | 
| 
       23939 
     | 
    
         
            -
                  }
         
     | 
| 
       23940 
     | 
    
         
            -
                };
         
     | 
| 
       23941 
23955 
     | 
    
         
             
                PgAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
         
     | 
| 
       23942 
23956 
     | 
    
         
             
                  can(statement, dialect7) {
         
     | 
| 
       23943 
23957 
     | 
    
         
             
                    return statement.type === "create_composite_pk" && dialect7 === "postgresql";
         
     | 
| 
         @@ -24002,85 +24016,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo 
     | 
|
| 
       24002 
24016 
     | 
    
         
             
                    return `ALTER TABLE \`${statement.tableName}\` DROP PRIMARY KEY, ADD PRIMARY KEY(\`${newColumns.join("`,`")}\`);`;
         
     | 
| 
       24003 
24017 
     | 
    
         
             
                  }
         
     | 
| 
       24004 
24018 
     | 
    
         
             
                };
         
     | 
| 
       24005 
     | 
    
         
            -
                SqliteAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
         
     | 
| 
       24006 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       24007 
     | 
    
         
            -
                    return statement.type === "create_composite_pk" && dialect7 === "sqlite";
         
     | 
| 
       24008 
     | 
    
         
            -
                  }
         
     | 
| 
       24009 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       24010 
     | 
    
         
            -
                    let msg = "/*\n";
         
     | 
| 
       24011 
     | 
    
         
            -
                    msg += `You're trying to add PRIMARY KEY(${statement.data}) to '${statement.tableName}' table
         
     | 
| 
       24012 
     | 
    
         
            -
            `;
         
     | 
| 
       24013 
     | 
    
         
            -
                    msg += "SQLite does not support adding primary key to an already created table\n";
         
     | 
| 
       24014 
     | 
    
         
            -
                    msg += "You can do it in 3 steps with drizzle orm:\n";
         
     | 
| 
       24015 
     | 
    
         
            -
                    msg += " - create new mirror table with needed pk, rename current table to old_table, generate SQL\n";
         
     | 
| 
       24016 
     | 
    
         
            -
                    msg += " - migrate old data from one table to another\n";
         
     | 
| 
       24017 
     | 
    
         
            -
                    msg += " - delete old_table in schema, generate sql\n\n";
         
     | 
| 
       24018 
     | 
    
         
            -
                    msg += "or create manual migration like below:\n\n";
         
     | 
| 
       24019 
     | 
    
         
            -
                    msg += "ALTER TABLE table_name RENAME TO old_table;\n";
         
     | 
| 
       24020 
     | 
    
         
            -
                    msg += "CREATE TABLE table_name (\n";
         
     | 
| 
       24021 
     | 
    
         
            -
                    msg += "	column1 datatype [ NULL | NOT NULL ],\n";
         
     | 
| 
       24022 
     | 
    
         
            -
                    msg += "	column2 datatype [ NULL | NOT NULL ],\n";
         
     | 
| 
       24023 
     | 
    
         
            -
                    msg += "	...\n";
         
     | 
| 
       24024 
     | 
    
         
            -
                    msg += "	PRIMARY KEY (pk_col1, pk_col2, ... pk_col_n)\n";
         
     | 
| 
       24025 
     | 
    
         
            -
                    msg += " );\n";
         
     | 
| 
       24026 
     | 
    
         
            -
                    msg += "INSERT INTO table_name SELECT * FROM old_table;\n\n";
         
     | 
| 
       24027 
     | 
    
         
            -
                    msg += "Due to that we don't generate migration automatically and it has to be done manually\n";
         
     | 
| 
       24028 
     | 
    
         
            -
                    msg += "*/\n";
         
     | 
| 
       24029 
     | 
    
         
            -
                    return msg;
         
     | 
| 
       24030 
     | 
    
         
            -
                  }
         
     | 
| 
       24031 
     | 
    
         
            -
                };
         
     | 
| 
       24032 
     | 
    
         
            -
                SqliteAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
         
     | 
| 
       24033 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       24034 
     | 
    
         
            -
                    return statement.type === "delete_composite_pk" && dialect7 === "sqlite";
         
     | 
| 
       24035 
     | 
    
         
            -
                  }
         
     | 
| 
       24036 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       24037 
     | 
    
         
            -
                    let msg = "/*\n";
         
     | 
| 
       24038 
     | 
    
         
            -
                    msg += `You're trying to delete PRIMARY KEY(${statement.data}) from '${statement.tableName}' table
         
     | 
| 
       24039 
     | 
    
         
            -
            `;
         
     | 
| 
       24040 
     | 
    
         
            -
                    msg += "SQLite does not supportprimary key deletion from existing table\n";
         
     | 
| 
       24041 
     | 
    
         
            -
                    msg += "You can do it in 3 steps with drizzle orm:\n";
         
     | 
| 
       24042 
     | 
    
         
            -
                    msg += " - create new mirror table table without pk, rename current table to old_table, generate SQL\n";
         
     | 
| 
       24043 
     | 
    
         
            -
                    msg += " - migrate old data from one table to another\n";
         
     | 
| 
       24044 
     | 
    
         
            -
                    msg += " - delete old_table in schema, generate sql\n\n";
         
     | 
| 
       24045 
     | 
    
         
            -
                    msg += "or create manual migration like below:\n\n";
         
     | 
| 
       24046 
     | 
    
         
            -
                    msg += "ALTER TABLE table_name RENAME TO old_table;\n";
         
     | 
| 
       24047 
     | 
    
         
            -
                    msg += "CREATE TABLE table_name (\n";
         
     | 
| 
       24048 
     | 
    
         
            -
                    msg += "	column1 datatype [ NULL | NOT NULL ],\n";
         
     | 
| 
       24049 
     | 
    
         
            -
                    msg += "	column2 datatype [ NULL | NOT NULL ],\n";
         
     | 
| 
       24050 
     | 
    
         
            -
                    msg += "	...\n";
         
     | 
| 
       24051 
     | 
    
         
            -
                    msg += "	PRIMARY KEY (pk_col1, pk_col2, ... pk_col_n)\n";
         
     | 
| 
       24052 
     | 
    
         
            -
                    msg += " );\n";
         
     | 
| 
       24053 
     | 
    
         
            -
                    msg += "INSERT INTO table_name SELECT * FROM old_table;\n\n";
         
     | 
| 
       24054 
     | 
    
         
            -
                    msg += "Due to that we don't generate migration automatically and it has to be done manually\n";
         
     | 
| 
       24055 
     | 
    
         
            -
                    msg += "*/\n";
         
     | 
| 
       24056 
     | 
    
         
            -
                    return msg;
         
     | 
| 
       24057 
     | 
    
         
            -
                  }
         
     | 
| 
       24058 
     | 
    
         
            -
                };
         
     | 
| 
       24059 
     | 
    
         
            -
                SqliteAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
         
     | 
| 
       24060 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       24061 
     | 
    
         
            -
                    return statement.type === "alter_composite_pk" && dialect7 === "sqlite";
         
     | 
| 
       24062 
     | 
    
         
            -
                  }
         
     | 
| 
       24063 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       24064 
     | 
    
         
            -
                    let msg = "/*\n";
         
     | 
| 
       24065 
     | 
    
         
            -
                    msg += "SQLite does not support altering primary key\n";
         
     | 
| 
       24066 
     | 
    
         
            -
                    msg += "You can do it in 3 steps with drizzle orm:\n";
         
     | 
| 
       24067 
     | 
    
         
            -
                    msg += " - create new mirror table with needed pk, rename current table to old_table, generate SQL\n";
         
     | 
| 
       24068 
     | 
    
         
            -
                    msg += " - migrate old data from one table to another\n";
         
     | 
| 
       24069 
     | 
    
         
            -
                    msg += " - delete old_table in schema, generate sql\n\n";
         
     | 
| 
       24070 
     | 
    
         
            -
                    msg += "or create manual migration like below:\n\n";
         
     | 
| 
       24071 
     | 
    
         
            -
                    msg += "ALTER TABLE table_name RENAME TO old_table;\n";
         
     | 
| 
       24072 
     | 
    
         
            -
                    msg += "CREATE TABLE table_name (\n";
         
     | 
| 
       24073 
     | 
    
         
            -
                    msg += "	column1 datatype [ NULL | NOT NULL ],\n";
         
     | 
| 
       24074 
     | 
    
         
            -
                    msg += "	column2 datatype [ NULL | NOT NULL ],\n";
         
     | 
| 
       24075 
     | 
    
         
            -
                    msg += "	...\n";
         
     | 
| 
       24076 
     | 
    
         
            -
                    msg += "	PRIMARY KEY (pk_col1, pk_col2, ... pk_col_n)\n";
         
     | 
| 
       24077 
     | 
    
         
            -
                    msg += " );\n";
         
     | 
| 
       24078 
     | 
    
         
            -
                    msg += "INSERT INTO table_name SELECT * FROM old_table;\n\n";
         
     | 
| 
       24079 
     | 
    
         
            -
                    msg += "Due to that we don't generate migration automatically and it has to be done manually\n";
         
     | 
| 
       24080 
     | 
    
         
            -
                    msg += "*/\n";
         
     | 
| 
       24081 
     | 
    
         
            -
                    return msg;
         
     | 
| 
       24082 
     | 
    
         
            -
                  }
         
     | 
| 
       24083 
     | 
    
         
            -
                };
         
     | 
| 
       24084 
24019 
     | 
    
         
             
                PgAlterTableAlterColumnSetPrimaryKeyConvertor = class extends Convertor {
         
     | 
| 
       24085 
24020 
     | 
    
         
             
                  can(statement, dialect7) {
         
     | 
| 
       24086 
24021 
     | 
    
         
             
                    return statement.type === "alter_table_alter_column_set_pk" && dialect7 === "postgresql";
         
     | 
| 
         @@ -24125,51 +24060,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo 
     | 
|
| 
       24125 
24060 
     | 
    
         
             
                    return `ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${columnName}" SET NOT NULL;`;
         
     | 
| 
       24126 
24061 
     | 
    
         
             
                  }
         
     | 
| 
       24127 
24062 
     | 
    
         
             
                };
         
     | 
| 
       24128 
     | 
    
         
            -
                SqliteAlterTableAlterColumnSetNotNullConvertor = class extends Convertor {
         
     | 
| 
       24129 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       24130 
     | 
    
         
            -
                    return statement.type === "alter_table_alter_column_set_notnull" && dialect7 === "sqlite";
         
     | 
| 
       24131 
     | 
    
         
            -
                  }
         
     | 
| 
       24132 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       24133 
     | 
    
         
            -
                    return `/*
         
     | 
| 
       24134 
     | 
    
         
            -
             SQLite does not support "Set not null to column" out of the box, we do not generate automatic migration for that, so it has to be done manually
         
     | 
| 
       24135 
     | 
    
         
            -
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         
     | 
| 
       24136 
     | 
    
         
            -
                              https://www.sqlite.org/lang_altertable.html
         
     | 
| 
       24137 
     | 
    
         
            -
                              https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
         
     | 
| 
       24138 
     | 
    
         
            -
             
     | 
| 
       24139 
     | 
    
         
            -
             Due to that we don't generate migration automatically and it has to be done manually
         
     | 
| 
       24140 
     | 
    
         
            -
            */`;
         
     | 
| 
       24141 
     | 
    
         
            -
                  }
         
     | 
| 
       24142 
     | 
    
         
            -
                };
         
     | 
| 
       24143 
     | 
    
         
            -
                SqliteAlterTableAlterColumnSetAutoincrementConvertor = class extends Convertor {
         
     | 
| 
       24144 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       24145 
     | 
    
         
            -
                    return statement.type === "alter_table_alter_column_set_autoincrement" && dialect7 === "sqlite";
         
     | 
| 
       24146 
     | 
    
         
            -
                  }
         
     | 
| 
       24147 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       24148 
     | 
    
         
            -
                    return `/*
         
     | 
| 
       24149 
     | 
    
         
            -
             SQLite does not support "Set autoincrement to a column" out of the box, we do not generate automatic migration for that, so it has to be done manually
         
     | 
| 
       24150 
     | 
    
         
            -
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         
     | 
| 
       24151 
     | 
    
         
            -
                              https://www.sqlite.org/lang_altertable.html
         
     | 
| 
       24152 
     | 
    
         
            -
                              https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
         
     | 
| 
       24153 
     | 
    
         
            -
             
     | 
| 
       24154 
     | 
    
         
            -
             Due to that we don't generate migration automatically and it has to be done manually
         
     | 
| 
       24155 
     | 
    
         
            -
            */`;
         
     | 
| 
       24156 
     | 
    
         
            -
                  }
         
     | 
| 
       24157 
     | 
    
         
            -
                };
         
     | 
| 
       24158 
     | 
    
         
            -
                SqliteAlterTableAlterColumnDropAutoincrementConvertor = class extends Convertor {
         
     | 
| 
       24159 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       24160 
     | 
    
         
            -
                    return statement.type === "alter_table_alter_column_drop_autoincrement" && dialect7 === "sqlite";
         
     | 
| 
       24161 
     | 
    
         
            -
                  }
         
     | 
| 
       24162 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       24163 
     | 
    
         
            -
                    return `/*
         
     | 
| 
       24164 
     | 
    
         
            -
             SQLite does not support "Drop autoincrement from a column" out of the box, we do not generate automatic migration for that, so it has to be done manually
         
     | 
| 
       24165 
     | 
    
         
            -
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         
     | 
| 
       24166 
     | 
    
         
            -
                              https://www.sqlite.org/lang_altertable.html
         
     | 
| 
       24167 
     | 
    
         
            -
                              https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
         
     | 
| 
       24168 
     | 
    
         
            -
             
     | 
| 
       24169 
     | 
    
         
            -
             Due to that we don't generate migration automatically and it has to be done manually
         
     | 
| 
       24170 
     | 
    
         
            -
            */`;
         
     | 
| 
       24171 
     | 
    
         
            -
                  }
         
     | 
| 
       24172 
     | 
    
         
            -
                };
         
     | 
| 
       24173 
24063 
     | 
    
         
             
                PgAlterTableAlterColumnDropNotNullConvertor = class extends Convertor {
         
     | 
| 
       24174 
24064 
     | 
    
         
             
                  can(statement, dialect7) {
         
     | 
| 
       24175 
24065 
     | 
    
         
             
                    return statement.type === "alter_table_alter_column_drop_notnull" && dialect7 === "postgresql";
         
     | 
| 
         @@ -24180,21 +24070,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo 
     | 
|
| 
       24180 
24070 
     | 
    
         
             
                    return `ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${columnName}" DROP NOT NULL;`;
         
     | 
| 
       24181 
24071 
     | 
    
         
             
                  }
         
     | 
| 
       24182 
24072 
     | 
    
         
             
                };
         
     | 
| 
       24183 
     | 
    
         
            -
                SqliteAlterTableAlterColumnDropNotNullConvertor = class extends Convertor {
         
     | 
| 
       24184 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       24185 
     | 
    
         
            -
                    return statement.type === "alter_table_alter_column_drop_notnull" && dialect7 === "sqlite";
         
     | 
| 
       24186 
     | 
    
         
            -
                  }
         
     | 
| 
       24187 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       24188 
     | 
    
         
            -
                    return `/*
         
     | 
| 
       24189 
     | 
    
         
            -
             SQLite does not support "Drop not null from column" out of the box, we do not generate automatic migration for that, so it has to be done manually
         
     | 
| 
       24190 
     | 
    
         
            -
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         
     | 
| 
       24191 
     | 
    
         
            -
                              https://www.sqlite.org/lang_altertable.html
         
     | 
| 
       24192 
     | 
    
         
            -
                              https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
         
     | 
| 
       24193 
     | 
    
         
            -
             
     | 
| 
       24194 
     | 
    
         
            -
             Due to that we don't generate migration automatically and it has to be done manually
         
     | 
| 
       24195 
     | 
    
         
            -
            */`;
         
     | 
| 
       24196 
     | 
    
         
            -
                  }
         
     | 
| 
       24197 
     | 
    
         
            -
                };
         
     | 
| 
       24198 
24073 
     | 
    
         
             
                PgCreateForeignKeyConvertor = class extends Convertor {
         
     | 
| 
       24199 
24074 
     | 
    
         
             
                  can(statement, dialect7) {
         
     | 
| 
       24200 
24075 
     | 
    
         
             
                    return statement.type === "create_reference" && dialect7 === "postgresql";
         
     | 
| 
         @@ -24225,18 +24100,21 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo 
     | 
|
| 
       24225 
24100 
     | 
    
         
             
                    return sql;
         
     | 
| 
       24226 
24101 
     | 
    
         
             
                  }
         
     | 
| 
       24227 
24102 
     | 
    
         
             
                };
         
     | 
| 
       24228 
     | 
    
         
            -
                 
     | 
| 
       24229 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       24230 
     | 
    
         
            -
                    return statement.type === "create_reference" && dialect7 === "sqlite";
         
     | 
| 
      
 24103 
     | 
    
         
            +
                LibSQLCreateForeignKeyConvertor = class extends Convertor {
         
     | 
| 
      
 24104 
     | 
    
         
            +
                  can(statement, dialect7, driver2) {
         
     | 
| 
      
 24105 
     | 
    
         
            +
                    return statement.type === "create_reference" && dialect7 === "sqlite" && driver2 === "turso";
         
     | 
| 
       24231 
24106 
     | 
    
         
             
                  }
         
     | 
| 
       24232 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       24233 
     | 
    
         
            -
                     
     | 
| 
       24234 
     | 
    
         
            -
              
     | 
| 
       24235 
     | 
    
         
            -
              
     | 
| 
       24236 
     | 
    
         
            -
             
     | 
| 
       24237 
     | 
    
         
            -
             
     | 
| 
       24238 
     | 
    
         
            -
              
     | 
| 
       24239 
     | 
    
         
            -
             
     | 
| 
      
 24107 
     | 
    
         
            +
                  convert(statement, json2, action) {
         
     | 
| 
      
 24108 
     | 
    
         
            +
                    const { columnsFrom, columnsTo, tableFrom, onDelete, onUpdate, tableTo } = action === "push" ? SQLiteSquasher.unsquashPushFK(statement.data) : SQLiteSquasher.unsquashFK(statement.data);
         
     | 
| 
      
 24109 
     | 
    
         
            +
                    const { columnDefault, columnNotNull, columnType } = statement;
         
     | 
| 
      
 24110 
     | 
    
         
            +
                    const onDeleteStatement = onDelete ? ` ON DELETE ${onDelete}` : "";
         
     | 
| 
      
 24111 
     | 
    
         
            +
                    const onUpdateStatement = onUpdate ? ` ON UPDATE ${onUpdate}` : "";
         
     | 
| 
      
 24112 
     | 
    
         
            +
                    const columnsDefaultValue = columnDefault ? ` DEFAULT ${columnDefault}` : "";
         
     | 
| 
      
 24113 
     | 
    
         
            +
                    const columnNotNullValue = columnNotNull ? ` NOT NULL` : "";
         
     | 
| 
      
 24114 
     | 
    
         
            +
                    const columnTypeValue = columnType ? ` ${columnType}` : "";
         
     | 
| 
      
 24115 
     | 
    
         
            +
                    const columnFrom = columnsFrom[0];
         
     | 
| 
      
 24116 
     | 
    
         
            +
                    const columnTo = columnsTo[0];
         
     | 
| 
      
 24117 
     | 
    
         
            +
                    return `ALTER TABLE \`${tableFrom}\` ALTER COLUMN "${columnFrom}" TO "${columnFrom}"${columnTypeValue}${columnNotNullValue}${columnsDefaultValue} REFERENCES ${tableTo}(${columnTo})${onDeleteStatement}${onUpdateStatement};`;
         
     | 
| 
       24240 
24118 
     | 
    
         
             
                  }
         
     | 
| 
       24241 
24119 
     | 
    
         
             
                };
         
     | 
| 
       24242 
24120 
     | 
    
         
             
                MySqlCreateForeignKeyConvertor = class extends Convertor {
         
     | 
| 
         @@ -24285,20 +24163,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo 
     | 
|
| 
       24285 
24163 
     | 
    
         
             
                    return sql;
         
     | 
| 
       24286 
24164 
     | 
    
         
             
                  }
         
     | 
| 
       24287 
24165 
     | 
    
         
             
                };
         
     | 
| 
       24288 
     | 
    
         
            -
                SqliteAlterForeignKeyConvertor = class extends Convertor {
         
     | 
| 
       24289 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       24290 
     | 
    
         
            -
                    return statement.type === "alter_reference" && dialect7 === "sqlite";
         
     | 
| 
       24291 
     | 
    
         
            -
                  }
         
     | 
| 
       24292 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       24293 
     | 
    
         
            -
                    return `/*
         
     | 
| 
       24294 
     | 
    
         
            -
             SQLite does not support "Changing existing foreign key" out of the box, we do not generate automatic migration for that, so it has to be done manually
         
     | 
| 
       24295 
     | 
    
         
            -
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         
     | 
| 
       24296 
     | 
    
         
            -
                              https://www.sqlite.org/lang_altertable.html
         
     | 
| 
       24297 
     | 
    
         
            -
             
     | 
| 
       24298 
     | 
    
         
            -
             Due to that we don't generate migration automatically and it has to be done manually
         
     | 
| 
       24299 
     | 
    
         
            -
            */`;
         
     | 
| 
       24300 
     | 
    
         
            -
                  }
         
     | 
| 
       24301 
     | 
    
         
            -
                };
         
     | 
| 
       24302 
24166 
     | 
    
         
             
                PgDeleteForeignKeyConvertor = class extends Convertor {
         
     | 
| 
       24303 
24167 
     | 
    
         
             
                  can(statement, dialect7) {
         
     | 
| 
       24304 
24168 
     | 
    
         
             
                    return statement.type === "delete_reference" && dialect7 === "postgresql";
         
     | 
| 
         @@ -24311,20 +24175,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo 
     | 
|
| 
       24311 
24175 
     | 
    
         
             
            `;
         
     | 
| 
       24312 
24176 
     | 
    
         
             
                  }
         
     | 
| 
       24313 
24177 
     | 
    
         
             
                };
         
     | 
| 
       24314 
     | 
    
         
            -
                SqliteDeleteForeignKeyConvertor = class extends Convertor {
         
     | 
| 
       24315 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       24316 
     | 
    
         
            -
                    return statement.type === "delete_reference" && dialect7 === "sqlite";
         
     | 
| 
       24317 
     | 
    
         
            -
                  }
         
     | 
| 
       24318 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       24319 
     | 
    
         
            -
                    return `/*
         
     | 
| 
       24320 
     | 
    
         
            -
             SQLite does not support "Dropping foreign key" out of the box, we do not generate automatic migration for that, so it has to be done manually
         
     | 
| 
       24321 
     | 
    
         
            -
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         
     | 
| 
       24322 
     | 
    
         
            -
                              https://www.sqlite.org/lang_altertable.html
         
     | 
| 
       24323 
     | 
    
         
            -
             
     | 
| 
       24324 
     | 
    
         
            -
             Due to that we don't generate migration automatically and it has to be done manually
         
     | 
| 
       24325 
     | 
    
         
            -
            */`;
         
     | 
| 
       24326 
     | 
    
         
            -
                  }
         
     | 
| 
       24327 
     | 
    
         
            -
                };
         
     | 
| 
       24328 
24178 
     | 
    
         
             
                MySqlDeleteForeignKeyConvertor = class extends Convertor {
         
     | 
| 
       24329 
24179 
     | 
    
         
             
                  can(statement, dialect7) {
         
     | 
| 
       24330 
24180 
     | 
    
         
             
                    return statement.type === "delete_reference" && dialect7 === "mysql";
         
     | 
| 
         @@ -24490,10 +24340,96 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo 
     | 
|
| 
       24490 
24340 
     | 
    
         
             
                    return `DROP INDEX \`${name}\` ON \`${statement.tableName}\`;`;
         
     | 
| 
       24491 
24341 
     | 
    
         
             
                  }
         
     | 
| 
       24492 
24342 
     | 
    
         
             
                };
         
     | 
| 
      
 24343 
     | 
    
         
            +
                SQLiteRecreateTableConvertor = class extends Convertor {
         
     | 
| 
      
 24344 
     | 
    
         
            +
                  can(statement, dialect7, driver2) {
         
     | 
| 
      
 24345 
     | 
    
         
            +
                    return statement.type === "recreate_table" && dialect7 === "sqlite" && !driver2;
         
     | 
| 
      
 24346 
     | 
    
         
            +
                  }
         
     | 
| 
      
 24347 
     | 
    
         
            +
                  convert(statement) {
         
     | 
| 
      
 24348 
     | 
    
         
            +
                    const { tableName, columns, compositePKs, referenceData } = statement;
         
     | 
| 
      
 24349 
     | 
    
         
            +
                    const columnNames = columns.map((it) => `"${it.name}"`).join(", ");
         
     | 
| 
      
 24350 
     | 
    
         
            +
                    const newTableName = `__new_${tableName}`;
         
     | 
| 
      
 24351 
     | 
    
         
            +
                    const sqlStatements = [];
         
     | 
| 
      
 24352 
     | 
    
         
            +
                    sqlStatements.push(`PRAGMA foreign_keys=OFF;`);
         
     | 
| 
      
 24353 
     | 
    
         
            +
                    sqlStatements.push(
         
     | 
| 
      
 24354 
     | 
    
         
            +
                      new SQLiteCreateTableConvertor().convert({
         
     | 
| 
      
 24355 
     | 
    
         
            +
                        type: "sqlite_create_table",
         
     | 
| 
      
 24356 
     | 
    
         
            +
                        tableName: newTableName,
         
     | 
| 
      
 24357 
     | 
    
         
            +
                        columns,
         
     | 
| 
      
 24358 
     | 
    
         
            +
                        referenceData,
         
     | 
| 
      
 24359 
     | 
    
         
            +
                        compositePKs
         
     | 
| 
      
 24360 
     | 
    
         
            +
                      })
         
     | 
| 
      
 24361 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24362 
     | 
    
         
            +
                    sqlStatements.push(
         
     | 
| 
      
 24363 
     | 
    
         
            +
                      `INSERT INTO \`${newTableName}\`(${columnNames}) SELECT ${columnNames} FROM \`${tableName}\`;`
         
     | 
| 
      
 24364 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24365 
     | 
    
         
            +
                    sqlStatements.push(
         
     | 
| 
      
 24366 
     | 
    
         
            +
                      new SQLiteDropTableConvertor().convert({
         
     | 
| 
      
 24367 
     | 
    
         
            +
                        type: "drop_table",
         
     | 
| 
      
 24368 
     | 
    
         
            +
                        tableName,
         
     | 
| 
      
 24369 
     | 
    
         
            +
                        schema: ""
         
     | 
| 
      
 24370 
     | 
    
         
            +
                      })
         
     | 
| 
      
 24371 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24372 
     | 
    
         
            +
                    sqlStatements.push(
         
     | 
| 
      
 24373 
     | 
    
         
            +
                      new SqliteRenameTableConvertor().convert({
         
     | 
| 
      
 24374 
     | 
    
         
            +
                        fromSchema: "",
         
     | 
| 
      
 24375 
     | 
    
         
            +
                        tableNameFrom: newTableName,
         
     | 
| 
      
 24376 
     | 
    
         
            +
                        tableNameTo: tableName,
         
     | 
| 
      
 24377 
     | 
    
         
            +
                        toSchema: "",
         
     | 
| 
      
 24378 
     | 
    
         
            +
                        type: "rename_table"
         
     | 
| 
      
 24379 
     | 
    
         
            +
                      })
         
     | 
| 
      
 24380 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24381 
     | 
    
         
            +
                    sqlStatements.push(`PRAGMA foreign_keys=ON;`);
         
     | 
| 
      
 24382 
     | 
    
         
            +
                    return sqlStatements;
         
     | 
| 
      
 24383 
     | 
    
         
            +
                  }
         
     | 
| 
      
 24384 
     | 
    
         
            +
                };
         
     | 
| 
      
 24385 
     | 
    
         
            +
                LibSQLRecreateTableConvertor = class extends Convertor {
         
     | 
| 
      
 24386 
     | 
    
         
            +
                  can(statement, dialect7, driver2) {
         
     | 
| 
      
 24387 
     | 
    
         
            +
                    return statement.type === "recreate_table" && dialect7 === "sqlite" && driver2 === "turso";
         
     | 
| 
      
 24388 
     | 
    
         
            +
                  }
         
     | 
| 
      
 24389 
     | 
    
         
            +
                  convert(statement) {
         
     | 
| 
      
 24390 
     | 
    
         
            +
                    const { tableName, columns, compositePKs, referenceData } = statement;
         
     | 
| 
      
 24391 
     | 
    
         
            +
                    const columnNames = columns.map((it) => `"${it.name}"`).join(", ");
         
     | 
| 
      
 24392 
     | 
    
         
            +
                    const newTableName = `__new_${tableName}`;
         
     | 
| 
      
 24393 
     | 
    
         
            +
                    const sqlStatements = [];
         
     | 
| 
      
 24394 
     | 
    
         
            +
                    sqlStatements.push(`PRAGMA foreign_keys=OFF;`);
         
     | 
| 
      
 24395 
     | 
    
         
            +
                    sqlStatements.push(
         
     | 
| 
      
 24396 
     | 
    
         
            +
                      new SQLiteCreateTableConvertor().convert({
         
     | 
| 
      
 24397 
     | 
    
         
            +
                        type: "sqlite_create_table",
         
     | 
| 
      
 24398 
     | 
    
         
            +
                        tableName: newTableName,
         
     | 
| 
      
 24399 
     | 
    
         
            +
                        columns,
         
     | 
| 
      
 24400 
     | 
    
         
            +
                        referenceData,
         
     | 
| 
      
 24401 
     | 
    
         
            +
                        compositePKs
         
     | 
| 
      
 24402 
     | 
    
         
            +
                      })
         
     | 
| 
      
 24403 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24404 
     | 
    
         
            +
                    sqlStatements.push(
         
     | 
| 
      
 24405 
     | 
    
         
            +
                      `INSERT INTO \`${newTableName}\`(${columnNames}) SELECT ${columnNames} FROM \`${tableName}\`;`
         
     | 
| 
      
 24406 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24407 
     | 
    
         
            +
                    sqlStatements.push(
         
     | 
| 
      
 24408 
     | 
    
         
            +
                      new SQLiteDropTableConvertor().convert({
         
     | 
| 
      
 24409 
     | 
    
         
            +
                        type: "drop_table",
         
     | 
| 
      
 24410 
     | 
    
         
            +
                        tableName,
         
     | 
| 
      
 24411 
     | 
    
         
            +
                        schema: ""
         
     | 
| 
      
 24412 
     | 
    
         
            +
                      })
         
     | 
| 
      
 24413 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24414 
     | 
    
         
            +
                    sqlStatements.push(
         
     | 
| 
      
 24415 
     | 
    
         
            +
                      new SqliteRenameTableConvertor().convert({
         
     | 
| 
      
 24416 
     | 
    
         
            +
                        fromSchema: "",
         
     | 
| 
      
 24417 
     | 
    
         
            +
                        tableNameFrom: newTableName,
         
     | 
| 
      
 24418 
     | 
    
         
            +
                        tableNameTo: tableName,
         
     | 
| 
      
 24419 
     | 
    
         
            +
                        toSchema: "",
         
     | 
| 
      
 24420 
     | 
    
         
            +
                        type: "rename_table"
         
     | 
| 
      
 24421 
     | 
    
         
            +
                      })
         
     | 
| 
      
 24422 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24423 
     | 
    
         
            +
                    sqlStatements.push(`PRAGMA foreign_keys=ON;`);
         
     | 
| 
      
 24424 
     | 
    
         
            +
                    return sqlStatements;
         
     | 
| 
      
 24425 
     | 
    
         
            +
                  }
         
     | 
| 
      
 24426 
     | 
    
         
            +
                };
         
     | 
| 
       24493 
24427 
     | 
    
         
             
                convertors = [];
         
     | 
| 
       24494 
24428 
     | 
    
         
             
                convertors.push(new PgCreateTableConvertor());
         
     | 
| 
       24495 
24429 
     | 
    
         
             
                convertors.push(new MySqlCreateTableConvertor());
         
     | 
| 
       24496 
24430 
     | 
    
         
             
                convertors.push(new SQLiteCreateTableConvertor());
         
     | 
| 
      
 24431 
     | 
    
         
            +
                convertors.push(new SQLiteRecreateTableConvertor());
         
     | 
| 
      
 24432 
     | 
    
         
            +
                convertors.push(new LibSQLRecreateTableConvertor());
         
     | 
| 
       24497 
24433 
     | 
    
         
             
                convertors.push(new CreateTypeEnumConvertor());
         
     | 
| 
       24498 
24434 
     | 
    
         
             
                convertors.push(new CreatePgSequenceConvertor());
         
     | 
| 
       24499 
24435 
     | 
    
         
             
                convertors.push(new DropPgSequenceConvertor());
         
     | 
| 
         @@ -24541,6 +24477,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo 
     | 
|
| 
       24541 
24477 
     | 
    
         
             
                convertors.push(new SqliteAlterTableAlterColumnAlterGeneratedConvertor());
         
     | 
| 
       24542 
24478 
     | 
    
         
             
                convertors.push(new SqliteAlterTableAlterColumnSetExpressionConvertor());
         
     | 
| 
       24543 
24479 
     | 
    
         
             
                convertors.push(new MySqlModifyColumn());
         
     | 
| 
      
 24480 
     | 
    
         
            +
                convertors.push(new LibSQLModifyColumn());
         
     | 
| 
       24544 
24481 
     | 
    
         
             
                convertors.push(new PgCreateForeignKeyConvertor());
         
     | 
| 
       24545 
24482 
     | 
    
         
             
                convertors.push(new MySqlCreateForeignKeyConvertor());
         
     | 
| 
       24546 
24483 
     | 
    
         
             
                convertors.push(new PgAlterForeignKeyConvertor());
         
     | 
| 
         @@ -24552,24 +24489,10 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo 
     | 
|
| 
       24552 
24489 
     | 
    
         
             
                convertors.push(new PgAlterTableSetSchemaConvertor());
         
     | 
| 
       24553 
24490 
     | 
    
         
             
                convertors.push(new PgAlterTableSetNewSchemaConvertor());
         
     | 
| 
       24554 
24491 
     | 
    
         
             
                convertors.push(new PgAlterTableRemoveFromSchemaConvertor());
         
     | 
| 
       24555 
     | 
    
         
            -
                convertors.push(new  
     | 
| 
       24556 
     | 
    
         
            -
                convertors.push(new SqliteAlterForeignKeyConvertor());
         
     | 
| 
       24557 
     | 
    
         
            -
                convertors.push(new SqliteDeleteForeignKeyConvertor());
         
     | 
| 
       24558 
     | 
    
         
            -
                convertors.push(new SqliteCreateForeignKeyConvertor());
         
     | 
| 
       24559 
     | 
    
         
            -
                convertors.push(new SQLiteAlterTableAddUniqueConstraintConvertor());
         
     | 
| 
       24560 
     | 
    
         
            -
                convertors.push(new SQLiteAlterTableDropUniqueConstraintConvertor());
         
     | 
| 
      
 24492 
     | 
    
         
            +
                convertors.push(new LibSQLCreateForeignKeyConvertor());
         
     | 
| 
       24561 
24493 
     | 
    
         
             
                convertors.push(new PgAlterTableAlterColumnDropGenerated());
         
     | 
| 
       24562 
24494 
     | 
    
         
             
                convertors.push(new PgAlterTableAlterColumnSetGenerated());
         
     | 
| 
       24563 
24495 
     | 
    
         
             
                convertors.push(new PgAlterTableAlterColumnAlterGenerated());
         
     | 
| 
       24564 
     | 
    
         
            -
                convertors.push(new SqliteAlterTableAlterColumnSetNotNullConvertor());
         
     | 
| 
       24565 
     | 
    
         
            -
                convertors.push(new SqliteAlterTableAlterColumnDropNotNullConvertor());
         
     | 
| 
       24566 
     | 
    
         
            -
                convertors.push(new SqliteAlterTableAlterColumnSetDefaultConvertor());
         
     | 
| 
       24567 
     | 
    
         
            -
                convertors.push(new SqliteAlterTableAlterColumnDropDefaultConvertor());
         
     | 
| 
       24568 
     | 
    
         
            -
                convertors.push(new SqliteAlterTableAlterColumnSetAutoincrementConvertor());
         
     | 
| 
       24569 
     | 
    
         
            -
                convertors.push(new SqliteAlterTableAlterColumnDropAutoincrementConvertor());
         
     | 
| 
       24570 
     | 
    
         
            -
                convertors.push(new SqliteAlterTableCreateCompositePrimaryKeyConvertor());
         
     | 
| 
       24571 
     | 
    
         
            -
                convertors.push(new SqliteAlterTableDeleteCompositePrimaryKeyConvertor());
         
     | 
| 
       24572 
     | 
    
         
            -
                convertors.push(new SqliteAlterTableAlterCompositePrimaryKeyConvertor());
         
     | 
| 
       24573 
24496 
     | 
    
         
             
                convertors.push(new PgAlterTableCreateCompositePrimaryKeyConvertor());
         
     | 
| 
       24574 
24497 
     | 
    
         
             
                convertors.push(new PgAlterTableDeleteCompositePrimaryKeyConvertor());
         
     | 
| 
       24575 
24498 
     | 
    
         
             
                convertors.push(new PgAlterTableAlterCompositePrimaryKeyConvertor());
         
     | 
| 
         @@ -24578,19 +24501,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo 
     | 
|
| 
       24578 
24501 
     | 
    
         
             
                convertors.push(new MySqlAlterTableCreateCompositePrimaryKeyConvertor());
         
     | 
| 
       24579 
24502 
     | 
    
         
             
                convertors.push(new MySqlAlterTableAddPk());
         
     | 
| 
       24580 
24503 
     | 
    
         
             
                convertors.push(new MySqlAlterTableAlterCompositePrimaryKeyConvertor());
         
     | 
| 
       24581 
     | 
    
         
            -
                fromJson = (statements, dialect7) => {
         
     | 
| 
       24582 
     | 
    
         
            -
                  const result = statements.flatMap((statement) => {
         
     | 
| 
       24583 
     | 
    
         
            -
                    const filtered = convertors.filter((it) => {
         
     | 
| 
       24584 
     | 
    
         
            -
                      return it.can(statement, dialect7);
         
     | 
| 
       24585 
     | 
    
         
            -
                    });
         
     | 
| 
       24586 
     | 
    
         
            -
                    const convertor = filtered.length === 1 ? filtered[0] : void 0;
         
     | 
| 
       24587 
     | 
    
         
            -
                    if (!convertor) {
         
     | 
| 
       24588 
     | 
    
         
            -
                      return "";
         
     | 
| 
       24589 
     | 
    
         
            -
                    }
         
     | 
| 
       24590 
     | 
    
         
            -
                    return convertor.convert(statement);
         
     | 
| 
       24591 
     | 
    
         
            -
                  }).filter((it) => it !== "");
         
     | 
| 
       24592 
     | 
    
         
            -
                  return result;
         
     | 
| 
       24593 
     | 
    
         
            -
                };
         
     | 
| 
       24594 
24504 
     | 
    
         
             
                https:
         
     | 
| 
       24595 
24505 
     | 
    
         
             
                  `
         
     | 
| 
       24596 
24506 
     | 
    
         
             
            create table users (
         
     | 
| 
         @@ -24618,12 +24528,248 @@ drop type __venum; 
     | 
|
| 
       24618 
24528 
     | 
    
         
             
              }
         
     | 
| 
       24619 
24529 
     | 
    
         
             
            });
         
     | 
| 
       24620 
24530 
     | 
    
         | 
| 
      
 24531 
     | 
    
         
            +
            // src/cli/commands/sqlitePushUtils.ts
         
     | 
| 
      
 24532 
     | 
    
         
            +
            var _moveDataStatements, getOldTableName, getNewTableName, logSuggestionsAndReturn;
         
     | 
| 
      
 24533 
     | 
    
         
            +
            var init_sqlitePushUtils = __esm({
         
     | 
| 
      
 24534 
     | 
    
         
            +
              "src/cli/commands/sqlitePushUtils.ts"() {
         
     | 
| 
      
 24535 
     | 
    
         
            +
                "use strict";
         
     | 
| 
      
 24536 
     | 
    
         
            +
                init_source();
         
     | 
| 
      
 24537 
     | 
    
         
            +
                init_sqliteSchema();
         
     | 
| 
      
 24538 
     | 
    
         
            +
                init_sqlgenerator();
         
     | 
| 
      
 24539 
     | 
    
         
            +
                init_utils();
         
     | 
| 
      
 24540 
     | 
    
         
            +
                _moveDataStatements = (tableName, json, dataLoss = false) => {
         
     | 
| 
      
 24541 
     | 
    
         
            +
                  const statements = [];
         
     | 
| 
      
 24542 
     | 
    
         
            +
                  const newTableName = `__new_${tableName}`;
         
     | 
| 
      
 24543 
     | 
    
         
            +
                  const tableColumns = Object.values(json.tables[tableName].columns);
         
     | 
| 
      
 24544 
     | 
    
         
            +
                  const referenceData = Object.values(json.tables[tableName].foreignKeys);
         
     | 
| 
      
 24545 
     | 
    
         
            +
                  const compositePKs = Object.values(
         
     | 
| 
      
 24546 
     | 
    
         
            +
                    json.tables[tableName].compositePrimaryKeys
         
     | 
| 
      
 24547 
     | 
    
         
            +
                  ).map((it) => SQLiteSquasher.unsquashPK(it));
         
     | 
| 
      
 24548 
     | 
    
         
            +
                  const fks = referenceData.map((it) => SQLiteSquasher.unsquashPushFK(it));
         
     | 
| 
      
 24549 
     | 
    
         
            +
                  statements.push(
         
     | 
| 
      
 24550 
     | 
    
         
            +
                    new SQLiteCreateTableConvertor().convert({
         
     | 
| 
      
 24551 
     | 
    
         
            +
                      type: "sqlite_create_table",
         
     | 
| 
      
 24552 
     | 
    
         
            +
                      tableName: newTableName,
         
     | 
| 
      
 24553 
     | 
    
         
            +
                      columns: tableColumns,
         
     | 
| 
      
 24554 
     | 
    
         
            +
                      referenceData: fks,
         
     | 
| 
      
 24555 
     | 
    
         
            +
                      compositePKs
         
     | 
| 
      
 24556 
     | 
    
         
            +
                    })
         
     | 
| 
      
 24557 
     | 
    
         
            +
                  );
         
     | 
| 
      
 24558 
     | 
    
         
            +
                  if (!dataLoss) {
         
     | 
| 
      
 24559 
     | 
    
         
            +
                    const columns = Object.keys(json.tables[tableName].columns).map(
         
     | 
| 
      
 24560 
     | 
    
         
            +
                      (c) => `"${c}"`
         
     | 
| 
      
 24561 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24562 
     | 
    
         
            +
                    statements.push(
         
     | 
| 
      
 24563 
     | 
    
         
            +
                      `INSERT INTO \`${newTableName}\`(${columns.join(
         
     | 
| 
      
 24564 
     | 
    
         
            +
                        ", "
         
     | 
| 
      
 24565 
     | 
    
         
            +
                      )}) SELECT ${columns.join(", ")} FROM \`${tableName}\`;`
         
     | 
| 
      
 24566 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24567 
     | 
    
         
            +
                  }
         
     | 
| 
      
 24568 
     | 
    
         
            +
                  statements.push(
         
     | 
| 
      
 24569 
     | 
    
         
            +
                    new SQLiteDropTableConvertor().convert({
         
     | 
| 
      
 24570 
     | 
    
         
            +
                      type: "drop_table",
         
     | 
| 
      
 24571 
     | 
    
         
            +
                      tableName,
         
     | 
| 
      
 24572 
     | 
    
         
            +
                      schema: ""
         
     | 
| 
      
 24573 
     | 
    
         
            +
                    })
         
     | 
| 
      
 24574 
     | 
    
         
            +
                  );
         
     | 
| 
      
 24575 
     | 
    
         
            +
                  statements.push(
         
     | 
| 
      
 24576 
     | 
    
         
            +
                    new SqliteRenameTableConvertor().convert({
         
     | 
| 
      
 24577 
     | 
    
         
            +
                      fromSchema: "",
         
     | 
| 
      
 24578 
     | 
    
         
            +
                      tableNameFrom: newTableName,
         
     | 
| 
      
 24579 
     | 
    
         
            +
                      tableNameTo: tableName,
         
     | 
| 
      
 24580 
     | 
    
         
            +
                      toSchema: "",
         
     | 
| 
      
 24581 
     | 
    
         
            +
                      type: "rename_table"
         
     | 
| 
      
 24582 
     | 
    
         
            +
                    })
         
     | 
| 
      
 24583 
     | 
    
         
            +
                  );
         
     | 
| 
      
 24584 
     | 
    
         
            +
                  for (const idx of Object.values(json.tables[tableName].indexes)) {
         
     | 
| 
      
 24585 
     | 
    
         
            +
                    statements.push(
         
     | 
| 
      
 24586 
     | 
    
         
            +
                      new CreateSqliteIndexConvertor().convert({
         
     | 
| 
      
 24587 
     | 
    
         
            +
                        type: "create_index",
         
     | 
| 
      
 24588 
     | 
    
         
            +
                        tableName,
         
     | 
| 
      
 24589 
     | 
    
         
            +
                        schema: "",
         
     | 
| 
      
 24590 
     | 
    
         
            +
                        data: idx
         
     | 
| 
      
 24591 
     | 
    
         
            +
                      })
         
     | 
| 
      
 24592 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24593 
     | 
    
         
            +
                  }
         
     | 
| 
      
 24594 
     | 
    
         
            +
                  return statements;
         
     | 
| 
      
 24595 
     | 
    
         
            +
                };
         
     | 
| 
      
 24596 
     | 
    
         
            +
                getOldTableName = (tableName, meta) => {
         
     | 
| 
      
 24597 
     | 
    
         
            +
                  for (const key of Object.keys(meta.tables)) {
         
     | 
| 
      
 24598 
     | 
    
         
            +
                    const value = meta.tables[key];
         
     | 
| 
      
 24599 
     | 
    
         
            +
                    if (`"${tableName}"` === value) {
         
     | 
| 
      
 24600 
     | 
    
         
            +
                      return key.substring(1, key.length - 1);
         
     | 
| 
      
 24601 
     | 
    
         
            +
                    }
         
     | 
| 
      
 24602 
     | 
    
         
            +
                  }
         
     | 
| 
      
 24603 
     | 
    
         
            +
                  return tableName;
         
     | 
| 
      
 24604 
     | 
    
         
            +
                };
         
     | 
| 
      
 24605 
     | 
    
         
            +
                getNewTableName = (tableName, meta) => {
         
     | 
| 
      
 24606 
     | 
    
         
            +
                  if (typeof meta.tables[`"${tableName}"`] !== "undefined") {
         
     | 
| 
      
 24607 
     | 
    
         
            +
                    return meta.tables[`"${tableName}"`].substring(
         
     | 
| 
      
 24608 
     | 
    
         
            +
                      1,
         
     | 
| 
      
 24609 
     | 
    
         
            +
                      meta.tables[`"${tableName}"`].length - 1
         
     | 
| 
      
 24610 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24611 
     | 
    
         
            +
                  }
         
     | 
| 
      
 24612 
     | 
    
         
            +
                  return tableName;
         
     | 
| 
      
 24613 
     | 
    
         
            +
                };
         
     | 
| 
      
 24614 
     | 
    
         
            +
                logSuggestionsAndReturn = async (connection, statements, json1, json2, meta) => {
         
     | 
| 
      
 24615 
     | 
    
         
            +
                  let shouldAskForApprove = false;
         
     | 
| 
      
 24616 
     | 
    
         
            +
                  const statementsToExecute = [];
         
     | 
| 
      
 24617 
     | 
    
         
            +
                  const infoToPrint = [];
         
     | 
| 
      
 24618 
     | 
    
         
            +
                  const tablesToRemove = [];
         
     | 
| 
      
 24619 
     | 
    
         
            +
                  const columnsToRemove = [];
         
     | 
| 
      
 24620 
     | 
    
         
            +
                  const schemasToRemove = [];
         
     | 
| 
      
 24621 
     | 
    
         
            +
                  const tablesToTruncate = [];
         
     | 
| 
      
 24622 
     | 
    
         
            +
                  for (const statement of statements) {
         
     | 
| 
      
 24623 
     | 
    
         
            +
                    if (statement.type === "drop_table") {
         
     | 
| 
      
 24624 
     | 
    
         
            +
                      const res = await connection.query(
         
     | 
| 
      
 24625 
     | 
    
         
            +
                        `select count(*) as count from \`${statement.tableName}\``
         
     | 
| 
      
 24626 
     | 
    
         
            +
                      );
         
     | 
| 
      
 24627 
     | 
    
         
            +
                      const count = Number(res[0].count);
         
     | 
| 
      
 24628 
     | 
    
         
            +
                      if (count > 0) {
         
     | 
| 
      
 24629 
     | 
    
         
            +
                        infoToPrint.push(
         
     | 
| 
      
 24630 
     | 
    
         
            +
                          `\xB7 You're about to delete ${source_default.underline(
         
     | 
| 
      
 24631 
     | 
    
         
            +
                            statement.tableName
         
     | 
| 
      
 24632 
     | 
    
         
            +
                          )} table with ${count} items`
         
     | 
| 
      
 24633 
     | 
    
         
            +
                        );
         
     | 
| 
      
 24634 
     | 
    
         
            +
                        tablesToRemove.push(statement.tableName);
         
     | 
| 
      
 24635 
     | 
    
         
            +
                        shouldAskForApprove = true;
         
     | 
| 
      
 24636 
     | 
    
         
            +
                      }
         
     | 
| 
      
 24637 
     | 
    
         
            +
                      const fromJsonStatement = fromJson([statement], "sqlite", "push");
         
     | 
| 
      
 24638 
     | 
    
         
            +
                      statementsToExecute.push(
         
     | 
| 
      
 24639 
     | 
    
         
            +
                        ...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
         
     | 
| 
      
 24640 
     | 
    
         
            +
                      );
         
     | 
| 
      
 24641 
     | 
    
         
            +
                    } else if (statement.type === "alter_table_drop_column") {
         
     | 
| 
      
 24642 
     | 
    
         
            +
                      const tableName = statement.tableName;
         
     | 
| 
      
 24643 
     | 
    
         
            +
                      const columnName = statement.columnName;
         
     | 
| 
      
 24644 
     | 
    
         
            +
                      const res = await connection.query(
         
     | 
| 
      
 24645 
     | 
    
         
            +
                        `select count(\`${tableName}\`.\`${columnName}\`) as count from \`${tableName}\``
         
     | 
| 
      
 24646 
     | 
    
         
            +
                      );
         
     | 
| 
      
 24647 
     | 
    
         
            +
                      const count = Number(res[0].count);
         
     | 
| 
      
 24648 
     | 
    
         
            +
                      if (count > 0) {
         
     | 
| 
      
 24649 
     | 
    
         
            +
                        infoToPrint.push(
         
     | 
| 
      
 24650 
     | 
    
         
            +
                          `\xB7 You're about to delete ${source_default.underline(
         
     | 
| 
      
 24651 
     | 
    
         
            +
                            columnName
         
     | 
| 
      
 24652 
     | 
    
         
            +
                          )} column in ${tableName} table with ${count} items`
         
     | 
| 
      
 24653 
     | 
    
         
            +
                        );
         
     | 
| 
      
 24654 
     | 
    
         
            +
                        columnsToRemove.push(`${tableName}_${statement.columnName}`);
         
     | 
| 
      
 24655 
     | 
    
         
            +
                        shouldAskForApprove = true;
         
     | 
| 
      
 24656 
     | 
    
         
            +
                      }
         
     | 
| 
      
 24657 
     | 
    
         
            +
                      const fromJsonStatement = fromJson([statement], "sqlite", "push");
         
     | 
| 
      
 24658 
     | 
    
         
            +
                      statementsToExecute.push(
         
     | 
| 
      
 24659 
     | 
    
         
            +
                        ...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
         
     | 
| 
      
 24660 
     | 
    
         
            +
                      );
         
     | 
| 
      
 24661 
     | 
    
         
            +
                    } else if (statement.type === "sqlite_alter_table_add_column" && (statement.column.notNull && !statement.column.default)) {
         
     | 
| 
      
 24662 
     | 
    
         
            +
                      const tableName = statement.tableName;
         
     | 
| 
      
 24663 
     | 
    
         
            +
                      const columnName = statement.column.name;
         
     | 
| 
      
 24664 
     | 
    
         
            +
                      const res = await connection.query(
         
     | 
| 
      
 24665 
     | 
    
         
            +
                        `select count(*) as count from \`${tableName}\``
         
     | 
| 
      
 24666 
     | 
    
         
            +
                      );
         
     | 
| 
      
 24667 
     | 
    
         
            +
                      const count = Number(res[0].count);
         
     | 
| 
      
 24668 
     | 
    
         
            +
                      if (count > 0) {
         
     | 
| 
      
 24669 
     | 
    
         
            +
                        infoToPrint.push(
         
     | 
| 
      
 24670 
     | 
    
         
            +
                          `\xB7 You're about to add not-null ${source_default.underline(
         
     | 
| 
      
 24671 
     | 
    
         
            +
                            columnName
         
     | 
| 
      
 24672 
     | 
    
         
            +
                          )} column without default value, which contains ${count} items`
         
     | 
| 
      
 24673 
     | 
    
         
            +
                        );
         
     | 
| 
      
 24674 
     | 
    
         
            +
                        tablesToTruncate.push(tableName);
         
     | 
| 
      
 24675 
     | 
    
         
            +
                        statementsToExecute.push(`delete from ${tableName};`);
         
     | 
| 
      
 24676 
     | 
    
         
            +
                        shouldAskForApprove = true;
         
     | 
| 
      
 24677 
     | 
    
         
            +
                      }
         
     | 
| 
      
 24678 
     | 
    
         
            +
                      const fromJsonStatement = fromJson([statement], "sqlite", "push");
         
     | 
| 
      
 24679 
     | 
    
         
            +
                      statementsToExecute.push(
         
     | 
| 
      
 24680 
     | 
    
         
            +
                        ...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
         
     | 
| 
      
 24681 
     | 
    
         
            +
                      );
         
     | 
| 
      
 24682 
     | 
    
         
            +
                    } else if (statement.type === "recreate_table") {
         
     | 
| 
      
 24683 
     | 
    
         
            +
                      const tableName = statement.tableName;
         
     | 
| 
      
 24684 
     | 
    
         
            +
                      const oldTableName = getOldTableName(tableName, meta);
         
     | 
| 
      
 24685 
     | 
    
         
            +
                      let dataLoss = false;
         
     | 
| 
      
 24686 
     | 
    
         
            +
                      const prevColumnNames = Object.keys(json1.tables[oldTableName].columns);
         
     | 
| 
      
 24687 
     | 
    
         
            +
                      const currentColumnNames = Object.keys(json2.tables[tableName].columns);
         
     | 
| 
      
 24688 
     | 
    
         
            +
                      const { removedColumns, addedColumns } = findAddedAndRemoved(
         
     | 
| 
      
 24689 
     | 
    
         
            +
                        prevColumnNames,
         
     | 
| 
      
 24690 
     | 
    
         
            +
                        currentColumnNames
         
     | 
| 
      
 24691 
     | 
    
         
            +
                      );
         
     | 
| 
      
 24692 
     | 
    
         
            +
                      if (removedColumns.length) {
         
     | 
| 
      
 24693 
     | 
    
         
            +
                        for (const removedColumn of removedColumns) {
         
     | 
| 
      
 24694 
     | 
    
         
            +
                          const res = await connection.query(
         
     | 
| 
      
 24695 
     | 
    
         
            +
                            `select count(\`${tableName}\`.\`${removedColumn}\`) as count from \`${tableName}\``
         
     | 
| 
      
 24696 
     | 
    
         
            +
                          );
         
     | 
| 
      
 24697 
     | 
    
         
            +
                          const count = Number(res[0].count);
         
     | 
| 
      
 24698 
     | 
    
         
            +
                          if (count > 0) {
         
     | 
| 
      
 24699 
     | 
    
         
            +
                            infoToPrint.push(
         
     | 
| 
      
 24700 
     | 
    
         
            +
                              `\xB7 You're about to delete ${source_default.underline(
         
     | 
| 
      
 24701 
     | 
    
         
            +
                                removedColumn
         
     | 
| 
      
 24702 
     | 
    
         
            +
                              )} column in ${tableName} table with ${count} items`
         
     | 
| 
      
 24703 
     | 
    
         
            +
                            );
         
     | 
| 
      
 24704 
     | 
    
         
            +
                            columnsToRemove.push(removedColumn);
         
     | 
| 
      
 24705 
     | 
    
         
            +
                            shouldAskForApprove = true;
         
     | 
| 
      
 24706 
     | 
    
         
            +
                          }
         
     | 
| 
      
 24707 
     | 
    
         
            +
                        }
         
     | 
| 
      
 24708 
     | 
    
         
            +
                      }
         
     | 
| 
      
 24709 
     | 
    
         
            +
                      if (addedColumns.length) {
         
     | 
| 
      
 24710 
     | 
    
         
            +
                        for (const addedColumn of addedColumns) {
         
     | 
| 
      
 24711 
     | 
    
         
            +
                          const [res] = await connection.query(
         
     | 
| 
      
 24712 
     | 
    
         
            +
                            `select count(*) as count from \`${tableName}\``
         
     | 
| 
      
 24713 
     | 
    
         
            +
                          );
         
     | 
| 
      
 24714 
     | 
    
         
            +
                          const columnConf = json2.tables[tableName].columns[addedColumn];
         
     | 
| 
      
 24715 
     | 
    
         
            +
                          const count = Number(res.count);
         
     | 
| 
      
 24716 
     | 
    
         
            +
                          if (count > 0 && columnConf.notNull && !columnConf.default) {
         
     | 
| 
      
 24717 
     | 
    
         
            +
                            dataLoss = true;
         
     | 
| 
      
 24718 
     | 
    
         
            +
                            infoToPrint.push(
         
     | 
| 
      
 24719 
     | 
    
         
            +
                              `\xB7 You're about to add not-null ${source_default.underline(
         
     | 
| 
      
 24720 
     | 
    
         
            +
                                addedColumn
         
     | 
| 
      
 24721 
     | 
    
         
            +
                              )} column without default value to table, which contains ${count} items`
         
     | 
| 
      
 24722 
     | 
    
         
            +
                            );
         
     | 
| 
      
 24723 
     | 
    
         
            +
                            shouldAskForApprove = true;
         
     | 
| 
      
 24724 
     | 
    
         
            +
                            tablesToTruncate.push(tableName);
         
     | 
| 
      
 24725 
     | 
    
         
            +
                            statementsToExecute.push(`DELETE FROM \`${tableName}\`;`);
         
     | 
| 
      
 24726 
     | 
    
         
            +
                          }
         
     | 
| 
      
 24727 
     | 
    
         
            +
                        }
         
     | 
| 
      
 24728 
     | 
    
         
            +
                      }
         
     | 
| 
      
 24729 
     | 
    
         
            +
                      const tablesReferencingCurrent = [];
         
     | 
| 
      
 24730 
     | 
    
         
            +
                      for (const table4 of Object.values(json2.tables)) {
         
     | 
| 
      
 24731 
     | 
    
         
            +
                        const tablesRefs = Object.values(json2.tables[table4.name].foreignKeys).filter((t2) => SQLiteSquasher.unsquashPushFK(t2).tableTo === tableName).map((it) => SQLiteSquasher.unsquashPushFK(it).tableFrom);
         
     | 
| 
      
 24732 
     | 
    
         
            +
                        tablesReferencingCurrent.push(...tablesRefs);
         
     | 
| 
      
 24733 
     | 
    
         
            +
                      }
         
     | 
| 
      
 24734 
     | 
    
         
            +
                      if (!tablesReferencingCurrent.length) {
         
     | 
| 
      
 24735 
     | 
    
         
            +
                        statementsToExecute.push(..._moveDataStatements(tableName, json2, dataLoss));
         
     | 
| 
      
 24736 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 24737 
     | 
    
         
            +
                      }
         
     | 
| 
      
 24738 
     | 
    
         
            +
                      const [{ foreign_keys: pragmaState }] = await connection.query(`PRAGMA foreign_keys;`);
         
     | 
| 
      
 24739 
     | 
    
         
            +
                      if (pragmaState) {
         
     | 
| 
      
 24740 
     | 
    
         
            +
                        statementsToExecute.push(`PRAGMA foreign_keys=OFF;`);
         
     | 
| 
      
 24741 
     | 
    
         
            +
                      }
         
     | 
| 
      
 24742 
     | 
    
         
            +
                      statementsToExecute.push(..._moveDataStatements(tableName, json2, dataLoss));
         
     | 
| 
      
 24743 
     | 
    
         
            +
                      if (pragmaState) {
         
     | 
| 
      
 24744 
     | 
    
         
            +
                        statementsToExecute.push(`PRAGMA foreign_keys=ON;`);
         
     | 
| 
      
 24745 
     | 
    
         
            +
                      }
         
     | 
| 
      
 24746 
     | 
    
         
            +
                    } else {
         
     | 
| 
      
 24747 
     | 
    
         
            +
                      const fromJsonStatement = fromJson([statement], "sqlite", "push");
         
     | 
| 
      
 24748 
     | 
    
         
            +
                      statementsToExecute.push(
         
     | 
| 
      
 24749 
     | 
    
         
            +
                        ...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
         
     | 
| 
      
 24750 
     | 
    
         
            +
                      );
         
     | 
| 
      
 24751 
     | 
    
         
            +
                    }
         
     | 
| 
      
 24752 
     | 
    
         
            +
                  }
         
     | 
| 
      
 24753 
     | 
    
         
            +
                  return {
         
     | 
| 
      
 24754 
     | 
    
         
            +
                    statementsToExecute,
         
     | 
| 
      
 24755 
     | 
    
         
            +
                    shouldAskForApprove,
         
     | 
| 
      
 24756 
     | 
    
         
            +
                    infoToPrint,
         
     | 
| 
      
 24757 
     | 
    
         
            +
                    columnsToRemove: [...new Set(columnsToRemove)],
         
     | 
| 
      
 24758 
     | 
    
         
            +
                    schemasToRemove: [...new Set(schemasToRemove)],
         
     | 
| 
      
 24759 
     | 
    
         
            +
                    tablesToTruncate: [...new Set(tablesToTruncate)],
         
     | 
| 
      
 24760 
     | 
    
         
            +
                    tablesToRemove: [...new Set(tablesToRemove)]
         
     | 
| 
      
 24761 
     | 
    
         
            +
                  };
         
     | 
| 
      
 24762 
     | 
    
         
            +
                };
         
     | 
| 
      
 24763 
     | 
    
         
            +
              }
         
     | 
| 
      
 24764 
     | 
    
         
            +
            });
         
     | 
| 
      
 24765 
     | 
    
         
            +
             
     | 
| 
       24621 
24766 
     | 
    
         
             
            // src/jsonStatements.ts
         
     | 
| 
       24622 
     | 
    
         
            -
            var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql;
         
     | 
| 
      
 24767 
     | 
    
         
            +
            var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareLibSQLCreateReferencesJson, prepareDropReferencesJson, prepareLibSQLDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql;
         
     | 
| 
       24623 
24768 
     | 
    
         
             
            var init_jsonStatements = __esm({
         
     | 
| 
       24624 
24769 
     | 
    
         
             
              "src/jsonStatements.ts"() {
         
     | 
| 
       24625 
24770 
     | 
    
         
             
                "use strict";
         
     | 
| 
       24626 
24771 
     | 
    
         
             
                init_source();
         
     | 
| 
      
 24772 
     | 
    
         
            +
                init_sqlitePushUtils();
         
     | 
| 
       24627 
24773 
     | 
    
         
             
                init_views();
         
     | 
| 
       24628 
24774 
     | 
    
         
             
                init_mysqlSchema();
         
     | 
| 
       24629 
24775 
     | 
    
         
             
                init_pgSchema();
         
     | 
| 
         @@ -25397,7 +25543,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25397 
25543 
     | 
    
         
             
                  return [...dropPkStatements, ...setPkStatements, ...statements];
         
     | 
| 
       25398 
25544 
     | 
    
         
             
                };
         
     | 
| 
       25399 
25545 
     | 
    
         
             
                prepareSqliteAlterColumns = (tableName, schema5, columns, json2) => {
         
     | 
| 
       25400 
     | 
    
         
            -
                  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
         
     | 
| 
      
 25546 
     | 
    
         
            +
                  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
         
     | 
| 
       25401 
25547 
     | 
    
         
             
                  let statements = [];
         
     | 
| 
       25402 
25548 
     | 
    
         
             
                  let dropPkStatements = [];
         
     | 
| 
       25403 
25549 
     | 
    
         
             
                  let setPkStatements = [];
         
     | 
| 
         @@ -25411,6 +25557,49 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25411 
25557 
     | 
    
         
             
                    const columnPk = json2.tables[tableName].columns[columnName].primaryKey;
         
     | 
| 
       25412 
25558 
     | 
    
         
             
                    const columnGenerated = json2.tables[tableName].columns[columnName].generated;
         
     | 
| 
       25413 
25559 
     | 
    
         
             
                    const compositePk = json2.tables[tableName].compositePrimaryKeys[`${tableName}_${columnName}`];
         
     | 
| 
      
 25560 
     | 
    
         
            +
                    if (((_a = column7.autoincrement) == null ? void 0 : _a.type) === "added") {
         
     | 
| 
      
 25561 
     | 
    
         
            +
                      statements.push({
         
     | 
| 
      
 25562 
     | 
    
         
            +
                        type: "alter_table_alter_column_set_autoincrement",
         
     | 
| 
      
 25563 
     | 
    
         
            +
                        tableName,
         
     | 
| 
      
 25564 
     | 
    
         
            +
                        columnName,
         
     | 
| 
      
 25565 
     | 
    
         
            +
                        schema: schema5,
         
     | 
| 
      
 25566 
     | 
    
         
            +
                        newDataType: columnType,
         
     | 
| 
      
 25567 
     | 
    
         
            +
                        columnDefault,
         
     | 
| 
      
 25568 
     | 
    
         
            +
                        columnOnUpdate,
         
     | 
| 
      
 25569 
     | 
    
         
            +
                        columnNotNull,
         
     | 
| 
      
 25570 
     | 
    
         
            +
                        columnAutoIncrement,
         
     | 
| 
      
 25571 
     | 
    
         
            +
                        columnPk
         
     | 
| 
      
 25572 
     | 
    
         
            +
                      });
         
     | 
| 
      
 25573 
     | 
    
         
            +
                    }
         
     | 
| 
      
 25574 
     | 
    
         
            +
                    if (((_b = column7.autoincrement) == null ? void 0 : _b.type) === "changed") {
         
     | 
| 
      
 25575 
     | 
    
         
            +
                      const type = column7.autoincrement.new ? "alter_table_alter_column_set_autoincrement" : "alter_table_alter_column_drop_autoincrement";
         
     | 
| 
      
 25576 
     | 
    
         
            +
                      statements.push({
         
     | 
| 
      
 25577 
     | 
    
         
            +
                        type,
         
     | 
| 
      
 25578 
     | 
    
         
            +
                        tableName,
         
     | 
| 
      
 25579 
     | 
    
         
            +
                        columnName,
         
     | 
| 
      
 25580 
     | 
    
         
            +
                        schema: schema5,
         
     | 
| 
      
 25581 
     | 
    
         
            +
                        newDataType: columnType,
         
     | 
| 
      
 25582 
     | 
    
         
            +
                        columnDefault,
         
     | 
| 
      
 25583 
     | 
    
         
            +
                        columnOnUpdate,
         
     | 
| 
      
 25584 
     | 
    
         
            +
                        columnNotNull,
         
     | 
| 
      
 25585 
     | 
    
         
            +
                        columnAutoIncrement,
         
     | 
| 
      
 25586 
     | 
    
         
            +
                        columnPk
         
     | 
| 
      
 25587 
     | 
    
         
            +
                      });
         
     | 
| 
      
 25588 
     | 
    
         
            +
                    }
         
     | 
| 
      
 25589 
     | 
    
         
            +
                    if (((_c = column7.autoincrement) == null ? void 0 : _c.type) === "deleted") {
         
     | 
| 
      
 25590 
     | 
    
         
            +
                      statements.push({
         
     | 
| 
      
 25591 
     | 
    
         
            +
                        type: "alter_table_alter_column_drop_autoincrement",
         
     | 
| 
      
 25592 
     | 
    
         
            +
                        tableName,
         
     | 
| 
      
 25593 
     | 
    
         
            +
                        columnName,
         
     | 
| 
      
 25594 
     | 
    
         
            +
                        schema: schema5,
         
     | 
| 
      
 25595 
     | 
    
         
            +
                        newDataType: columnType,
         
     | 
| 
      
 25596 
     | 
    
         
            +
                        columnDefault,
         
     | 
| 
      
 25597 
     | 
    
         
            +
                        columnOnUpdate,
         
     | 
| 
      
 25598 
     | 
    
         
            +
                        columnNotNull,
         
     | 
| 
      
 25599 
     | 
    
         
            +
                        columnAutoIncrement,
         
     | 
| 
      
 25600 
     | 
    
         
            +
                        columnPk
         
     | 
| 
      
 25601 
     | 
    
         
            +
                      });
         
     | 
| 
      
 25602 
     | 
    
         
            +
                    }
         
     | 
| 
       25414 
25603 
     | 
    
         
             
                    if (typeof column7.name !== "string") {
         
     | 
| 
       25415 
25604 
     | 
    
         
             
                      statements.push({
         
     | 
| 
       25416 
25605 
     | 
    
         
             
                        type: "alter_table_rename_column",
         
     | 
| 
         @@ -25420,7 +25609,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25420 
25609 
     | 
    
         
             
                        schema: schema5
         
     | 
| 
       25421 
25610 
     | 
    
         
             
                      });
         
     | 
| 
       25422 
25611 
     | 
    
         
             
                    }
         
     | 
| 
       25423 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25612 
     | 
    
         
            +
                    if (((_d = column7.type) == null ? void 0 : _d.type) === "changed") {
         
     | 
| 
       25424 
25613 
     | 
    
         
             
                      statements.push({
         
     | 
| 
       25425 
25614 
     | 
    
         
             
                        type: "alter_table_alter_column_set_type",
         
     | 
| 
       25426 
25615 
     | 
    
         
             
                        tableName,
         
     | 
| 
         @@ -25435,7 +25624,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25435 
25624 
     | 
    
         
             
                        columnPk
         
     | 
| 
       25436 
25625 
     | 
    
         
             
                      });
         
     | 
| 
       25437 
25626 
     | 
    
         
             
                    }
         
     | 
| 
       25438 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25627 
     | 
    
         
            +
                    if (((_e = column7.primaryKey) == null ? void 0 : _e.type) === "deleted" || ((_f = column7.primaryKey) == null ? void 0 : _f.type) === "changed" && !column7.primaryKey.new && typeof compositePk === "undefined") {
         
     | 
| 
       25439 
25628 
     | 
    
         
             
                      dropPkStatements.push({
         
     | 
| 
       25440 
25629 
     | 
    
         
             
                        ////
         
     | 
| 
       25441 
25630 
     | 
    
         
             
                        type: "alter_table_alter_column_drop_pk",
         
     | 
| 
         @@ -25444,7 +25633,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25444 
25633 
     | 
    
         
             
                        schema: schema5
         
     | 
| 
       25445 
25634 
     | 
    
         
             
                      });
         
     | 
| 
       25446 
25635 
     | 
    
         
             
                    }
         
     | 
| 
       25447 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25636 
     | 
    
         
            +
                    if (((_g = column7.default) == null ? void 0 : _g.type) === "added") {
         
     | 
| 
       25448 
25637 
     | 
    
         
             
                      statements.push({
         
     | 
| 
       25449 
25638 
     | 
    
         
             
                        type: "alter_table_alter_column_set_default",
         
     | 
| 
       25450 
25639 
     | 
    
         
             
                        tableName,
         
     | 
| 
         @@ -25458,7 +25647,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25458 
25647 
     | 
    
         
             
                        columnPk
         
     | 
| 
       25459 
25648 
     | 
    
         
             
                      });
         
     | 
| 
       25460 
25649 
     | 
    
         
             
                    }
         
     | 
| 
       25461 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25650 
     | 
    
         
            +
                    if (((_h = column7.default) == null ? void 0 : _h.type) === "changed") {
         
     | 
| 
       25462 
25651 
     | 
    
         
             
                      statements.push({
         
     | 
| 
       25463 
25652 
     | 
    
         
             
                        type: "alter_table_alter_column_set_default",
         
     | 
| 
       25464 
25653 
     | 
    
         
             
                        tableName,
         
     | 
| 
         @@ -25473,7 +25662,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25473 
25662 
     | 
    
         
             
                        columnPk
         
     | 
| 
       25474 
25663 
     | 
    
         
             
                      });
         
     | 
| 
       25475 
25664 
     | 
    
         
             
                    }
         
     | 
| 
       25476 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25665 
     | 
    
         
            +
                    if (((_i = column7.default) == null ? void 0 : _i.type) === "deleted") {
         
     | 
| 
       25477 
25666 
     | 
    
         
             
                      statements.push({
         
     | 
| 
       25478 
25667 
     | 
    
         
             
                        type: "alter_table_alter_column_drop_default",
         
     | 
| 
       25479 
25668 
     | 
    
         
             
                        tableName,
         
     | 
| 
         @@ -25487,7 +25676,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25487 
25676 
     | 
    
         
             
                        columnPk
         
     | 
| 
       25488 
25677 
     | 
    
         
             
                      });
         
     | 
| 
       25489 
25678 
     | 
    
         
             
                    }
         
     | 
| 
       25490 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25679 
     | 
    
         
            +
                    if (((_j = column7.notNull) == null ? void 0 : _j.type) === "added") {
         
     | 
| 
       25491 
25680 
     | 
    
         
             
                      statements.push({
         
     | 
| 
       25492 
25681 
     | 
    
         
             
                        type: "alter_table_alter_column_set_notnull",
         
     | 
| 
       25493 
25682 
     | 
    
         
             
                        tableName,
         
     | 
| 
         @@ -25501,7 +25690,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25501 
25690 
     | 
    
         
             
                        columnPk
         
     | 
| 
       25502 
25691 
     | 
    
         
             
                      });
         
     | 
| 
       25503 
25692 
     | 
    
         
             
                    }
         
     | 
| 
       25504 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25693 
     | 
    
         
            +
                    if (((_k = column7.notNull) == null ? void 0 : _k.type) === "changed") {
         
     | 
| 
       25505 
25694 
     | 
    
         
             
                      const type = column7.notNull.new ? "alter_table_alter_column_set_notnull" : "alter_table_alter_column_drop_notnull";
         
     | 
| 
       25506 
25695 
     | 
    
         
             
                      statements.push({
         
     | 
| 
       25507 
25696 
     | 
    
         
             
                        type,
         
     | 
| 
         @@ -25516,7 +25705,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25516 
25705 
     | 
    
         
             
                        columnPk
         
     | 
| 
       25517 
25706 
     | 
    
         
             
                      });
         
     | 
| 
       25518 
25707 
     | 
    
         
             
                    }
         
     | 
| 
       25519 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25708 
     | 
    
         
            +
                    if (((_l = column7.notNull) == null ? void 0 : _l.type) === "deleted") {
         
     | 
| 
       25520 
25709 
     | 
    
         
             
                      statements.push({
         
     | 
| 
       25521 
25710 
     | 
    
         
             
                        type: "alter_table_alter_column_drop_notnull",
         
     | 
| 
       25522 
25711 
     | 
    
         
             
                        tableName,
         
     | 
| 
         @@ -25530,7 +25719,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25530 
25719 
     | 
    
         
             
                        columnPk
         
     | 
| 
       25531 
25720 
     | 
    
         
             
                      });
         
     | 
| 
       25532 
25721 
     | 
    
         
             
                    }
         
     | 
| 
       25533 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25722 
     | 
    
         
            +
                    if (((_m = column7.generated) == null ? void 0 : _m.type) === "added") {
         
     | 
| 
       25534 
25723 
     | 
    
         
             
                      if ((columnGenerated == null ? void 0 : columnGenerated.type) === "virtual") {
         
     | 
| 
       25535 
25724 
     | 
    
         
             
                        statements.push({
         
     | 
| 
       25536 
25725 
     | 
    
         
             
                          type: "alter_table_alter_column_set_generated",
         
     | 
| 
         @@ -25551,7 +25740,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25551 
25740 
     | 
    
         
             
                        );
         
     | 
| 
       25552 
25741 
     | 
    
         
             
                      }
         
     | 
| 
       25553 
25742 
     | 
    
         
             
                    }
         
     | 
| 
       25554 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25743 
     | 
    
         
            +
                    if (((_n = column7.generated) == null ? void 0 : _n.type) === "changed") {
         
     | 
| 
       25555 
25744 
     | 
    
         
             
                      if ((columnGenerated == null ? void 0 : columnGenerated.type) === "virtual") {
         
     | 
| 
       25556 
25745 
     | 
    
         
             
                        statements.push({
         
     | 
| 
       25557 
25746 
     | 
    
         
             
                          type: "alter_table_alter_column_alter_generated",
         
     | 
| 
         @@ -25572,7 +25761,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25572 
25761 
     | 
    
         
             
                        );
         
     | 
| 
       25573 
25762 
     | 
    
         
             
                      }
         
     | 
| 
       25574 
25763 
     | 
    
         
             
                    }
         
     | 
| 
       25575 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25764 
     | 
    
         
            +
                    if (((_o = column7.generated) == null ? void 0 : _o.type) === "deleted") {
         
     | 
| 
       25576 
25765 
     | 
    
         
             
                      statements.push({
         
     | 
| 
       25577 
25766 
     | 
    
         
             
                        type: "alter_table_alter_column_drop_generated",
         
     | 
| 
       25578 
25767 
     | 
    
         
             
                        tableName,
         
     | 
| 
         @@ -25587,7 +25776,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25587 
25776 
     | 
    
         
             
                        columnGenerated
         
     | 
| 
       25588 
25777 
     | 
    
         
             
                      });
         
     | 
| 
       25589 
25778 
     | 
    
         
             
                    }
         
     | 
| 
       25590 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25779 
     | 
    
         
            +
                    if (((_p = column7.primaryKey) == null ? void 0 : _p.type) === "added" || ((_q = column7.primaryKey) == null ? void 0 : _q.type) === "changed" && column7.primaryKey.new) {
         
     | 
| 
       25591 
25780 
     | 
    
         
             
                      const wasAutoincrement = statements.filter(
         
     | 
| 
       25592 
25781 
     | 
    
         
             
                        (it) => it.type === "alter_table_alter_column_set_autoincrement"
         
     | 
| 
       25593 
25782 
     | 
    
         
             
                      );
         
     | 
| 
         @@ -25600,7 +25789,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25600 
25789 
     | 
    
         
             
                        });
         
     | 
| 
       25601 
25790 
     | 
    
         
             
                      }
         
     | 
| 
       25602 
25791 
     | 
    
         
             
                    }
         
     | 
| 
       25603 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25792 
     | 
    
         
            +
                    if (((_r = column7.onUpdate) == null ? void 0 : _r.type) === "added") {
         
     | 
| 
       25604 
25793 
     | 
    
         
             
                      statements.push({
         
     | 
| 
       25605 
25794 
     | 
    
         
             
                        type: "alter_table_alter_column_set_on_update",
         
     | 
| 
       25606 
25795 
     | 
    
         
             
                        tableName,
         
     | 
| 
         @@ -25614,7 +25803,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25614 
25803 
     | 
    
         
             
                        columnPk
         
     | 
| 
       25615 
25804 
     | 
    
         
             
                      });
         
     | 
| 
       25616 
25805 
     | 
    
         
             
                    }
         
     | 
| 
       25617 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25806 
     | 
    
         
            +
                    if (((_s = column7.onUpdate) == null ? void 0 : _s.type) === "deleted") {
         
     | 
| 
       25618 
25807 
     | 
    
         
             
                      statements.push({
         
     | 
| 
       25619 
25808 
     | 
    
         
             
                        type: "alter_table_alter_column_drop_on_update",
         
     | 
| 
       25620 
25809 
     | 
    
         
             
                        tableName,
         
     | 
| 
         @@ -25674,6 +25863,37 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25674 
25863 
     | 
    
         
             
                    };
         
     | 
| 
       25675 
25864 
     | 
    
         
             
                  });
         
     | 
| 
       25676 
25865 
     | 
    
         
             
                };
         
     | 
| 
      
 25866 
     | 
    
         
            +
                prepareLibSQLCreateReferencesJson = (tableName, schema5, foreignKeys, json2, action) => {
         
     | 
| 
      
 25867 
     | 
    
         
            +
                  return Object.values(foreignKeys).map((fkData) => {
         
     | 
| 
      
 25868 
     | 
    
         
            +
                    const { columnsFrom, tableFrom, columnsTo } = action === "push" ? SQLiteSquasher.unsquashPushFK(fkData) : SQLiteSquasher.unsquashFK(fkData);
         
     | 
| 
      
 25869 
     | 
    
         
            +
                    let isMulticolumn = false;
         
     | 
| 
      
 25870 
     | 
    
         
            +
                    if (columnsFrom.length > 1 || columnsTo.length > 1) {
         
     | 
| 
      
 25871 
     | 
    
         
            +
                      isMulticolumn = true;
         
     | 
| 
      
 25872 
     | 
    
         
            +
                      return {
         
     | 
| 
      
 25873 
     | 
    
         
            +
                        type: "create_reference",
         
     | 
| 
      
 25874 
     | 
    
         
            +
                        tableName,
         
     | 
| 
      
 25875 
     | 
    
         
            +
                        data: fkData,
         
     | 
| 
      
 25876 
     | 
    
         
            +
                        schema: schema5,
         
     | 
| 
      
 25877 
     | 
    
         
            +
                        isMulticolumn
         
     | 
| 
      
 25878 
     | 
    
         
            +
                      };
         
     | 
| 
      
 25879 
     | 
    
         
            +
                    }
         
     | 
| 
      
 25880 
     | 
    
         
            +
                    const columnFrom = columnsFrom[0];
         
     | 
| 
      
 25881 
     | 
    
         
            +
                    const {
         
     | 
| 
      
 25882 
     | 
    
         
            +
                      notNull: columnNotNull,
         
     | 
| 
      
 25883 
     | 
    
         
            +
                      default: columnDefault,
         
     | 
| 
      
 25884 
     | 
    
         
            +
                      type: columnType
         
     | 
| 
      
 25885 
     | 
    
         
            +
                    } = json2.tables[tableFrom].columns[columnFrom];
         
     | 
| 
      
 25886 
     | 
    
         
            +
                    return {
         
     | 
| 
      
 25887 
     | 
    
         
            +
                      type: "create_reference",
         
     | 
| 
      
 25888 
     | 
    
         
            +
                      tableName,
         
     | 
| 
      
 25889 
     | 
    
         
            +
                      data: fkData,
         
     | 
| 
      
 25890 
     | 
    
         
            +
                      schema: schema5,
         
     | 
| 
      
 25891 
     | 
    
         
            +
                      columnNotNull,
         
     | 
| 
      
 25892 
     | 
    
         
            +
                      columnDefault,
         
     | 
| 
      
 25893 
     | 
    
         
            +
                      columnType
         
     | 
| 
      
 25894 
     | 
    
         
            +
                    };
         
     | 
| 
      
 25895 
     | 
    
         
            +
                  });
         
     | 
| 
      
 25896 
     | 
    
         
            +
                };
         
     | 
| 
       25677 
25897 
     | 
    
         
             
                prepareDropReferencesJson = (tableName, schema5, foreignKeys) => {
         
     | 
| 
       25678 
25898 
     | 
    
         
             
                  return Object.values(foreignKeys).map((fkData) => {
         
     | 
| 
       25679 
25899 
     | 
    
         
             
                    return {
         
     | 
| 
         @@ -25684,6 +25904,54 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25684 
25904 
     | 
    
         
             
                    };
         
     | 
| 
       25685 
25905 
     | 
    
         
             
                  });
         
     | 
| 
       25686 
25906 
     | 
    
         
             
                };
         
     | 
| 
      
 25907 
     | 
    
         
            +
                prepareLibSQLDropReferencesJson = (tableName, schema5, foreignKeys, json2, meta, action) => {
         
     | 
| 
      
 25908 
     | 
    
         
            +
                  const statements = Object.values(foreignKeys).map((fkData) => {
         
     | 
| 
      
 25909 
     | 
    
         
            +
                    const { columnsFrom, tableFrom, columnsTo, name, tableTo, onDelete, onUpdate } = action === "push" ? SQLiteSquasher.unsquashPushFK(fkData) : SQLiteSquasher.unsquashFK(fkData);
         
     | 
| 
      
 25910 
     | 
    
         
            +
                    const keys = Object.keys(json2.tables[tableName].columns);
         
     | 
| 
      
 25911 
     | 
    
         
            +
                    const filtered = columnsFrom.filter((it) => keys.includes(it));
         
     | 
| 
      
 25912 
     | 
    
         
            +
                    const fullDrop = filtered.length === 0;
         
     | 
| 
      
 25913 
     | 
    
         
            +
                    if (fullDrop)
         
     | 
| 
      
 25914 
     | 
    
         
            +
                      return;
         
     | 
| 
      
 25915 
     | 
    
         
            +
                    let isMulticolumn = false;
         
     | 
| 
      
 25916 
     | 
    
         
            +
                    if (columnsFrom.length > 1 || columnsTo.length > 1) {
         
     | 
| 
      
 25917 
     | 
    
         
            +
                      isMulticolumn = true;
         
     | 
| 
      
 25918 
     | 
    
         
            +
                      return {
         
     | 
| 
      
 25919 
     | 
    
         
            +
                        type: "delete_reference",
         
     | 
| 
      
 25920 
     | 
    
         
            +
                        tableName,
         
     | 
| 
      
 25921 
     | 
    
         
            +
                        data: fkData,
         
     | 
| 
      
 25922 
     | 
    
         
            +
                        schema: schema5,
         
     | 
| 
      
 25923 
     | 
    
         
            +
                        isMulticolumn
         
     | 
| 
      
 25924 
     | 
    
         
            +
                      };
         
     | 
| 
      
 25925 
     | 
    
         
            +
                    }
         
     | 
| 
      
 25926 
     | 
    
         
            +
                    const columnFrom = columnsFrom[0];
         
     | 
| 
      
 25927 
     | 
    
         
            +
                    const newTableName = getNewTableName(tableFrom, meta);
         
     | 
| 
      
 25928 
     | 
    
         
            +
                    const {
         
     | 
| 
      
 25929 
     | 
    
         
            +
                      notNull: columnNotNull,
         
     | 
| 
      
 25930 
     | 
    
         
            +
                      default: columnDefault,
         
     | 
| 
      
 25931 
     | 
    
         
            +
                      type: columnType
         
     | 
| 
      
 25932 
     | 
    
         
            +
                    } = json2.tables[newTableName].columns[columnFrom];
         
     | 
| 
      
 25933 
     | 
    
         
            +
                    const fkToSquash = {
         
     | 
| 
      
 25934 
     | 
    
         
            +
                      columnsFrom,
         
     | 
| 
      
 25935 
     | 
    
         
            +
                      columnsTo,
         
     | 
| 
      
 25936 
     | 
    
         
            +
                      name,
         
     | 
| 
      
 25937 
     | 
    
         
            +
                      tableFrom: newTableName,
         
     | 
| 
      
 25938 
     | 
    
         
            +
                      tableTo,
         
     | 
| 
      
 25939 
     | 
    
         
            +
                      onDelete,
         
     | 
| 
      
 25940 
     | 
    
         
            +
                      onUpdate
         
     | 
| 
      
 25941 
     | 
    
         
            +
                    };
         
     | 
| 
      
 25942 
     | 
    
         
            +
                    const foreignKey = action === "push" ? SQLiteSquasher.squashPushFK(fkToSquash) : SQLiteSquasher.squashFK(fkToSquash);
         
     | 
| 
      
 25943 
     | 
    
         
            +
                    return {
         
     | 
| 
      
 25944 
     | 
    
         
            +
                      type: "delete_reference",
         
     | 
| 
      
 25945 
     | 
    
         
            +
                      tableName,
         
     | 
| 
      
 25946 
     | 
    
         
            +
                      data: foreignKey,
         
     | 
| 
      
 25947 
     | 
    
         
            +
                      schema: schema5,
         
     | 
| 
      
 25948 
     | 
    
         
            +
                      columnNotNull,
         
     | 
| 
      
 25949 
     | 
    
         
            +
                      columnDefault,
         
     | 
| 
      
 25950 
     | 
    
         
            +
                      columnType
         
     | 
| 
      
 25951 
     | 
    
         
            +
                    };
         
     | 
| 
      
 25952 
     | 
    
         
            +
                  });
         
     | 
| 
      
 25953 
     | 
    
         
            +
                  return statements.filter((it) => it);
         
     | 
| 
      
 25954 
     | 
    
         
            +
                };
         
     | 
| 
       25687 
25955 
     | 
    
         
             
                prepareAlterReferencesJson = (tableName, schema5, foreignKeys) => {
         
     | 
| 
       25688 
25956 
     | 
    
         
             
                  const stmts = [];
         
     | 
| 
       25689 
25957 
     | 
    
         
             
                  Object.values(foreignKeys).map((val2) => {
         
     | 
| 
         @@ -25838,8 +26106,289 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25838 
26106 
     | 
    
         
             
              }
         
     | 
| 
       25839 
26107 
     | 
    
         
             
            });
         
     | 
| 
       25840 
26108 
     | 
    
         | 
| 
      
 26109 
     | 
    
         
            +
            // src/statementCombiner.ts
         
     | 
| 
      
 26110 
     | 
    
         
            +
            var prepareLibSQLRecreateTable, prepareSQLiteRecreateTable, libSQLCombineStatements, sqliteCombineStatements;
         
     | 
| 
      
 26111 
     | 
    
         
            +
            var init_statementCombiner = __esm({
         
     | 
| 
      
 26112 
     | 
    
         
            +
              "src/statementCombiner.ts"() {
         
     | 
| 
      
 26113 
     | 
    
         
            +
                "use strict";
         
     | 
| 
      
 26114 
     | 
    
         
            +
                init_jsonStatements();
         
     | 
| 
      
 26115 
     | 
    
         
            +
                init_sqliteSchema();
         
     | 
| 
      
 26116 
     | 
    
         
            +
                prepareLibSQLRecreateTable = (table4, action) => {
         
     | 
| 
      
 26117 
     | 
    
         
            +
                  const { name, columns, uniqueConstraints, indexes } = table4;
         
     | 
| 
      
 26118 
     | 
    
         
            +
                  const composites = Object.values(table4.compositePrimaryKeys).map(
         
     | 
| 
      
 26119 
     | 
    
         
            +
                    (it) => SQLiteSquasher.unsquashPK(it)
         
     | 
| 
      
 26120 
     | 
    
         
            +
                  );
         
     | 
| 
      
 26121 
     | 
    
         
            +
                  const references2 = Object.values(table4.foreignKeys);
         
     | 
| 
      
 26122 
     | 
    
         
            +
                  const fks = references2.map(
         
     | 
| 
      
 26123 
     | 
    
         
            +
                    (it) => action === "push" ? SQLiteSquasher.unsquashPushFK(it) : SQLiteSquasher.unsquashFK(it)
         
     | 
| 
      
 26124 
     | 
    
         
            +
                  );
         
     | 
| 
      
 26125 
     | 
    
         
            +
                  const statements = [
         
     | 
| 
      
 26126 
     | 
    
         
            +
                    {
         
     | 
| 
      
 26127 
     | 
    
         
            +
                      type: "recreate_table",
         
     | 
| 
      
 26128 
     | 
    
         
            +
                      tableName: name,
         
     | 
| 
      
 26129 
     | 
    
         
            +
                      columns: Object.values(columns),
         
     | 
| 
      
 26130 
     | 
    
         
            +
                      compositePKs: composites,
         
     | 
| 
      
 26131 
     | 
    
         
            +
                      referenceData: fks,
         
     | 
| 
      
 26132 
     | 
    
         
            +
                      uniqueConstraints: Object.values(uniqueConstraints)
         
     | 
| 
      
 26133 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26134 
     | 
    
         
            +
                  ];
         
     | 
| 
      
 26135 
     | 
    
         
            +
                  if (Object.keys(indexes).length) {
         
     | 
| 
      
 26136 
     | 
    
         
            +
                    statements.push(...prepareCreateIndexesJson(name, "", indexes));
         
     | 
| 
      
 26137 
     | 
    
         
            +
                  }
         
     | 
| 
      
 26138 
     | 
    
         
            +
                  return statements;
         
     | 
| 
      
 26139 
     | 
    
         
            +
                };
         
     | 
| 
      
 26140 
     | 
    
         
            +
                prepareSQLiteRecreateTable = (table4, action) => {
         
     | 
| 
      
 26141 
     | 
    
         
            +
                  const { name, columns, uniqueConstraints, indexes } = table4;
         
     | 
| 
      
 26142 
     | 
    
         
            +
                  const composites = Object.values(table4.compositePrimaryKeys).map(
         
     | 
| 
      
 26143 
     | 
    
         
            +
                    (it) => SQLiteSquasher.unsquashPK(it)
         
     | 
| 
      
 26144 
     | 
    
         
            +
                  );
         
     | 
| 
      
 26145 
     | 
    
         
            +
                  const references2 = Object.values(table4.foreignKeys);
         
     | 
| 
      
 26146 
     | 
    
         
            +
                  const fks = references2.map(
         
     | 
| 
      
 26147 
     | 
    
         
            +
                    (it) => action === "push" ? SQLiteSquasher.unsquashPushFK(it) : SQLiteSquasher.unsquashFK(it)
         
     | 
| 
      
 26148 
     | 
    
         
            +
                  );
         
     | 
| 
      
 26149 
     | 
    
         
            +
                  const statements = [
         
     | 
| 
      
 26150 
     | 
    
         
            +
                    {
         
     | 
| 
      
 26151 
     | 
    
         
            +
                      type: "recreate_table",
         
     | 
| 
      
 26152 
     | 
    
         
            +
                      tableName: name,
         
     | 
| 
      
 26153 
     | 
    
         
            +
                      columns: Object.values(columns),
         
     | 
| 
      
 26154 
     | 
    
         
            +
                      compositePKs: composites,
         
     | 
| 
      
 26155 
     | 
    
         
            +
                      referenceData: fks,
         
     | 
| 
      
 26156 
     | 
    
         
            +
                      uniqueConstraints: Object.values(uniqueConstraints)
         
     | 
| 
      
 26157 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26158 
     | 
    
         
            +
                  ];
         
     | 
| 
      
 26159 
     | 
    
         
            +
                  if (Object.keys(indexes).length) {
         
     | 
| 
      
 26160 
     | 
    
         
            +
                    statements.push(...prepareCreateIndexesJson(name, "", indexes));
         
     | 
| 
      
 26161 
     | 
    
         
            +
                  }
         
     | 
| 
      
 26162 
     | 
    
         
            +
                  return statements;
         
     | 
| 
      
 26163 
     | 
    
         
            +
                };
         
     | 
| 
      
 26164 
     | 
    
         
            +
                libSQLCombineStatements = (statements, json2, action) => {
         
     | 
| 
      
 26165 
     | 
    
         
            +
                  const newStatements = {};
         
     | 
| 
      
 26166 
     | 
    
         
            +
                  for (const statement of statements) {
         
     | 
| 
      
 26167 
     | 
    
         
            +
                    if (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" || statement.type === "create_composite_pk" || statement.type === "alter_composite_pk" || statement.type === "delete_composite_pk") {
         
     | 
| 
      
 26168 
     | 
    
         
            +
                      const tableName2 = statement.tableName;
         
     | 
| 
      
 26169 
     | 
    
         
            +
                      const statementsForTable2 = newStatements[tableName2];
         
     | 
| 
      
 26170 
     | 
    
         
            +
                      if (!statementsForTable2) {
         
     | 
| 
      
 26171 
     | 
    
         
            +
                        newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26172 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26173 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26174 
     | 
    
         
            +
                      if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26175 
     | 
    
         
            +
                        const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         
     | 
| 
      
 26176 
     | 
    
         
            +
                        const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26177 
     | 
    
         
            +
                        if (wasRename) {
         
     | 
| 
      
 26178 
     | 
    
         
            +
                          newStatements[tableName2].push(...preparedStatements);
         
     | 
| 
      
 26179 
     | 
    
         
            +
                        } else {
         
     | 
| 
      
 26180 
     | 
    
         
            +
                          newStatements[tableName2] = preparedStatements;
         
     | 
| 
      
 26181 
     | 
    
         
            +
                        }
         
     | 
| 
      
 26182 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26183 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26184 
     | 
    
         
            +
                      continue;
         
     | 
| 
      
 26185 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26186 
     | 
    
         
            +
                    if (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default") {
         
     | 
| 
      
 26187 
     | 
    
         
            +
                      const { tableName: tableName2, columnName, columnPk } = statement;
         
     | 
| 
      
 26188 
     | 
    
         
            +
                      const columnIsPartOfForeignKey = Object.values(
         
     | 
| 
      
 26189 
     | 
    
         
            +
                        json2.tables[tableName2].foreignKeys
         
     | 
| 
      
 26190 
     | 
    
         
            +
                      ).some((it) => {
         
     | 
| 
      
 26191 
     | 
    
         
            +
                        const unsquashFk = action === "push" ? SQLiteSquasher.unsquashPushFK(it) : SQLiteSquasher.unsquashFK(it);
         
     | 
| 
      
 26192 
     | 
    
         
            +
                        return unsquashFk.columnsFrom.includes(columnName);
         
     | 
| 
      
 26193 
     | 
    
         
            +
                      });
         
     | 
| 
      
 26194 
     | 
    
         
            +
                      const statementsForTable2 = newStatements[tableName2];
         
     | 
| 
      
 26195 
     | 
    
         
            +
                      if (!statementsForTable2 && (columnIsPartOfForeignKey || columnPk)) {
         
     | 
| 
      
 26196 
     | 
    
         
            +
                        newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26197 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26198 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26199 
     | 
    
         
            +
                      if (statementsForTable2 && (columnIsPartOfForeignKey || columnPk)) {
         
     | 
| 
      
 26200 
     | 
    
         
            +
                        if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26201 
     | 
    
         
            +
                          const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         
     | 
| 
      
 26202 
     | 
    
         
            +
                          const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26203 
     | 
    
         
            +
                          if (wasRename) {
         
     | 
| 
      
 26204 
     | 
    
         
            +
                            newStatements[tableName2].push(...preparedStatements);
         
     | 
| 
      
 26205 
     | 
    
         
            +
                          } else {
         
     | 
| 
      
 26206 
     | 
    
         
            +
                            newStatements[tableName2] = preparedStatements;
         
     | 
| 
      
 26207 
     | 
    
         
            +
                          }
         
     | 
| 
      
 26208 
     | 
    
         
            +
                        }
         
     | 
| 
      
 26209 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26210 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26211 
     | 
    
         
            +
                      if (statementsForTable2 && !(columnIsPartOfForeignKey || columnPk)) {
         
     | 
| 
      
 26212 
     | 
    
         
            +
                        if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26213 
     | 
    
         
            +
                          newStatements[tableName2].push(statement);
         
     | 
| 
      
 26214 
     | 
    
         
            +
                        }
         
     | 
| 
      
 26215 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26216 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26217 
     | 
    
         
            +
                      newStatements[tableName2] = [statement];
         
     | 
| 
      
 26218 
     | 
    
         
            +
                      continue;
         
     | 
| 
      
 26219 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26220 
     | 
    
         
            +
                    if (statement.type === "create_reference") {
         
     | 
| 
      
 26221 
     | 
    
         
            +
                      const tableName2 = statement.tableName;
         
     | 
| 
      
 26222 
     | 
    
         
            +
                      const data = action === "push" ? SQLiteSquasher.unsquashPushFK(statement.data) : SQLiteSquasher.unsquashFK(statement.data);
         
     | 
| 
      
 26223 
     | 
    
         
            +
                      const statementsForTable2 = newStatements[tableName2];
         
     | 
| 
      
 26224 
     | 
    
         
            +
                      if (!statementsForTable2) {
         
     | 
| 
      
 26225 
     | 
    
         
            +
                        newStatements[tableName2] = statement.isMulticolumn ? prepareLibSQLRecreateTable(json2.tables[tableName2], action) : [statement];
         
     | 
| 
      
 26226 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26227 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26228 
     | 
    
         
            +
                      if (!statement.isMulticolumn && statementsForTable2.some(
         
     | 
| 
      
 26229 
     | 
    
         
            +
                        (st) => st.type === "sqlite_alter_table_add_column" && st.column.name === data.columnsFrom[0]
         
     | 
| 
      
 26230 
     | 
    
         
            +
                      )) {
         
     | 
| 
      
 26231 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26232 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26233 
     | 
    
         
            +
                      if (statement.isMulticolumn) {
         
     | 
| 
      
 26234 
     | 
    
         
            +
                        if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26235 
     | 
    
         
            +
                          const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         
     | 
| 
      
 26236 
     | 
    
         
            +
                          const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26237 
     | 
    
         
            +
                          if (wasRename) {
         
     | 
| 
      
 26238 
     | 
    
         
            +
                            newStatements[tableName2].push(...preparedStatements);
         
     | 
| 
      
 26239 
     | 
    
         
            +
                          } else {
         
     | 
| 
      
 26240 
     | 
    
         
            +
                            newStatements[tableName2] = preparedStatements;
         
     | 
| 
      
 26241 
     | 
    
         
            +
                          }
         
     | 
| 
      
 26242 
     | 
    
         
            +
                          continue;
         
     | 
| 
      
 26243 
     | 
    
         
            +
                        }
         
     | 
| 
      
 26244 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26245 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26246 
     | 
    
         
            +
                      if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26247 
     | 
    
         
            +
                        newStatements[tableName2].push(statement);
         
     | 
| 
      
 26248 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26249 
     | 
    
         
            +
                      continue;
         
     | 
| 
      
 26250 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26251 
     | 
    
         
            +
                    if (statement.type === "delete_reference") {
         
     | 
| 
      
 26252 
     | 
    
         
            +
                      const tableName2 = statement.tableName;
         
     | 
| 
      
 26253 
     | 
    
         
            +
                      const statementsForTable2 = newStatements[tableName2];
         
     | 
| 
      
 26254 
     | 
    
         
            +
                      if (!statementsForTable2) {
         
     | 
| 
      
 26255 
     | 
    
         
            +
                        newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26256 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26257 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26258 
     | 
    
         
            +
                      if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26259 
     | 
    
         
            +
                        const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         
     | 
| 
      
 26260 
     | 
    
         
            +
                        const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26261 
     | 
    
         
            +
                        if (wasRename) {
         
     | 
| 
      
 26262 
     | 
    
         
            +
                          newStatements[tableName2].push(...preparedStatements);
         
     | 
| 
      
 26263 
     | 
    
         
            +
                        } else {
         
     | 
| 
      
 26264 
     | 
    
         
            +
                          newStatements[tableName2] = preparedStatements;
         
     | 
| 
      
 26265 
     | 
    
         
            +
                        }
         
     | 
| 
      
 26266 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26267 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26268 
     | 
    
         
            +
                      continue;
         
     | 
| 
      
 26269 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26270 
     | 
    
         
            +
                    if (statement.type === "sqlite_alter_table_add_column" && statement.column.primaryKey) {
         
     | 
| 
      
 26271 
     | 
    
         
            +
                      const tableName2 = statement.tableName;
         
     | 
| 
      
 26272 
     | 
    
         
            +
                      const statementsForTable2 = newStatements[tableName2];
         
     | 
| 
      
 26273 
     | 
    
         
            +
                      if (!statementsForTable2) {
         
     | 
| 
      
 26274 
     | 
    
         
            +
                        newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26275 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26276 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26277 
     | 
    
         
            +
                      if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26278 
     | 
    
         
            +
                        const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         
     | 
| 
      
 26279 
     | 
    
         
            +
                        const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26280 
     | 
    
         
            +
                        if (wasRename) {
         
     | 
| 
      
 26281 
     | 
    
         
            +
                          newStatements[tableName2].push(...preparedStatements);
         
     | 
| 
      
 26282 
     | 
    
         
            +
                        } else {
         
     | 
| 
      
 26283 
     | 
    
         
            +
                          newStatements[tableName2] = preparedStatements;
         
     | 
| 
      
 26284 
     | 
    
         
            +
                        }
         
     | 
| 
      
 26285 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26286 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26287 
     | 
    
         
            +
                      continue;
         
     | 
| 
      
 26288 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26289 
     | 
    
         
            +
                    const tableName = statement.type === "rename_table" ? statement.tableNameTo : statement.tableName;
         
     | 
| 
      
 26290 
     | 
    
         
            +
                    const statementsForTable = newStatements[tableName];
         
     | 
| 
      
 26291 
     | 
    
         
            +
                    if (!statementsForTable) {
         
     | 
| 
      
 26292 
     | 
    
         
            +
                      newStatements[tableName] = [statement];
         
     | 
| 
      
 26293 
     | 
    
         
            +
                      continue;
         
     | 
| 
      
 26294 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26295 
     | 
    
         
            +
                    if (!statementsForTable.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26296 
     | 
    
         
            +
                      newStatements[tableName].push(statement);
         
     | 
| 
      
 26297 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26298 
     | 
    
         
            +
                  }
         
     | 
| 
      
 26299 
     | 
    
         
            +
                  const combinedStatements = Object.values(newStatements).flat();
         
     | 
| 
      
 26300 
     | 
    
         
            +
                  const renamedTables = combinedStatements.filter((it) => it.type === "rename_table");
         
     | 
| 
      
 26301 
     | 
    
         
            +
                  const renamedColumns = combinedStatements.filter((it) => it.type === "alter_table_rename_column");
         
     | 
| 
      
 26302 
     | 
    
         
            +
                  const rest = combinedStatements.filter((it) => it.type !== "rename_table" && it.type !== "alter_table_rename_column");
         
     | 
| 
      
 26303 
     | 
    
         
            +
                  return [...renamedTables, ...renamedColumns, ...rest];
         
     | 
| 
      
 26304 
     | 
    
         
            +
                };
         
     | 
| 
      
 26305 
     | 
    
         
            +
                sqliteCombineStatements = (statements, json2, action) => {
         
     | 
| 
      
 26306 
     | 
    
         
            +
                  const newStatements = {};
         
     | 
| 
      
 26307 
     | 
    
         
            +
                  for (const statement of statements) {
         
     | 
| 
      
 26308 
     | 
    
         
            +
                    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" || statement.type === "delete_reference" || statement.type === "alter_reference" || statement.type === "create_composite_pk" || statement.type === "alter_composite_pk" || statement.type === "delete_composite_pk" || statement.type === "create_unique_constraint" || statement.type === "delete_unique_constraint") {
         
     | 
| 
      
 26309 
     | 
    
         
            +
                      const tableName2 = statement.tableName;
         
     | 
| 
      
 26310 
     | 
    
         
            +
                      const statementsForTable2 = newStatements[tableName2];
         
     | 
| 
      
 26311 
     | 
    
         
            +
                      if (!statementsForTable2) {
         
     | 
| 
      
 26312 
     | 
    
         
            +
                        newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26313 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26314 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26315 
     | 
    
         
            +
                      if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26316 
     | 
    
         
            +
                        const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         
     | 
| 
      
 26317 
     | 
    
         
            +
                        const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26318 
     | 
    
         
            +
                        if (wasRename) {
         
     | 
| 
      
 26319 
     | 
    
         
            +
                          newStatements[tableName2].push(...preparedStatements);
         
     | 
| 
      
 26320 
     | 
    
         
            +
                        } else {
         
     | 
| 
      
 26321 
     | 
    
         
            +
                          newStatements[tableName2] = preparedStatements;
         
     | 
| 
      
 26322 
     | 
    
         
            +
                        }
         
     | 
| 
      
 26323 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26324 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26325 
     | 
    
         
            +
                      continue;
         
     | 
| 
      
 26326 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26327 
     | 
    
         
            +
                    if (statement.type === "sqlite_alter_table_add_column" && statement.column.primaryKey) {
         
     | 
| 
      
 26328 
     | 
    
         
            +
                      const tableName2 = statement.tableName;
         
     | 
| 
      
 26329 
     | 
    
         
            +
                      const statementsForTable2 = newStatements[tableName2];
         
     | 
| 
      
 26330 
     | 
    
         
            +
                      if (!statementsForTable2) {
         
     | 
| 
      
 26331 
     | 
    
         
            +
                        newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26332 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26333 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26334 
     | 
    
         
            +
                      if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26335 
     | 
    
         
            +
                        const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         
     | 
| 
      
 26336 
     | 
    
         
            +
                        const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26337 
     | 
    
         
            +
                        if (wasRename) {
         
     | 
| 
      
 26338 
     | 
    
         
            +
                          newStatements[tableName2].push(...preparedStatements);
         
     | 
| 
      
 26339 
     | 
    
         
            +
                        } else {
         
     | 
| 
      
 26340 
     | 
    
         
            +
                          newStatements[tableName2] = preparedStatements;
         
     | 
| 
      
 26341 
     | 
    
         
            +
                        }
         
     | 
| 
      
 26342 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26343 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26344 
     | 
    
         
            +
                      continue;
         
     | 
| 
      
 26345 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26346 
     | 
    
         
            +
                    if (statement.type === "create_reference") {
         
     | 
| 
      
 26347 
     | 
    
         
            +
                      const tableName2 = statement.tableName;
         
     | 
| 
      
 26348 
     | 
    
         
            +
                      const data = action === "push" ? SQLiteSquasher.unsquashPushFK(statement.data) : SQLiteSquasher.unsquashFK(statement.data);
         
     | 
| 
      
 26349 
     | 
    
         
            +
                      const statementsForTable2 = newStatements[tableName2];
         
     | 
| 
      
 26350 
     | 
    
         
            +
                      if (!statementsForTable2) {
         
     | 
| 
      
 26351 
     | 
    
         
            +
                        newStatements[tableName2] = prepareSQLiteRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26352 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26353 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26354 
     | 
    
         
            +
                      if (data.columnsFrom.length === 1 && statementsForTable2.some(
         
     | 
| 
      
 26355 
     | 
    
         
            +
                        (st) => st.type === "sqlite_alter_table_add_column" && st.column.name === data.columnsFrom[0]
         
     | 
| 
      
 26356 
     | 
    
         
            +
                      )) {
         
     | 
| 
      
 26357 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26358 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26359 
     | 
    
         
            +
                      if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26360 
     | 
    
         
            +
                        const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         
     | 
| 
      
 26361 
     | 
    
         
            +
                        const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26362 
     | 
    
         
            +
                        if (wasRename) {
         
     | 
| 
      
 26363 
     | 
    
         
            +
                          newStatements[tableName2].push(...preparedStatements);
         
     | 
| 
      
 26364 
     | 
    
         
            +
                        } else {
         
     | 
| 
      
 26365 
     | 
    
         
            +
                          newStatements[tableName2] = preparedStatements;
         
     | 
| 
      
 26366 
     | 
    
         
            +
                        }
         
     | 
| 
      
 26367 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26368 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26369 
     | 
    
         
            +
                      continue;
         
     | 
| 
      
 26370 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26371 
     | 
    
         
            +
                    const tableName = statement.type === "rename_table" ? statement.tableNameTo : statement.tableName;
         
     | 
| 
      
 26372 
     | 
    
         
            +
                    const statementsForTable = newStatements[tableName];
         
     | 
| 
      
 26373 
     | 
    
         
            +
                    if (!statementsForTable) {
         
     | 
| 
      
 26374 
     | 
    
         
            +
                      newStatements[tableName] = [statement];
         
     | 
| 
      
 26375 
     | 
    
         
            +
                      continue;
         
     | 
| 
      
 26376 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26377 
     | 
    
         
            +
                    if (!statementsForTable.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26378 
     | 
    
         
            +
                      newStatements[tableName].push(statement);
         
     | 
| 
      
 26379 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26380 
     | 
    
         
            +
                  }
         
     | 
| 
      
 26381 
     | 
    
         
            +
                  const combinedStatements = Object.values(newStatements).flat();
         
     | 
| 
      
 26382 
     | 
    
         
            +
                  const renamedTables = combinedStatements.filter((it) => it.type === "rename_table");
         
     | 
| 
      
 26383 
     | 
    
         
            +
                  const renamedColumns = combinedStatements.filter((it) => it.type === "alter_table_rename_column");
         
     | 
| 
      
 26384 
     | 
    
         
            +
                  const rest = combinedStatements.filter((it) => it.type !== "rename_table" && it.type !== "alter_table_rename_column");
         
     | 
| 
      
 26385 
     | 
    
         
            +
                  return [...renamedTables, ...renamedColumns, ...rest];
         
     | 
| 
      
 26386 
     | 
    
         
            +
                };
         
     | 
| 
      
 26387 
     | 
    
         
            +
              }
         
     | 
| 
      
 26388 
     | 
    
         
            +
            });
         
     | 
| 
      
 26389 
     | 
    
         
            +
             
     | 
| 
       25841 
26390 
     | 
    
         
             
            // src/snapshotsDiffer.ts
         
     | 
| 
       25842 
     | 
    
         
            -
            var makeChanged, makeSelfOrChanged, makePatched, columnSchema, alteredColumnSchema, enumSchema2, changedEnumSchema, tableScheme, alteredTableScheme, diffResultScheme, diffResultSchemeMysql, diffResultSchemeSQLite, schemaChangeFor, nameChangeFor, nameSchemaChangeFor, columnChangeFor, applyPgSnapshotsDiff, applyMysqlSnapshotsDiff, applySqliteSnapshotsDiff;
         
     | 
| 
      
 26391 
     | 
    
         
            +
            var makeChanged, makeSelfOrChanged, makePatched, columnSchema, alteredColumnSchema, enumSchema2, changedEnumSchema, tableScheme, alteredTableScheme, diffResultScheme, diffResultSchemeMysql, diffResultSchemeSQLite, schemaChangeFor, nameChangeFor, nameSchemaChangeFor, columnChangeFor, applyPgSnapshotsDiff, applyMysqlSnapshotsDiff, applySqliteSnapshotsDiff, applyLibSQLSnapshotsDiff;
         
     | 
| 
       25843 
26392 
     | 
    
         
             
            var init_snapshotsDiffer = __esm({
         
     | 
| 
       25844 
26393 
     | 
    
         
             
              "src/snapshotsDiffer.ts"() {
         
     | 
| 
       25845 
26394 
     | 
    
         
             
                "use strict";
         
     | 
| 
         @@ -25851,6 +26400,7 @@ var init_snapshotsDiffer = __esm({ 
     | 
|
| 
       25851 
26400 
     | 
    
         
             
                init_mysqlSchema();
         
     | 
| 
       25852 
26401 
     | 
    
         
             
                init_pgSchema();
         
     | 
| 
       25853 
26402 
     | 
    
         
             
                init_sqliteSchema();
         
     | 
| 
      
 26403 
     | 
    
         
            +
                init_statementCombiner();
         
     | 
| 
       25854 
26404 
     | 
    
         
             
                init_utils();
         
     | 
| 
       25855 
26405 
     | 
    
         
             
                makeChanged = (schema5) => {
         
     | 
| 
       25856 
26406 
     | 
    
         
             
                  return objectType({
         
     | 
| 
         @@ -26867,35 +27417,319 @@ var init_snapshotsDiffer = __esm({ 
     | 
|
| 
       26867 
27417 
     | 
    
         
             
                  const jsonDroppedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
         
     | 
| 
       26868 
27418 
     | 
    
         
             
                    (t2) => t2.type === "delete_reference"
         
     | 
| 
       26869 
27419 
     | 
    
         
             
                  );
         
     | 
| 
       26870 
     | 
    
         
            -
                  const jsonMySqlCreateTables = createdTables.map((it) => {
         
     | 
| 
       26871 
     | 
    
         
            -
                    return prepareMySqlCreateTableJson(
         
     | 
| 
       26872 
     | 
    
         
            -
                      it,
         
     | 
| 
       26873 
     | 
    
         
            -
                      curFull,
         
     | 
| 
       26874 
     | 
    
         
            -
                      curFull.internal
         
     | 
| 
       26875 
     | 
    
         
            -
                    );
         
     | 
| 
       26876 
     | 
    
         
            -
                  });
         
     | 
| 
       26877 
     | 
    
         
            -
                  jsonStatements.push(...jsonMySqlCreateTables);
         
     | 
| 
      
 27420 
     | 
    
         
            +
                  const jsonMySqlCreateTables = createdTables.map((it) => {
         
     | 
| 
      
 27421 
     | 
    
         
            +
                    return prepareMySqlCreateTableJson(
         
     | 
| 
      
 27422 
     | 
    
         
            +
                      it,
         
     | 
| 
      
 27423 
     | 
    
         
            +
                      curFull,
         
     | 
| 
      
 27424 
     | 
    
         
            +
                      curFull.internal
         
     | 
| 
      
 27425 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27426 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27427 
     | 
    
         
            +
                  jsonStatements.push(...jsonMySqlCreateTables);
         
     | 
| 
      
 27428 
     | 
    
         
            +
                  jsonStatements.push(...jsonDropTables);
         
     | 
| 
      
 27429 
     | 
    
         
            +
                  jsonStatements.push(...jsonRenameTables);
         
     | 
| 
      
 27430 
     | 
    
         
            +
                  jsonStatements.push(...jsonRenameColumnsStatements);
         
     | 
| 
      
 27431 
     | 
    
         
            +
                  jsonStatements.push(...jsonDeletedUniqueConstraints);
         
     | 
| 
      
 27432 
     | 
    
         
            +
                  jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
         
     | 
| 
      
 27433 
     | 
    
         
            +
                  jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
         
     | 
| 
      
 27434 
     | 
    
         
            +
                  jsonStatements.push(...jsonDeletedCompositePKs);
         
     | 
| 
      
 27435 
     | 
    
         
            +
                  jsonStatements.push(...jsonTableAlternations);
         
     | 
| 
      
 27436 
     | 
    
         
            +
                  jsonStatements.push(...jsonAddedCompositePKs);
         
     | 
| 
      
 27437 
     | 
    
         
            +
                  jsonStatements.push(...jsonAddedUniqueConstraints);
         
     | 
| 
      
 27438 
     | 
    
         
            +
                  jsonStatements.push(...jsonDeletedUniqueConstraints);
         
     | 
| 
      
 27439 
     | 
    
         
            +
                  jsonStatements.push(...jsonAddColumnsStatemets);
         
     | 
| 
      
 27440 
     | 
    
         
            +
                  jsonStatements.push(...jsonCreateReferencesForCreatedTables);
         
     | 
| 
      
 27441 
     | 
    
         
            +
                  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
         
     | 
| 
      
 27442 
     | 
    
         
            +
                  jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
         
     | 
| 
      
 27443 
     | 
    
         
            +
                  jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
         
     | 
| 
      
 27444 
     | 
    
         
            +
                  jsonStatements.push(...jsonDropColumnsStatemets);
         
     | 
| 
      
 27445 
     | 
    
         
            +
                  jsonStatements.push(...jsonAlteredCompositePKs);
         
     | 
| 
      
 27446 
     | 
    
         
            +
                  jsonStatements.push(...jsonAddedUniqueConstraints);
         
     | 
| 
      
 27447 
     | 
    
         
            +
                  jsonStatements.push(...jsonAlteredUniqueConstraints);
         
     | 
| 
      
 27448 
     | 
    
         
            +
                  const sqlStatements = fromJson(jsonStatements, "mysql");
         
     | 
| 
      
 27449 
     | 
    
         
            +
                  const uniqueSqlStatements = [];
         
     | 
| 
      
 27450 
     | 
    
         
            +
                  sqlStatements.forEach((ss) => {
         
     | 
| 
      
 27451 
     | 
    
         
            +
                    if (!uniqueSqlStatements.includes(ss)) {
         
     | 
| 
      
 27452 
     | 
    
         
            +
                      uniqueSqlStatements.push(ss);
         
     | 
| 
      
 27453 
     | 
    
         
            +
                    }
         
     | 
| 
      
 27454 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27455 
     | 
    
         
            +
                  const rTables = renamedTables.map((it) => {
         
     | 
| 
      
 27456 
     | 
    
         
            +
                    return { from: it.from, to: it.to };
         
     | 
| 
      
 27457 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27458 
     | 
    
         
            +
                  const _meta = prepareMigrationMeta([], rTables, rColumns);
         
     | 
| 
      
 27459 
     | 
    
         
            +
                  return {
         
     | 
| 
      
 27460 
     | 
    
         
            +
                    statements: jsonStatements,
         
     | 
| 
      
 27461 
     | 
    
         
            +
                    sqlStatements: uniqueSqlStatements,
         
     | 
| 
      
 27462 
     | 
    
         
            +
                    _meta
         
     | 
| 
      
 27463 
     | 
    
         
            +
                  };
         
     | 
| 
      
 27464 
     | 
    
         
            +
                };
         
     | 
| 
      
 27465 
     | 
    
         
            +
                applySqliteSnapshotsDiff = async (json1, json2, tablesResolver2, columnsResolver2, prevFull, curFull, action) => {
         
     | 
| 
      
 27466 
     | 
    
         
            +
                  const tablesDiff = diffSchemasOrTables(json1.tables, json2.tables);
         
     | 
| 
      
 27467 
     | 
    
         
            +
                  const {
         
     | 
| 
      
 27468 
     | 
    
         
            +
                    created: createdTables,
         
     | 
| 
      
 27469 
     | 
    
         
            +
                    deleted: deletedTables,
         
     | 
| 
      
 27470 
     | 
    
         
            +
                    renamed: renamedTables
         
     | 
| 
      
 27471 
     | 
    
         
            +
                  } = await tablesResolver2({
         
     | 
| 
      
 27472 
     | 
    
         
            +
                    created: tablesDiff.added,
         
     | 
| 
      
 27473 
     | 
    
         
            +
                    deleted: tablesDiff.deleted
         
     | 
| 
      
 27474 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27475 
     | 
    
         
            +
                  const tablesPatchedSnap1 = copy(json1);
         
     | 
| 
      
 27476 
     | 
    
         
            +
                  tablesPatchedSnap1.tables = mapEntries(tablesPatchedSnap1.tables, (_2, it) => {
         
     | 
| 
      
 27477 
     | 
    
         
            +
                    const { name } = nameChangeFor(it, renamedTables);
         
     | 
| 
      
 27478 
     | 
    
         
            +
                    it.name = name;
         
     | 
| 
      
 27479 
     | 
    
         
            +
                    return [name, it];
         
     | 
| 
      
 27480 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27481 
     | 
    
         
            +
                  const res = diffColumns(tablesPatchedSnap1.tables, json2.tables);
         
     | 
| 
      
 27482 
     | 
    
         
            +
                  const columnRenames = [];
         
     | 
| 
      
 27483 
     | 
    
         
            +
                  const columnCreates = [];
         
     | 
| 
      
 27484 
     | 
    
         
            +
                  const columnDeletes = [];
         
     | 
| 
      
 27485 
     | 
    
         
            +
                  for (let entry of Object.values(res)) {
         
     | 
| 
      
 27486 
     | 
    
         
            +
                    const { renamed, created, deleted } = await columnsResolver2({
         
     | 
| 
      
 27487 
     | 
    
         
            +
                      tableName: entry.name,
         
     | 
| 
      
 27488 
     | 
    
         
            +
                      schema: entry.schema,
         
     | 
| 
      
 27489 
     | 
    
         
            +
                      deleted: entry.columns.deleted,
         
     | 
| 
      
 27490 
     | 
    
         
            +
                      created: entry.columns.added
         
     | 
| 
      
 27491 
     | 
    
         
            +
                    });
         
     | 
| 
      
 27492 
     | 
    
         
            +
                    if (created.length > 0) {
         
     | 
| 
      
 27493 
     | 
    
         
            +
                      columnCreates.push({
         
     | 
| 
      
 27494 
     | 
    
         
            +
                        table: entry.name,
         
     | 
| 
      
 27495 
     | 
    
         
            +
                        columns: created
         
     | 
| 
      
 27496 
     | 
    
         
            +
                      });
         
     | 
| 
      
 27497 
     | 
    
         
            +
                    }
         
     | 
| 
      
 27498 
     | 
    
         
            +
                    if (deleted.length > 0) {
         
     | 
| 
      
 27499 
     | 
    
         
            +
                      columnDeletes.push({
         
     | 
| 
      
 27500 
     | 
    
         
            +
                        table: entry.name,
         
     | 
| 
      
 27501 
     | 
    
         
            +
                        columns: deleted
         
     | 
| 
      
 27502 
     | 
    
         
            +
                      });
         
     | 
| 
      
 27503 
     | 
    
         
            +
                    }
         
     | 
| 
      
 27504 
     | 
    
         
            +
                    if (renamed.length > 0) {
         
     | 
| 
      
 27505 
     | 
    
         
            +
                      columnRenames.push({
         
     | 
| 
      
 27506 
     | 
    
         
            +
                        table: entry.name,
         
     | 
| 
      
 27507 
     | 
    
         
            +
                        renames: renamed
         
     | 
| 
      
 27508 
     | 
    
         
            +
                      });
         
     | 
| 
      
 27509 
     | 
    
         
            +
                    }
         
     | 
| 
      
 27510 
     | 
    
         
            +
                  }
         
     | 
| 
      
 27511 
     | 
    
         
            +
                  const columnRenamesDict = columnRenames.reduce(
         
     | 
| 
      
 27512 
     | 
    
         
            +
                    (acc, it) => {
         
     | 
| 
      
 27513 
     | 
    
         
            +
                      acc[it.table] = it.renames;
         
     | 
| 
      
 27514 
     | 
    
         
            +
                      return acc;
         
     | 
| 
      
 27515 
     | 
    
         
            +
                    },
         
     | 
| 
      
 27516 
     | 
    
         
            +
                    {}
         
     | 
| 
      
 27517 
     | 
    
         
            +
                  );
         
     | 
| 
      
 27518 
     | 
    
         
            +
                  const columnsPatchedSnap1 = copy(tablesPatchedSnap1);
         
     | 
| 
      
 27519 
     | 
    
         
            +
                  columnsPatchedSnap1.tables = mapEntries(
         
     | 
| 
      
 27520 
     | 
    
         
            +
                    columnsPatchedSnap1.tables,
         
     | 
| 
      
 27521 
     | 
    
         
            +
                    (tableKey2, tableValue) => {
         
     | 
| 
      
 27522 
     | 
    
         
            +
                      const patchedColumns = mapKeys(
         
     | 
| 
      
 27523 
     | 
    
         
            +
                        tableValue.columns,
         
     | 
| 
      
 27524 
     | 
    
         
            +
                        (columnKey, column7) => {
         
     | 
| 
      
 27525 
     | 
    
         
            +
                          const rens = columnRenamesDict[tableValue.name] || [];
         
     | 
| 
      
 27526 
     | 
    
         
            +
                          const newName = columnChangeFor(columnKey, rens);
         
     | 
| 
      
 27527 
     | 
    
         
            +
                          column7.name = newName;
         
     | 
| 
      
 27528 
     | 
    
         
            +
                          return newName;
         
     | 
| 
      
 27529 
     | 
    
         
            +
                        }
         
     | 
| 
      
 27530 
     | 
    
         
            +
                      );
         
     | 
| 
      
 27531 
     | 
    
         
            +
                      tableValue.columns = patchedColumns;
         
     | 
| 
      
 27532 
     | 
    
         
            +
                      return [tableKey2, tableValue];
         
     | 
| 
      
 27533 
     | 
    
         
            +
                    }
         
     | 
| 
      
 27534 
     | 
    
         
            +
                  );
         
     | 
| 
      
 27535 
     | 
    
         
            +
                  const diffResult = applyJsonDiff(columnsPatchedSnap1, json2);
         
     | 
| 
      
 27536 
     | 
    
         
            +
                  const typedResult = diffResultSchemeSQLite.parse(diffResult);
         
     | 
| 
      
 27537 
     | 
    
         
            +
                  const tablesMap = {};
         
     | 
| 
      
 27538 
     | 
    
         
            +
                  typedResult.alteredTablesWithColumns.forEach((obj) => {
         
     | 
| 
      
 27539 
     | 
    
         
            +
                    tablesMap[obj.name] = obj;
         
     | 
| 
      
 27540 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27541 
     | 
    
         
            +
                  const jsonCreateTables = createdTables.map((it) => {
         
     | 
| 
      
 27542 
     | 
    
         
            +
                    return prepareSQLiteCreateTable(it, action);
         
     | 
| 
      
 27543 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27544 
     | 
    
         
            +
                  const jsonCreateIndexesForCreatedTables = createdTables.map((it) => {
         
     | 
| 
      
 27545 
     | 
    
         
            +
                    return prepareCreateIndexesJson(
         
     | 
| 
      
 27546 
     | 
    
         
            +
                      it.name,
         
     | 
| 
      
 27547 
     | 
    
         
            +
                      it.schema,
         
     | 
| 
      
 27548 
     | 
    
         
            +
                      it.indexes,
         
     | 
| 
      
 27549 
     | 
    
         
            +
                      curFull.internal
         
     | 
| 
      
 27550 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27551 
     | 
    
         
            +
                  }).flat();
         
     | 
| 
      
 27552 
     | 
    
         
            +
                  const jsonDropTables = deletedTables.map((it) => {
         
     | 
| 
      
 27553 
     | 
    
         
            +
                    return prepareDropTableJson(it);
         
     | 
| 
      
 27554 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27555 
     | 
    
         
            +
                  const jsonRenameTables = renamedTables.map((it) => {
         
     | 
| 
      
 27556 
     | 
    
         
            +
                    return prepareRenameTableJson(it.from, it.to);
         
     | 
| 
      
 27557 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27558 
     | 
    
         
            +
                  const jsonRenameColumnsStatements = columnRenames.map((it) => prepareRenameColumns(it.table, "", it.renames)).flat();
         
     | 
| 
      
 27559 
     | 
    
         
            +
                  const jsonDropColumnsStatemets = columnDeletes.map((it) => _prepareDropColumns(it.table, "", it.columns)).flat();
         
     | 
| 
      
 27560 
     | 
    
         
            +
                  const jsonAddColumnsStatemets = columnCreates.map((it) => {
         
     | 
| 
      
 27561 
     | 
    
         
            +
                    return _prepareSqliteAddColumns(
         
     | 
| 
      
 27562 
     | 
    
         
            +
                      it.table,
         
     | 
| 
      
 27563 
     | 
    
         
            +
                      it.columns,
         
     | 
| 
      
 27564 
     | 
    
         
            +
                      tablesMap[it.table] && tablesMap[it.table].addedForeignKeys ? Object.values(tablesMap[it.table].addedForeignKeys) : []
         
     | 
| 
      
 27565 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27566 
     | 
    
         
            +
                  }).flat();
         
     | 
| 
      
 27567 
     | 
    
         
            +
                  const allAltered = typedResult.alteredTablesWithColumns;
         
     | 
| 
      
 27568 
     | 
    
         
            +
                  const jsonAddedCompositePKs = [];
         
     | 
| 
      
 27569 
     | 
    
         
            +
                  const jsonDeletedCompositePKs = [];
         
     | 
| 
      
 27570 
     | 
    
         
            +
                  const jsonAlteredCompositePKs = [];
         
     | 
| 
      
 27571 
     | 
    
         
            +
                  const jsonAddedUniqueConstraints = [];
         
     | 
| 
      
 27572 
     | 
    
         
            +
                  const jsonDeletedUniqueConstraints = [];
         
     | 
| 
      
 27573 
     | 
    
         
            +
                  const jsonAlteredUniqueConstraints = [];
         
     | 
| 
      
 27574 
     | 
    
         
            +
                  allAltered.forEach((it) => {
         
     | 
| 
      
 27575 
     | 
    
         
            +
                    let addedColumns = [];
         
     | 
| 
      
 27576 
     | 
    
         
            +
                    for (const addedPkName of Object.keys(it.addedCompositePKs)) {
         
     | 
| 
      
 27577 
     | 
    
         
            +
                      const addedPkColumns = it.addedCompositePKs[addedPkName];
         
     | 
| 
      
 27578 
     | 
    
         
            +
                      addedColumns = SQLiteSquasher.unsquashPK(addedPkColumns);
         
     | 
| 
      
 27579 
     | 
    
         
            +
                    }
         
     | 
| 
      
 27580 
     | 
    
         
            +
                    let deletedColumns = [];
         
     | 
| 
      
 27581 
     | 
    
         
            +
                    for (const deletedPkName of Object.keys(it.deletedCompositePKs)) {
         
     | 
| 
      
 27582 
     | 
    
         
            +
                      const deletedPkColumns = it.deletedCompositePKs[deletedPkName];
         
     | 
| 
      
 27583 
     | 
    
         
            +
                      deletedColumns = SQLiteSquasher.unsquashPK(deletedPkColumns);
         
     | 
| 
      
 27584 
     | 
    
         
            +
                    }
         
     | 
| 
      
 27585 
     | 
    
         
            +
                    const doPerformDeleteAndCreate = JSON.stringify(addedColumns) !== JSON.stringify(deletedColumns);
         
     | 
| 
      
 27586 
     | 
    
         
            +
                    let addedCompositePKs = [];
         
     | 
| 
      
 27587 
     | 
    
         
            +
                    let deletedCompositePKs = [];
         
     | 
| 
      
 27588 
     | 
    
         
            +
                    let alteredCompositePKs = [];
         
     | 
| 
      
 27589 
     | 
    
         
            +
                    if (doPerformDeleteAndCreate) {
         
     | 
| 
      
 27590 
     | 
    
         
            +
                      addedCompositePKs = prepareAddCompositePrimaryKeySqlite(
         
     | 
| 
      
 27591 
     | 
    
         
            +
                        it.name,
         
     | 
| 
      
 27592 
     | 
    
         
            +
                        it.addedCompositePKs
         
     | 
| 
      
 27593 
     | 
    
         
            +
                      );
         
     | 
| 
      
 27594 
     | 
    
         
            +
                      deletedCompositePKs = prepareDeleteCompositePrimaryKeySqlite(
         
     | 
| 
      
 27595 
     | 
    
         
            +
                        it.name,
         
     | 
| 
      
 27596 
     | 
    
         
            +
                        it.deletedCompositePKs
         
     | 
| 
      
 27597 
     | 
    
         
            +
                      );
         
     | 
| 
      
 27598 
     | 
    
         
            +
                    }
         
     | 
| 
      
 27599 
     | 
    
         
            +
                    alteredCompositePKs = prepareAlterCompositePrimaryKeySqlite(
         
     | 
| 
      
 27600 
     | 
    
         
            +
                      it.name,
         
     | 
| 
      
 27601 
     | 
    
         
            +
                      it.alteredCompositePKs
         
     | 
| 
      
 27602 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27603 
     | 
    
         
            +
                    let addedUniqueConstraints = [];
         
     | 
| 
      
 27604 
     | 
    
         
            +
                    let deletedUniqueConstraints = [];
         
     | 
| 
      
 27605 
     | 
    
         
            +
                    let alteredUniqueConstraints = [];
         
     | 
| 
      
 27606 
     | 
    
         
            +
                    addedUniqueConstraints = prepareAddUniqueConstraintPg(
         
     | 
| 
      
 27607 
     | 
    
         
            +
                      it.name,
         
     | 
| 
      
 27608 
     | 
    
         
            +
                      it.schema,
         
     | 
| 
      
 27609 
     | 
    
         
            +
                      it.addedUniqueConstraints
         
     | 
| 
      
 27610 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27611 
     | 
    
         
            +
                    deletedUniqueConstraints = prepareDeleteUniqueConstraintPg(
         
     | 
| 
      
 27612 
     | 
    
         
            +
                      it.name,
         
     | 
| 
      
 27613 
     | 
    
         
            +
                      it.schema,
         
     | 
| 
      
 27614 
     | 
    
         
            +
                      it.deletedUniqueConstraints
         
     | 
| 
      
 27615 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27616 
     | 
    
         
            +
                    if (it.alteredUniqueConstraints) {
         
     | 
| 
      
 27617 
     | 
    
         
            +
                      const added = {};
         
     | 
| 
      
 27618 
     | 
    
         
            +
                      const deleted = {};
         
     | 
| 
      
 27619 
     | 
    
         
            +
                      for (const k of Object.keys(it.alteredUniqueConstraints)) {
         
     | 
| 
      
 27620 
     | 
    
         
            +
                        added[k] = it.alteredUniqueConstraints[k].__new;
         
     | 
| 
      
 27621 
     | 
    
         
            +
                        deleted[k] = it.alteredUniqueConstraints[k].__old;
         
     | 
| 
      
 27622 
     | 
    
         
            +
                      }
         
     | 
| 
      
 27623 
     | 
    
         
            +
                      addedUniqueConstraints.push(
         
     | 
| 
      
 27624 
     | 
    
         
            +
                        ...prepareAddUniqueConstraintPg(it.name, it.schema, added)
         
     | 
| 
      
 27625 
     | 
    
         
            +
                      );
         
     | 
| 
      
 27626 
     | 
    
         
            +
                      deletedUniqueConstraints.push(
         
     | 
| 
      
 27627 
     | 
    
         
            +
                        ...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
         
     | 
| 
      
 27628 
     | 
    
         
            +
                      );
         
     | 
| 
      
 27629 
     | 
    
         
            +
                    }
         
     | 
| 
      
 27630 
     | 
    
         
            +
                    jsonAddedCompositePKs.push(...addedCompositePKs);
         
     | 
| 
      
 27631 
     | 
    
         
            +
                    jsonDeletedCompositePKs.push(...deletedCompositePKs);
         
     | 
| 
      
 27632 
     | 
    
         
            +
                    jsonAlteredCompositePKs.push(...alteredCompositePKs);
         
     | 
| 
      
 27633 
     | 
    
         
            +
                    jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
         
     | 
| 
      
 27634 
     | 
    
         
            +
                    jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
         
     | 
| 
      
 27635 
     | 
    
         
            +
                    jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
         
     | 
| 
      
 27636 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27637 
     | 
    
         
            +
                  const rColumns = jsonRenameColumnsStatements.map((it) => {
         
     | 
| 
      
 27638 
     | 
    
         
            +
                    const tableName = it.tableName;
         
     | 
| 
      
 27639 
     | 
    
         
            +
                    const schema5 = it.schema;
         
     | 
| 
      
 27640 
     | 
    
         
            +
                    return {
         
     | 
| 
      
 27641 
     | 
    
         
            +
                      from: { schema: schema5, table: tableName, column: it.oldColumnName },
         
     | 
| 
      
 27642 
     | 
    
         
            +
                      to: { schema: schema5, table: tableName, column: it.newColumnName }
         
     | 
| 
      
 27643 
     | 
    
         
            +
                    };
         
     | 
| 
      
 27644 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27645 
     | 
    
         
            +
                  const jsonTableAlternations = allAltered.map((it) => {
         
     | 
| 
      
 27646 
     | 
    
         
            +
                    return prepareSqliteAlterColumns(it.name, it.schema, it.altered, json2);
         
     | 
| 
      
 27647 
     | 
    
         
            +
                  }).flat();
         
     | 
| 
      
 27648 
     | 
    
         
            +
                  const jsonCreateIndexesForAllAlteredTables = allAltered.map((it) => {
         
     | 
| 
      
 27649 
     | 
    
         
            +
                    return prepareCreateIndexesJson(
         
     | 
| 
      
 27650 
     | 
    
         
            +
                      it.name,
         
     | 
| 
      
 27651 
     | 
    
         
            +
                      it.schema,
         
     | 
| 
      
 27652 
     | 
    
         
            +
                      it.addedIndexes || {},
         
     | 
| 
      
 27653 
     | 
    
         
            +
                      curFull.internal
         
     | 
| 
      
 27654 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27655 
     | 
    
         
            +
                  }).flat();
         
     | 
| 
      
 27656 
     | 
    
         
            +
                  const jsonDropIndexesForAllAlteredTables = allAltered.map((it) => {
         
     | 
| 
      
 27657 
     | 
    
         
            +
                    return prepareDropIndexesJson(
         
     | 
| 
      
 27658 
     | 
    
         
            +
                      it.name,
         
     | 
| 
      
 27659 
     | 
    
         
            +
                      it.schema,
         
     | 
| 
      
 27660 
     | 
    
         
            +
                      it.deletedIndexes || {}
         
     | 
| 
      
 27661 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27662 
     | 
    
         
            +
                  }).flat();
         
     | 
| 
      
 27663 
     | 
    
         
            +
                  allAltered.forEach((it) => {
         
     | 
| 
      
 27664 
     | 
    
         
            +
                    const droppedIndexes = Object.keys(it.alteredIndexes).reduce(
         
     | 
| 
      
 27665 
     | 
    
         
            +
                      (current, item) => {
         
     | 
| 
      
 27666 
     | 
    
         
            +
                        current[item] = it.alteredIndexes[item].__old;
         
     | 
| 
      
 27667 
     | 
    
         
            +
                        return current;
         
     | 
| 
      
 27668 
     | 
    
         
            +
                      },
         
     | 
| 
      
 27669 
     | 
    
         
            +
                      {}
         
     | 
| 
      
 27670 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27671 
     | 
    
         
            +
                    const createdIndexes = Object.keys(it.alteredIndexes).reduce(
         
     | 
| 
      
 27672 
     | 
    
         
            +
                      (current, item) => {
         
     | 
| 
      
 27673 
     | 
    
         
            +
                        current[item] = it.alteredIndexes[item].__new;
         
     | 
| 
      
 27674 
     | 
    
         
            +
                        return current;
         
     | 
| 
      
 27675 
     | 
    
         
            +
                      },
         
     | 
| 
      
 27676 
     | 
    
         
            +
                      {}
         
     | 
| 
      
 27677 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27678 
     | 
    
         
            +
                    jsonCreateIndexesForAllAlteredTables.push(
         
     | 
| 
      
 27679 
     | 
    
         
            +
                      ...prepareCreateIndexesJson(
         
     | 
| 
      
 27680 
     | 
    
         
            +
                        it.name,
         
     | 
| 
      
 27681 
     | 
    
         
            +
                        it.schema,
         
     | 
| 
      
 27682 
     | 
    
         
            +
                        createdIndexes || {},
         
     | 
| 
      
 27683 
     | 
    
         
            +
                        curFull.internal
         
     | 
| 
      
 27684 
     | 
    
         
            +
                      )
         
     | 
| 
      
 27685 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27686 
     | 
    
         
            +
                    jsonDropIndexesForAllAlteredTables.push(
         
     | 
| 
      
 27687 
     | 
    
         
            +
                      ...prepareDropIndexesJson(it.name, it.schema, droppedIndexes || {})
         
     | 
| 
      
 27688 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27689 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27690 
     | 
    
         
            +
                  const jsonReferencesForAllAlteredTables = allAltered.map((it) => {
         
     | 
| 
      
 27691 
     | 
    
         
            +
                    const forAdded = prepareCreateReferencesJson(
         
     | 
| 
      
 27692 
     | 
    
         
            +
                      it.name,
         
     | 
| 
      
 27693 
     | 
    
         
            +
                      it.schema,
         
     | 
| 
      
 27694 
     | 
    
         
            +
                      it.addedForeignKeys
         
     | 
| 
      
 27695 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27696 
     | 
    
         
            +
                    const forAltered = prepareDropReferencesJson(
         
     | 
| 
      
 27697 
     | 
    
         
            +
                      it.name,
         
     | 
| 
      
 27698 
     | 
    
         
            +
                      it.schema,
         
     | 
| 
      
 27699 
     | 
    
         
            +
                      it.deletedForeignKeys
         
     | 
| 
      
 27700 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27701 
     | 
    
         
            +
                    const alteredFKs = prepareAlterReferencesJson(
         
     | 
| 
      
 27702 
     | 
    
         
            +
                      it.name,
         
     | 
| 
      
 27703 
     | 
    
         
            +
                      it.schema,
         
     | 
| 
      
 27704 
     | 
    
         
            +
                      it.alteredForeignKeys
         
     | 
| 
      
 27705 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27706 
     | 
    
         
            +
                    return [...forAdded, ...forAltered, ...alteredFKs];
         
     | 
| 
      
 27707 
     | 
    
         
            +
                  }).flat();
         
     | 
| 
      
 27708 
     | 
    
         
            +
                  const jsonCreatedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
         
     | 
| 
      
 27709 
     | 
    
         
            +
                    (t2) => t2.type === "create_reference"
         
     | 
| 
      
 27710 
     | 
    
         
            +
                  );
         
     | 
| 
      
 27711 
     | 
    
         
            +
                  const jsonDroppedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
         
     | 
| 
      
 27712 
     | 
    
         
            +
                    (t2) => t2.type === "delete_reference"
         
     | 
| 
      
 27713 
     | 
    
         
            +
                  );
         
     | 
| 
      
 27714 
     | 
    
         
            +
                  const jsonStatements = [];
         
     | 
| 
      
 27715 
     | 
    
         
            +
                  jsonStatements.push(...jsonCreateTables);
         
     | 
| 
       26878 
27716 
     | 
    
         
             
                  jsonStatements.push(...jsonDropTables);
         
     | 
| 
       26879 
27717 
     | 
    
         
             
                  jsonStatements.push(...jsonRenameTables);
         
     | 
| 
       26880 
27718 
     | 
    
         
             
                  jsonStatements.push(...jsonRenameColumnsStatements);
         
     | 
| 
       26881 
     | 
    
         
            -
                  jsonStatements.push(...jsonDeletedUniqueConstraints);
         
     | 
| 
       26882 
27719 
     | 
    
         
             
                  jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
         
     | 
| 
       26883 
27720 
     | 
    
         
             
                  jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
         
     | 
| 
       26884 
27721 
     | 
    
         
             
                  jsonStatements.push(...jsonDeletedCompositePKs);
         
     | 
| 
       26885 
27722 
     | 
    
         
             
                  jsonStatements.push(...jsonTableAlternations);
         
     | 
| 
       26886 
27723 
     | 
    
         
             
                  jsonStatements.push(...jsonAddedCompositePKs);
         
     | 
| 
       26887 
     | 
    
         
            -
                  jsonStatements.push(...jsonAddedUniqueConstraints);
         
     | 
| 
       26888 
     | 
    
         
            -
                  jsonStatements.push(...jsonDeletedUniqueConstraints);
         
     | 
| 
       26889 
27724 
     | 
    
         
             
                  jsonStatements.push(...jsonAddColumnsStatemets);
         
     | 
| 
       26890 
     | 
    
         
            -
                  jsonStatements.push(...jsonCreateReferencesForCreatedTables);
         
     | 
| 
       26891 
27725 
     | 
    
         
             
                  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
         
     | 
| 
       26892 
     | 
    
         
            -
                  jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
         
     | 
| 
       26893 
27726 
     | 
    
         
             
                  jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
         
     | 
| 
      
 27727 
     | 
    
         
            +
                  jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
         
     | 
| 
       26894 
27728 
     | 
    
         
             
                  jsonStatements.push(...jsonDropColumnsStatemets);
         
     | 
| 
       26895 
27729 
     | 
    
         
             
                  jsonStatements.push(...jsonAlteredCompositePKs);
         
     | 
| 
       26896 
     | 
    
         
            -
                  jsonStatements.push(...jsonAddedUniqueConstraints);
         
     | 
| 
       26897 
27730 
     | 
    
         
             
                  jsonStatements.push(...jsonAlteredUniqueConstraints);
         
     | 
| 
       26898 
     | 
    
         
            -
                  const  
     | 
| 
      
 27731 
     | 
    
         
            +
                  const combinedJsonStatements = sqliteCombineStatements(jsonStatements, json2, action);
         
     | 
| 
      
 27732 
     | 
    
         
            +
                  const sqlStatements = fromJson(combinedJsonStatements, "sqlite");
         
     | 
| 
       26899 
27733 
     | 
    
         
             
                  const uniqueSqlStatements = [];
         
     | 
| 
       26900 
27734 
     | 
    
         
             
                  sqlStatements.forEach((ss) => {
         
     | 
| 
       26901 
27735 
     | 
    
         
             
                    if (!uniqueSqlStatements.includes(ss)) {
         
     | 
| 
         @@ -26907,12 +27741,12 @@ var init_snapshotsDiffer = __esm({ 
     | 
|
| 
       26907 
27741 
     | 
    
         
             
                  });
         
     | 
| 
       26908 
27742 
     | 
    
         
             
                  const _meta = prepareMigrationMeta([], rTables, rColumns);
         
     | 
| 
       26909 
27743 
     | 
    
         
             
                  return {
         
     | 
| 
       26910 
     | 
    
         
            -
                    statements:  
     | 
| 
      
 27744 
     | 
    
         
            +
                    statements: combinedJsonStatements,
         
     | 
| 
       26911 
27745 
     | 
    
         
             
                    sqlStatements: uniqueSqlStatements,
         
     | 
| 
       26912 
27746 
     | 
    
         
             
                    _meta
         
     | 
| 
       26913 
27747 
     | 
    
         
             
                  };
         
     | 
| 
       26914 
27748 
     | 
    
         
             
                };
         
     | 
| 
       26915 
     | 
    
         
            -
                 
     | 
| 
      
 27749 
     | 
    
         
            +
                applyLibSQLSnapshotsDiff = async (json1, json2, tablesResolver2, columnsResolver2, prevFull, curFull, action) => {
         
     | 
| 
       26916 
27750 
     | 
    
         
             
                  const tablesDiff = diffSchemasOrTables(json1.tables, json2.tables);
         
     | 
| 
       26917 
27751 
     | 
    
         
             
                  const {
         
     | 
| 
       26918 
27752 
     | 
    
         
             
                    created: createdTables,
         
     | 
| 
         @@ -27014,6 +27848,18 @@ var init_snapshotsDiffer = __esm({ 
     | 
|
| 
       27014 
27848 
     | 
    
         
             
                      tablesMap[it.table] && tablesMap[it.table].addedForeignKeys ? Object.values(tablesMap[it.table].addedForeignKeys) : []
         
     | 
| 
       27015 
27849 
     | 
    
         
             
                    );
         
     | 
| 
       27016 
27850 
     | 
    
         
             
                  }).flat();
         
     | 
| 
      
 27851 
     | 
    
         
            +
                  const rColumns = jsonRenameColumnsStatements.map((it) => {
         
     | 
| 
      
 27852 
     | 
    
         
            +
                    const tableName = it.tableName;
         
     | 
| 
      
 27853 
     | 
    
         
            +
                    const schema5 = it.schema;
         
     | 
| 
      
 27854 
     | 
    
         
            +
                    return {
         
     | 
| 
      
 27855 
     | 
    
         
            +
                      from: { schema: schema5, table: tableName, column: it.oldColumnName },
         
     | 
| 
      
 27856 
     | 
    
         
            +
                      to: { schema: schema5, table: tableName, column: it.newColumnName }
         
     | 
| 
      
 27857 
     | 
    
         
            +
                    };
         
     | 
| 
      
 27858 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27859 
     | 
    
         
            +
                  const rTables = renamedTables.map((it) => {
         
     | 
| 
      
 27860 
     | 
    
         
            +
                    return { from: it.from, to: it.to };
         
     | 
| 
      
 27861 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27862 
     | 
    
         
            +
                  const _meta = prepareMigrationMeta([], rTables, rColumns);
         
     | 
| 
       27017 
27863 
     | 
    
         
             
                  const allAltered = typedResult.alteredTablesWithColumns;
         
     | 
| 
       27018 
27864 
     | 
    
         
             
                  const jsonAddedCompositePKs = [];
         
     | 
| 
       27019 
27865 
     | 
    
         
             
                  const jsonDeletedCompositePKs = [];
         
     | 
| 
         @@ -27084,14 +27930,6 @@ var init_snapshotsDiffer = __esm({ 
     | 
|
| 
       27084 
27930 
     | 
    
         
             
                    jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
         
     | 
| 
       27085 
27931 
     | 
    
         
             
                    jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
         
     | 
| 
       27086 
27932 
     | 
    
         
             
                  });
         
     | 
| 
       27087 
     | 
    
         
            -
                  const rColumns = jsonRenameColumnsStatements.map((it) => {
         
     | 
| 
       27088 
     | 
    
         
            -
                    const tableName = it.tableName;
         
     | 
| 
       27089 
     | 
    
         
            -
                    const schema5 = it.schema;
         
     | 
| 
       27090 
     | 
    
         
            -
                    return {
         
     | 
| 
       27091 
     | 
    
         
            -
                      from: { schema: schema5, table: tableName, column: it.oldColumnName },
         
     | 
| 
       27092 
     | 
    
         
            -
                      to: { schema: schema5, table: tableName, column: it.newColumnName }
         
     | 
| 
       27093 
     | 
    
         
            -
                    };
         
     | 
| 
       27094 
     | 
    
         
            -
                  });
         
     | 
| 
       27095 
27933 
     | 
    
         
             
                  const jsonTableAlternations = allAltered.map((it) => {
         
     | 
| 
       27096 
27934 
     | 
    
         
             
                    return prepareSqliteAlterColumns(it.name, it.schema, it.altered, json2);
         
     | 
| 
       27097 
27935 
     | 
    
         
             
                  }).flat();
         
     | 
| 
         @@ -27138,21 +27976,22 @@ var init_snapshotsDiffer = __esm({ 
     | 
|
| 
       27138 
27976 
     | 
    
         
             
                    );
         
     | 
| 
       27139 
27977 
     | 
    
         
             
                  });
         
     | 
| 
       27140 
27978 
     | 
    
         
             
                  const jsonReferencesForAllAlteredTables = allAltered.map((it) => {
         
     | 
| 
       27141 
     | 
    
         
            -
                    const forAdded =  
     | 
| 
      
 27979 
     | 
    
         
            +
                    const forAdded = prepareLibSQLCreateReferencesJson(
         
     | 
| 
       27142 
27980 
     | 
    
         
             
                      it.name,
         
     | 
| 
       27143 
27981 
     | 
    
         
             
                      it.schema,
         
     | 
| 
       27144 
     | 
    
         
            -
                      it.addedForeignKeys
         
     | 
| 
       27145 
     | 
    
         
            -
             
     | 
| 
       27146 
     | 
    
         
            -
             
     | 
| 
       27147 
     | 
    
         
            -
                      it.name,
         
     | 
| 
       27148 
     | 
    
         
            -
                      it.schema,
         
     | 
| 
       27149 
     | 
    
         
            -
                      it.deletedForeignKeys
         
     | 
| 
      
 27982 
     | 
    
         
            +
                      it.addedForeignKeys,
         
     | 
| 
      
 27983 
     | 
    
         
            +
                      json2,
         
     | 
| 
      
 27984 
     | 
    
         
            +
                      action
         
     | 
| 
       27150 
27985 
     | 
    
         
             
                    );
         
     | 
| 
       27151 
     | 
    
         
            -
                    const  
     | 
| 
      
 27986 
     | 
    
         
            +
                    const forAltered = prepareLibSQLDropReferencesJson(
         
     | 
| 
       27152 
27987 
     | 
    
         
             
                      it.name,
         
     | 
| 
       27153 
27988 
     | 
    
         
             
                      it.schema,
         
     | 
| 
       27154 
     | 
    
         
            -
                      it. 
     | 
| 
      
 27989 
     | 
    
         
            +
                      it.deletedForeignKeys,
         
     | 
| 
      
 27990 
     | 
    
         
            +
                      json2,
         
     | 
| 
      
 27991 
     | 
    
         
            +
                      _meta,
         
     | 
| 
      
 27992 
     | 
    
         
            +
                      action
         
     | 
| 
       27155 
27993 
     | 
    
         
             
                    );
         
     | 
| 
      
 27994 
     | 
    
         
            +
                    const alteredFKs = prepareAlterReferencesJson(it.name, it.schema, it.alteredForeignKeys);
         
     | 
| 
       27156 
27995 
     | 
    
         
             
                    return [...forAdded, ...forAltered, ...alteredFKs];
         
     | 
| 
       27157 
27996 
     | 
    
         
             
                  }).flat();
         
     | 
| 
       27158 
27997 
     | 
    
         
             
                  const jsonCreatedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
         
     | 
| 
         @@ -27178,19 +28017,22 @@ var init_snapshotsDiffer = __esm({ 
     | 
|
| 
       27178 
28017 
     | 
    
         
             
                  jsonStatements.push(...jsonDropColumnsStatemets);
         
     | 
| 
       27179 
28018 
     | 
    
         
             
                  jsonStatements.push(...jsonAlteredCompositePKs);
         
     | 
| 
       27180 
28019 
     | 
    
         
             
                  jsonStatements.push(...jsonAlteredUniqueConstraints);
         
     | 
| 
       27181 
     | 
    
         
            -
                  const  
     | 
| 
      
 28020 
     | 
    
         
            +
                  const combinedJsonStatements = libSQLCombineStatements(jsonStatements, json2, action);
         
     | 
| 
      
 28021 
     | 
    
         
            +
                  const sqlStatements = fromJson(
         
     | 
| 
      
 28022 
     | 
    
         
            +
                    combinedJsonStatements,
         
     | 
| 
      
 28023 
     | 
    
         
            +
                    "sqlite",
         
     | 
| 
      
 28024 
     | 
    
         
            +
                    action,
         
     | 
| 
      
 28025 
     | 
    
         
            +
                    "turso",
         
     | 
| 
      
 28026 
     | 
    
         
            +
                    json2
         
     | 
| 
      
 28027 
     | 
    
         
            +
                  );
         
     | 
| 
       27182 
28028 
     | 
    
         
             
                  const uniqueSqlStatements = [];
         
     | 
| 
       27183 
28029 
     | 
    
         
             
                  sqlStatements.forEach((ss) => {
         
     | 
| 
       27184 
28030 
     | 
    
         
             
                    if (!uniqueSqlStatements.includes(ss)) {
         
     | 
| 
       27185 
28031 
     | 
    
         
             
                      uniqueSqlStatements.push(ss);
         
     | 
| 
       27186 
28032 
     | 
    
         
             
                    }
         
     | 
| 
       27187 
28033 
     | 
    
         
             
                  });
         
     | 
| 
       27188 
     | 
    
         
            -
                  const rTables = renamedTables.map((it) => {
         
     | 
| 
       27189 
     | 
    
         
            -
                    return { from: it.from, to: it.to };
         
     | 
| 
       27190 
     | 
    
         
            -
                  });
         
     | 
| 
       27191 
     | 
    
         
            -
                  const _meta = prepareMigrationMeta([], rTables, rColumns);
         
     | 
| 
       27192 
28034 
     | 
    
         
             
                  return {
         
     | 
| 
       27193 
     | 
    
         
            -
                    statements:  
     | 
| 
      
 28035 
     | 
    
         
            +
                    statements: combinedJsonStatements,
         
     | 
| 
       27194 
28036 
     | 
    
         
             
                    sqlStatements: uniqueSqlStatements,
         
     | 
| 
       27195 
28037 
     | 
    
         
             
                    _meta
         
     | 
| 
       27196 
28038 
     | 
    
         
             
                  };
         
     | 
| 
         @@ -28529,6 +29371,7 @@ __export(migrate_exports, { 
     | 
|
| 
       28529 
29371 
     | 
    
         
             
              prepareAndMigrateMysql: () => prepareAndMigrateMysql,
         
     | 
| 
       28530 
29372 
     | 
    
         
             
              prepareAndMigratePg: () => prepareAndMigratePg,
         
     | 
| 
       28531 
29373 
     | 
    
         
             
              prepareAndMigrateSqlite: () => prepareAndMigrateSqlite,
         
     | 
| 
      
 29374 
     | 
    
         
            +
              prepareLibSQLPush: () => prepareLibSQLPush,
         
     | 
| 
       28532 
29375 
     | 
    
         
             
              prepareMySQLPush: () => prepareMySQLPush,
         
     | 
| 
       28533 
29376 
     | 
    
         
             
              preparePgPush: () => preparePgPush,
         
     | 
| 
       28534 
29377 
     | 
    
         
             
              prepareSQLitePush: () => prepareSQLitePush,
         
     | 
| 
         @@ -28541,7 +29384,7 @@ __export(migrate_exports, { 
     | 
|
| 
       28541 
29384 
     | 
    
         
             
              tablesResolver: () => tablesResolver,
         
     | 
| 
       28542 
29385 
     | 
    
         
             
              writeResult: () => writeResult
         
     | 
| 
       28543 
29386 
     | 
    
         
             
            });
         
     | 
| 
       28544 
     | 
    
         
            -
            var import_fs5, import_hanji3, import_path4, schemasResolver, tablesResolver, sequencesResolver, enumsResolver, columnsResolver, prepareAndMigratePg, preparePgPush, prepareMySQLPush, prepareAndMigrateMysql, prepareAndMigrateSqlite, prepareSQLitePush, promptColumnsConflicts, promptNamedWithSchemasConflict, promptSchemasConflict, BREAKPOINT, writeResult, embeddedMigrations, prepareSnapshotFolderName, two;
         
     | 
| 
      
 29387 
     | 
    
         
            +
            var import_fs5, import_hanji3, import_path4, schemasResolver, tablesResolver, sequencesResolver, enumsResolver, columnsResolver, prepareAndMigratePg, preparePgPush, prepareMySQLPush, prepareAndMigrateMysql, prepareAndMigrateSqlite, prepareSQLitePush, prepareLibSQLPush, promptColumnsConflicts, promptNamedWithSchemasConflict, promptSchemasConflict, BREAKPOINT, writeResult, embeddedMigrations, prepareSnapshotFolderName, two;
         
     | 
| 
       28545 
29388 
     | 
    
         
             
            var init_migrate = __esm({
         
     | 
| 
       28546 
29389 
     | 
    
         
             
              "src/cli/commands/migrate.ts"() {
         
     | 
| 
       28547 
29390 
     | 
    
         
             
                "use strict";
         
     | 
| 
         @@ -28793,6 +29636,7 @@ var init_migrate = __esm({ 
     | 
|
| 
       28793 
29636 
     | 
    
         
             
                prepareAndMigrateSqlite = async (config) => {
         
     | 
| 
       28794 
29637 
     | 
    
         
             
                  const outFolder = config.out;
         
     | 
| 
       28795 
29638 
     | 
    
         
             
                  const schemaPath = config.schema;
         
     | 
| 
      
 29639 
     | 
    
         
            +
                  const driver2 = config.driver;
         
     | 
| 
       28796 
29640 
     | 
    
         
             
                  try {
         
     | 
| 
       28797 
29641 
     | 
    
         
             
                    assertV1OutFolder(outFolder);
         
     | 
| 
       28798 
29642 
     | 
    
         
             
                    const { snapshots, journal } = prepareMigrationFolder(outFolder, "sqlite");
         
     | 
| 
         @@ -28818,14 +29662,27 @@ var init_migrate = __esm({ 
     | 
|
| 
       28818 
29662 
     | 
    
         
             
                    }
         
     | 
| 
       28819 
29663 
     | 
    
         
             
                    const squashedPrev = squashSqliteScheme(validatedPrev);
         
     | 
| 
       28820 
29664 
     | 
    
         
             
                    const squashedCur = squashSqliteScheme(validatedCur);
         
     | 
| 
       28821 
     | 
    
         
            -
                     
     | 
| 
       28822 
     | 
    
         
            -
             
     | 
| 
       28823 
     | 
    
         
            -
             
     | 
| 
       28824 
     | 
    
         
            -
                       
     | 
| 
       28825 
     | 
    
         
            -
             
     | 
| 
       28826 
     | 
    
         
            -
             
     | 
| 
       28827 
     | 
    
         
            -
             
     | 
| 
       28828 
     | 
    
         
            -
             
     | 
| 
      
 29665 
     | 
    
         
            +
                    let sqlStatements;
         
     | 
| 
      
 29666 
     | 
    
         
            +
                    let _meta;
         
     | 
| 
      
 29667 
     | 
    
         
            +
                    if (driver2 === "turso") {
         
     | 
| 
      
 29668 
     | 
    
         
            +
                      ({ sqlStatements, _meta } = await applyLibSQLSnapshotsDiff(
         
     | 
| 
      
 29669 
     | 
    
         
            +
                        squashedPrev,
         
     | 
| 
      
 29670 
     | 
    
         
            +
                        squashedCur,
         
     | 
| 
      
 29671 
     | 
    
         
            +
                        tablesResolver,
         
     | 
| 
      
 29672 
     | 
    
         
            +
                        columnsResolver,
         
     | 
| 
      
 29673 
     | 
    
         
            +
                        validatedPrev,
         
     | 
| 
      
 29674 
     | 
    
         
            +
                        validatedCur
         
     | 
| 
      
 29675 
     | 
    
         
            +
                      ));
         
     | 
| 
      
 29676 
     | 
    
         
            +
                    } else {
         
     | 
| 
      
 29677 
     | 
    
         
            +
                      ({ sqlStatements, _meta } = await applySqliteSnapshotsDiff(
         
     | 
| 
      
 29678 
     | 
    
         
            +
                        squashedPrev,
         
     | 
| 
      
 29679 
     | 
    
         
            +
                        squashedCur,
         
     | 
| 
      
 29680 
     | 
    
         
            +
                        tablesResolver,
         
     | 
| 
      
 29681 
     | 
    
         
            +
                        columnsResolver,
         
     | 
| 
      
 29682 
     | 
    
         
            +
                        validatedPrev,
         
     | 
| 
      
 29683 
     | 
    
         
            +
                        validatedCur
         
     | 
| 
      
 29684 
     | 
    
         
            +
                      ));
         
     | 
| 
      
 29685 
     | 
    
         
            +
                    }
         
     | 
| 
       28829 
29686 
     | 
    
         
             
                    writeResult({
         
     | 
| 
       28830 
29687 
     | 
    
         
             
                      cur,
         
     | 
| 
       28831 
29688 
     | 
    
         
             
                      sqlStatements,
         
     | 
| 
         @@ -28841,13 +29698,51 @@ var init_migrate = __esm({ 
     | 
|
| 
       28841 
29698 
     | 
    
         
             
                    console.error(e2);
         
     | 
| 
       28842 
29699 
     | 
    
         
             
                  }
         
     | 
| 
       28843 
29700 
     | 
    
         
             
                };
         
     | 
| 
       28844 
     | 
    
         
            -
                prepareSQLitePush = async (schemaPath, snapshot) => {
         
     | 
| 
      
 29701 
     | 
    
         
            +
                prepareSQLitePush = async (schemaPath, snapshot, driver2) => {
         
     | 
| 
      
 29702 
     | 
    
         
            +
                  const { prev, cur } = await prepareSQLiteDbPushSnapshot(snapshot, schemaPath);
         
     | 
| 
      
 29703 
     | 
    
         
            +
                  const validatedPrev = sqliteSchema.parse(prev);
         
     | 
| 
      
 29704 
     | 
    
         
            +
                  const validatedCur = sqliteSchema.parse(cur);
         
     | 
| 
      
 29705 
     | 
    
         
            +
                  const squashedPrev = squashSqliteScheme(validatedPrev, "push");
         
     | 
| 
      
 29706 
     | 
    
         
            +
                  const squashedCur = squashSqliteScheme(validatedCur, "push");
         
     | 
| 
      
 29707 
     | 
    
         
            +
                  let sqlStatements;
         
     | 
| 
      
 29708 
     | 
    
         
            +
                  let statements;
         
     | 
| 
      
 29709 
     | 
    
         
            +
                  let _meta;
         
     | 
| 
      
 29710 
     | 
    
         
            +
                  if (driver2 === "turso") {
         
     | 
| 
      
 29711 
     | 
    
         
            +
                    ({ sqlStatements, statements, _meta } = await applyLibSQLSnapshotsDiff(
         
     | 
| 
      
 29712 
     | 
    
         
            +
                      squashedPrev,
         
     | 
| 
      
 29713 
     | 
    
         
            +
                      squashedCur,
         
     | 
| 
      
 29714 
     | 
    
         
            +
                      tablesResolver,
         
     | 
| 
      
 29715 
     | 
    
         
            +
                      columnsResolver,
         
     | 
| 
      
 29716 
     | 
    
         
            +
                      validatedPrev,
         
     | 
| 
      
 29717 
     | 
    
         
            +
                      validatedCur,
         
     | 
| 
      
 29718 
     | 
    
         
            +
                      "push"
         
     | 
| 
      
 29719 
     | 
    
         
            +
                    ));
         
     | 
| 
      
 29720 
     | 
    
         
            +
                  } else {
         
     | 
| 
      
 29721 
     | 
    
         
            +
                    ({ sqlStatements, statements, _meta } = await applySqliteSnapshotsDiff(
         
     | 
| 
      
 29722 
     | 
    
         
            +
                      squashedPrev,
         
     | 
| 
      
 29723 
     | 
    
         
            +
                      squashedCur,
         
     | 
| 
      
 29724 
     | 
    
         
            +
                      tablesResolver,
         
     | 
| 
      
 29725 
     | 
    
         
            +
                      columnsResolver,
         
     | 
| 
      
 29726 
     | 
    
         
            +
                      validatedPrev,
         
     | 
| 
      
 29727 
     | 
    
         
            +
                      validatedCur,
         
     | 
| 
      
 29728 
     | 
    
         
            +
                      "push"
         
     | 
| 
      
 29729 
     | 
    
         
            +
                    ));
         
     | 
| 
      
 29730 
     | 
    
         
            +
                  }
         
     | 
| 
      
 29731 
     | 
    
         
            +
                  return {
         
     | 
| 
      
 29732 
     | 
    
         
            +
                    sqlStatements,
         
     | 
| 
      
 29733 
     | 
    
         
            +
                    statements,
         
     | 
| 
      
 29734 
     | 
    
         
            +
                    squashedPrev,
         
     | 
| 
      
 29735 
     | 
    
         
            +
                    squashedCur,
         
     | 
| 
      
 29736 
     | 
    
         
            +
                    meta: _meta
         
     | 
| 
      
 29737 
     | 
    
         
            +
                  };
         
     | 
| 
      
 29738 
     | 
    
         
            +
                };
         
     | 
| 
      
 29739 
     | 
    
         
            +
                prepareLibSQLPush = async (schemaPath, snapshot) => {
         
     | 
| 
       28845 
29740 
     | 
    
         
             
                  const { prev, cur } = await prepareSQLiteDbPushSnapshot(snapshot, schemaPath);
         
     | 
| 
       28846 
29741 
     | 
    
         
             
                  const validatedPrev = sqliteSchema.parse(prev);
         
     | 
| 
       28847 
29742 
     | 
    
         
             
                  const validatedCur = sqliteSchema.parse(cur);
         
     | 
| 
       28848 
29743 
     | 
    
         
             
                  const squashedPrev = squashSqliteScheme(validatedPrev, "push");
         
     | 
| 
       28849 
29744 
     | 
    
         
             
                  const squashedCur = squashSqliteScheme(validatedCur, "push");
         
     | 
| 
       28850 
     | 
    
         
            -
                  const { sqlStatements, statements, _meta } = await  
     | 
| 
      
 29745 
     | 
    
         
            +
                  const { sqlStatements, statements, _meta } = await applyLibSQLSnapshotsDiff(
         
     | 
| 
       28851 
29746 
     | 
    
         
             
                    squashedPrev,
         
     | 
| 
       28852 
29747 
     | 
    
         
             
                    squashedCur,
         
     | 
| 
       28853 
29748 
     | 
    
         
             
                    tablesResolver,
         
     | 
| 
         @@ -72205,8 +73100,271 @@ var init_selector_ui = __esm({ 
     | 
|
| 
       72205 
73100 
     | 
    
         
             
              }
         
     | 
| 
       72206 
73101 
     | 
    
         
             
            });
         
     | 
| 
       72207 
73102 
     | 
    
         | 
| 
      
 73103 
     | 
    
         
            +
            // src/cli/commands/libSqlPushUtils.ts
         
     | 
| 
      
 73104 
     | 
    
         
            +
            var getOldTableName3, _moveDataStatements2, libSqlLogSuggestionsAndReturn;
         
     | 
| 
      
 73105 
     | 
    
         
            +
            var init_libSqlPushUtils = __esm({
         
     | 
| 
      
 73106 
     | 
    
         
            +
              "src/cli/commands/libSqlPushUtils.ts"() {
         
     | 
| 
      
 73107 
     | 
    
         
            +
                "use strict";
         
     | 
| 
      
 73108 
     | 
    
         
            +
                init_source();
         
     | 
| 
      
 73109 
     | 
    
         
            +
                init_utils();
         
     | 
| 
      
 73110 
     | 
    
         
            +
                init_sqliteSchema();
         
     | 
| 
      
 73111 
     | 
    
         
            +
                init_sqlgenerator();
         
     | 
| 
      
 73112 
     | 
    
         
            +
                getOldTableName3 = (tableName, meta) => {
         
     | 
| 
      
 73113 
     | 
    
         
            +
                  for (const key of Object.keys(meta.tables)) {
         
     | 
| 
      
 73114 
     | 
    
         
            +
                    const value = meta.tables[key];
         
     | 
| 
      
 73115 
     | 
    
         
            +
                    if (`"${tableName}"` === value) {
         
     | 
| 
      
 73116 
     | 
    
         
            +
                      return key.substring(1, key.length - 1);
         
     | 
| 
      
 73117 
     | 
    
         
            +
                    }
         
     | 
| 
      
 73118 
     | 
    
         
            +
                  }
         
     | 
| 
      
 73119 
     | 
    
         
            +
                  return tableName;
         
     | 
| 
      
 73120 
     | 
    
         
            +
                };
         
     | 
| 
      
 73121 
     | 
    
         
            +
                _moveDataStatements2 = (tableName, json, dataLoss = false) => {
         
     | 
| 
      
 73122 
     | 
    
         
            +
                  const statements = [];
         
     | 
| 
      
 73123 
     | 
    
         
            +
                  const newTableName = `__new_${tableName}`;
         
     | 
| 
      
 73124 
     | 
    
         
            +
                  const tableColumns = Object.values(json.tables[tableName].columns);
         
     | 
| 
      
 73125 
     | 
    
         
            +
                  const referenceData = Object.values(json.tables[tableName].foreignKeys);
         
     | 
| 
      
 73126 
     | 
    
         
            +
                  const compositePKs = Object.values(
         
     | 
| 
      
 73127 
     | 
    
         
            +
                    json.tables[tableName].compositePrimaryKeys
         
     | 
| 
      
 73128 
     | 
    
         
            +
                  ).map((it) => SQLiteSquasher.unsquashPK(it));
         
     | 
| 
      
 73129 
     | 
    
         
            +
                  const fks = referenceData.map((it) => SQLiteSquasher.unsquashPushFK(it));
         
     | 
| 
      
 73130 
     | 
    
         
            +
                  statements.push(
         
     | 
| 
      
 73131 
     | 
    
         
            +
                    new SQLiteCreateTableConvertor().convert({
         
     | 
| 
      
 73132 
     | 
    
         
            +
                      type: "sqlite_create_table",
         
     | 
| 
      
 73133 
     | 
    
         
            +
                      tableName: newTableName,
         
     | 
| 
      
 73134 
     | 
    
         
            +
                      columns: tableColumns,
         
     | 
| 
      
 73135 
     | 
    
         
            +
                      referenceData: fks,
         
     | 
| 
      
 73136 
     | 
    
         
            +
                      compositePKs
         
     | 
| 
      
 73137 
     | 
    
         
            +
                    })
         
     | 
| 
      
 73138 
     | 
    
         
            +
                  );
         
     | 
| 
      
 73139 
     | 
    
         
            +
                  if (!dataLoss) {
         
     | 
| 
      
 73140 
     | 
    
         
            +
                    const columns = Object.keys(json.tables[tableName].columns).map(
         
     | 
| 
      
 73141 
     | 
    
         
            +
                      (c) => `"${c}"`
         
     | 
| 
      
 73142 
     | 
    
         
            +
                    );
         
     | 
| 
      
 73143 
     | 
    
         
            +
                    statements.push(
         
     | 
| 
      
 73144 
     | 
    
         
            +
                      `INSERT INTO \`${newTableName}\`(${columns.join(
         
     | 
| 
      
 73145 
     | 
    
         
            +
                        ", "
         
     | 
| 
      
 73146 
     | 
    
         
            +
                      )}) SELECT ${columns.join(", ")} FROM \`${tableName}\`;`
         
     | 
| 
      
 73147 
     | 
    
         
            +
                    );
         
     | 
| 
      
 73148 
     | 
    
         
            +
                  }
         
     | 
| 
      
 73149 
     | 
    
         
            +
                  statements.push(
         
     | 
| 
      
 73150 
     | 
    
         
            +
                    new SQLiteDropTableConvertor().convert({
         
     | 
| 
      
 73151 
     | 
    
         
            +
                      type: "drop_table",
         
     | 
| 
      
 73152 
     | 
    
         
            +
                      tableName,
         
     | 
| 
      
 73153 
     | 
    
         
            +
                      schema: ""
         
     | 
| 
      
 73154 
     | 
    
         
            +
                    })
         
     | 
| 
      
 73155 
     | 
    
         
            +
                  );
         
     | 
| 
      
 73156 
     | 
    
         
            +
                  statements.push(
         
     | 
| 
      
 73157 
     | 
    
         
            +
                    new SqliteRenameTableConvertor().convert({
         
     | 
| 
      
 73158 
     | 
    
         
            +
                      fromSchema: "",
         
     | 
| 
      
 73159 
     | 
    
         
            +
                      tableNameFrom: newTableName,
         
     | 
| 
      
 73160 
     | 
    
         
            +
                      tableNameTo: tableName,
         
     | 
| 
      
 73161 
     | 
    
         
            +
                      toSchema: "",
         
     | 
| 
      
 73162 
     | 
    
         
            +
                      type: "rename_table"
         
     | 
| 
      
 73163 
     | 
    
         
            +
                    })
         
     | 
| 
      
 73164 
     | 
    
         
            +
                  );
         
     | 
| 
      
 73165 
     | 
    
         
            +
                  for (const idx of Object.values(json.tables[tableName].indexes)) {
         
     | 
| 
      
 73166 
     | 
    
         
            +
                    statements.push(
         
     | 
| 
      
 73167 
     | 
    
         
            +
                      new CreateSqliteIndexConvertor().convert({
         
     | 
| 
      
 73168 
     | 
    
         
            +
                        type: "create_index",
         
     | 
| 
      
 73169 
     | 
    
         
            +
                        tableName,
         
     | 
| 
      
 73170 
     | 
    
         
            +
                        schema: "",
         
     | 
| 
      
 73171 
     | 
    
         
            +
                        data: idx
         
     | 
| 
      
 73172 
     | 
    
         
            +
                      })
         
     | 
| 
      
 73173 
     | 
    
         
            +
                    );
         
     | 
| 
      
 73174 
     | 
    
         
            +
                  }
         
     | 
| 
      
 73175 
     | 
    
         
            +
                  return statements;
         
     | 
| 
      
 73176 
     | 
    
         
            +
                };
         
     | 
| 
      
 73177 
     | 
    
         
            +
                libSqlLogSuggestionsAndReturn = async (connection, statements, json1, json2, meta) => {
         
     | 
| 
      
 73178 
     | 
    
         
            +
                  let shouldAskForApprove = false;
         
     | 
| 
      
 73179 
     | 
    
         
            +
                  const statementsToExecute = [];
         
     | 
| 
      
 73180 
     | 
    
         
            +
                  const infoToPrint = [];
         
     | 
| 
      
 73181 
     | 
    
         
            +
                  const tablesToRemove = [];
         
     | 
| 
      
 73182 
     | 
    
         
            +
                  const columnsToRemove = [];
         
     | 
| 
      
 73183 
     | 
    
         
            +
                  const tablesToTruncate = [];
         
     | 
| 
      
 73184 
     | 
    
         
            +
                  for (const statement of statements) {
         
     | 
| 
      
 73185 
     | 
    
         
            +
                    if (statement.type === "drop_table") {
         
     | 
| 
      
 73186 
     | 
    
         
            +
                      const res = await connection.query(
         
     | 
| 
      
 73187 
     | 
    
         
            +
                        `select count(*) as count from \`${statement.tableName}\``
         
     | 
| 
      
 73188 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73189 
     | 
    
         
            +
                      const count = Number(res[0].count);
         
     | 
| 
      
 73190 
     | 
    
         
            +
                      if (count > 0) {
         
     | 
| 
      
 73191 
     | 
    
         
            +
                        infoToPrint.push(
         
     | 
| 
      
 73192 
     | 
    
         
            +
                          `\xB7 You're about to delete ${source_default.underline(
         
     | 
| 
      
 73193 
     | 
    
         
            +
                            statement.tableName
         
     | 
| 
      
 73194 
     | 
    
         
            +
                          )} table with ${count} items`
         
     | 
| 
      
 73195 
     | 
    
         
            +
                        );
         
     | 
| 
      
 73196 
     | 
    
         
            +
                        tablesToRemove.push(statement.tableName);
         
     | 
| 
      
 73197 
     | 
    
         
            +
                        shouldAskForApprove = true;
         
     | 
| 
      
 73198 
     | 
    
         
            +
                      }
         
     | 
| 
      
 73199 
     | 
    
         
            +
                      const fromJsonStatement = fromJson([statement], "sqlite", "push", "turso", json2);
         
     | 
| 
      
 73200 
     | 
    
         
            +
                      statementsToExecute.push(
         
     | 
| 
      
 73201 
     | 
    
         
            +
                        ...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
         
     | 
| 
      
 73202 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73203 
     | 
    
         
            +
                    } else if (statement.type === "alter_table_drop_column") {
         
     | 
| 
      
 73204 
     | 
    
         
            +
                      const tableName = statement.tableName;
         
     | 
| 
      
 73205 
     | 
    
         
            +
                      const res = await connection.query(
         
     | 
| 
      
 73206 
     | 
    
         
            +
                        `select count(*) as count from \`${tableName}\``
         
     | 
| 
      
 73207 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73208 
     | 
    
         
            +
                      const count = Number(res[0].count);
         
     | 
| 
      
 73209 
     | 
    
         
            +
                      if (count > 0) {
         
     | 
| 
      
 73210 
     | 
    
         
            +
                        infoToPrint.push(
         
     | 
| 
      
 73211 
     | 
    
         
            +
                          `\xB7 You're about to delete ${source_default.underline(
         
     | 
| 
      
 73212 
     | 
    
         
            +
                            statement.columnName
         
     | 
| 
      
 73213 
     | 
    
         
            +
                          )} column in ${tableName} table with ${count} items`
         
     | 
| 
      
 73214 
     | 
    
         
            +
                        );
         
     | 
| 
      
 73215 
     | 
    
         
            +
                        columnsToRemove.push(`${tableName}_${statement.columnName}`);
         
     | 
| 
      
 73216 
     | 
    
         
            +
                        shouldAskForApprove = true;
         
     | 
| 
      
 73217 
     | 
    
         
            +
                      }
         
     | 
| 
      
 73218 
     | 
    
         
            +
                      const fromJsonStatement = fromJson([statement], "sqlite", "push", "turso", json2);
         
     | 
| 
      
 73219 
     | 
    
         
            +
                      statementsToExecute.push(
         
     | 
| 
      
 73220 
     | 
    
         
            +
                        ...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
         
     | 
| 
      
 73221 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73222 
     | 
    
         
            +
                    } else if (statement.type === "sqlite_alter_table_add_column" && statement.column.notNull && !statement.column.default) {
         
     | 
| 
      
 73223 
     | 
    
         
            +
                      const newTableName = statement.tableName;
         
     | 
| 
      
 73224 
     | 
    
         
            +
                      const res = await connection.query(
         
     | 
| 
      
 73225 
     | 
    
         
            +
                        `select count(*) as count from \`${newTableName}\``
         
     | 
| 
      
 73226 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73227 
     | 
    
         
            +
                      const count = Number(res[0].count);
         
     | 
| 
      
 73228 
     | 
    
         
            +
                      if (count > 0) {
         
     | 
| 
      
 73229 
     | 
    
         
            +
                        infoToPrint.push(
         
     | 
| 
      
 73230 
     | 
    
         
            +
                          `\xB7 You're about to add not-null ${source_default.underline(
         
     | 
| 
      
 73231 
     | 
    
         
            +
                            statement.column.name
         
     | 
| 
      
 73232 
     | 
    
         
            +
                          )} column without default value, which contains ${count} items`
         
     | 
| 
      
 73233 
     | 
    
         
            +
                        );
         
     | 
| 
      
 73234 
     | 
    
         
            +
                        tablesToTruncate.push(newTableName);
         
     | 
| 
      
 73235 
     | 
    
         
            +
                        statementsToExecute.push(`delete from ${newTableName};`);
         
     | 
| 
      
 73236 
     | 
    
         
            +
                        shouldAskForApprove = true;
         
     | 
| 
      
 73237 
     | 
    
         
            +
                      }
         
     | 
| 
      
 73238 
     | 
    
         
            +
                      const fromJsonStatement = fromJson([statement], "sqlite", "push", "turso", json2);
         
     | 
| 
      
 73239 
     | 
    
         
            +
                      statementsToExecute.push(
         
     | 
| 
      
 73240 
     | 
    
         
            +
                        ...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
         
     | 
| 
      
 73241 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73242 
     | 
    
         
            +
                    } else if (statement.type === "alter_table_alter_column_set_notnull") {
         
     | 
| 
      
 73243 
     | 
    
         
            +
                      const tableName = statement.tableName;
         
     | 
| 
      
 73244 
     | 
    
         
            +
                      if (statement.type === "alter_table_alter_column_set_notnull" && typeof statement.columnDefault === "undefined") {
         
     | 
| 
      
 73245 
     | 
    
         
            +
                        const res = await connection.query(
         
     | 
| 
      
 73246 
     | 
    
         
            +
                          `select count(*) as count from \`${tableName}\``
         
     | 
| 
      
 73247 
     | 
    
         
            +
                        );
         
     | 
| 
      
 73248 
     | 
    
         
            +
                        const count = Number(res[0].count);
         
     | 
| 
      
 73249 
     | 
    
         
            +
                        if (count > 0) {
         
     | 
| 
      
 73250 
     | 
    
         
            +
                          infoToPrint.push(
         
     | 
| 
      
 73251 
     | 
    
         
            +
                            `\xB7 You're about to add not-null constraint to ${source_default.underline(
         
     | 
| 
      
 73252 
     | 
    
         
            +
                              statement.columnName
         
     | 
| 
      
 73253 
     | 
    
         
            +
                            )} column without default value, which contains ${count} items`
         
     | 
| 
      
 73254 
     | 
    
         
            +
                          );
         
     | 
| 
      
 73255 
     | 
    
         
            +
                          tablesToTruncate.push(tableName);
         
     | 
| 
      
 73256 
     | 
    
         
            +
                          statementsToExecute.push(`delete from \`${tableName}\``);
         
     | 
| 
      
 73257 
     | 
    
         
            +
                          shouldAskForApprove = true;
         
     | 
| 
      
 73258 
     | 
    
         
            +
                        }
         
     | 
| 
      
 73259 
     | 
    
         
            +
                      }
         
     | 
| 
      
 73260 
     | 
    
         
            +
                      const modifyStatements = new LibSQLModifyColumn().convert(statement, json2);
         
     | 
| 
      
 73261 
     | 
    
         
            +
                      statementsToExecute.push(
         
     | 
| 
      
 73262 
     | 
    
         
            +
                        ...Array.isArray(modifyStatements) ? modifyStatements : [modifyStatements]
         
     | 
| 
      
 73263 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73264 
     | 
    
         
            +
                    } else if (statement.type === "recreate_table") {
         
     | 
| 
      
 73265 
     | 
    
         
            +
                      const tableName = statement.tableName;
         
     | 
| 
      
 73266 
     | 
    
         
            +
                      let dataLoss = false;
         
     | 
| 
      
 73267 
     | 
    
         
            +
                      const oldTableName = getOldTableName3(tableName, meta);
         
     | 
| 
      
 73268 
     | 
    
         
            +
                      const prevColumnNames = Object.keys(json1.tables[oldTableName].columns);
         
     | 
| 
      
 73269 
     | 
    
         
            +
                      const currentColumnNames = Object.keys(json2.tables[tableName].columns);
         
     | 
| 
      
 73270 
     | 
    
         
            +
                      const { removedColumns, addedColumns } = findAddedAndRemoved(
         
     | 
| 
      
 73271 
     | 
    
         
            +
                        prevColumnNames,
         
     | 
| 
      
 73272 
     | 
    
         
            +
                        currentColumnNames
         
     | 
| 
      
 73273 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73274 
     | 
    
         
            +
                      if (removedColumns.length) {
         
     | 
| 
      
 73275 
     | 
    
         
            +
                        for (const removedColumn of removedColumns) {
         
     | 
| 
      
 73276 
     | 
    
         
            +
                          const res = await connection.query(
         
     | 
| 
      
 73277 
     | 
    
         
            +
                            `select count(\`${tableName}\`.\`${removedColumn}\`) as count from \`${tableName}\``
         
     | 
| 
      
 73278 
     | 
    
         
            +
                          );
         
     | 
| 
      
 73279 
     | 
    
         
            +
                          const count = Number(res[0].count);
         
     | 
| 
      
 73280 
     | 
    
         
            +
                          if (count > 0) {
         
     | 
| 
      
 73281 
     | 
    
         
            +
                            infoToPrint.push(
         
     | 
| 
      
 73282 
     | 
    
         
            +
                              `\xB7 You're about to delete ${source_default.underline(
         
     | 
| 
      
 73283 
     | 
    
         
            +
                                removedColumn
         
     | 
| 
      
 73284 
     | 
    
         
            +
                              )} column in ${tableName} table with ${count} items`
         
     | 
| 
      
 73285 
     | 
    
         
            +
                            );
         
     | 
| 
      
 73286 
     | 
    
         
            +
                            columnsToRemove.push(removedColumn);
         
     | 
| 
      
 73287 
     | 
    
         
            +
                            shouldAskForApprove = true;
         
     | 
| 
      
 73288 
     | 
    
         
            +
                          }
         
     | 
| 
      
 73289 
     | 
    
         
            +
                        }
         
     | 
| 
      
 73290 
     | 
    
         
            +
                      }
         
     | 
| 
      
 73291 
     | 
    
         
            +
                      if (addedColumns.length) {
         
     | 
| 
      
 73292 
     | 
    
         
            +
                        for (const addedColumn of addedColumns) {
         
     | 
| 
      
 73293 
     | 
    
         
            +
                          const [res] = await connection.query(
         
     | 
| 
      
 73294 
     | 
    
         
            +
                            `select count(*) as count from \`${tableName}\``
         
     | 
| 
      
 73295 
     | 
    
         
            +
                          );
         
     | 
| 
      
 73296 
     | 
    
         
            +
                          const columnConf = json2.tables[tableName].columns[addedColumn];
         
     | 
| 
      
 73297 
     | 
    
         
            +
                          const count = Number(res.count);
         
     | 
| 
      
 73298 
     | 
    
         
            +
                          if (count > 0 && columnConf.notNull && !columnConf.default) {
         
     | 
| 
      
 73299 
     | 
    
         
            +
                            dataLoss = true;
         
     | 
| 
      
 73300 
     | 
    
         
            +
                            infoToPrint.push(
         
     | 
| 
      
 73301 
     | 
    
         
            +
                              `\xB7 You're about to add not-null ${source_default.underline(
         
     | 
| 
      
 73302 
     | 
    
         
            +
                                addedColumn
         
     | 
| 
      
 73303 
     | 
    
         
            +
                              )} column without default value to table, which contains ${count} items`
         
     | 
| 
      
 73304 
     | 
    
         
            +
                            );
         
     | 
| 
      
 73305 
     | 
    
         
            +
                            shouldAskForApprove = true;
         
     | 
| 
      
 73306 
     | 
    
         
            +
                            tablesToTruncate.push(tableName);
         
     | 
| 
      
 73307 
     | 
    
         
            +
                            statementsToExecute.push(`DELETE FROM \`${tableName}\`;`);
         
     | 
| 
      
 73308 
     | 
    
         
            +
                          }
         
     | 
| 
      
 73309 
     | 
    
         
            +
                        }
         
     | 
| 
      
 73310 
     | 
    
         
            +
                      }
         
     | 
| 
      
 73311 
     | 
    
         
            +
                      const tablesReferencingCurrent = [];
         
     | 
| 
      
 73312 
     | 
    
         
            +
                      for (const table4 of Object.values(json2.tables)) {
         
     | 
| 
      
 73313 
     | 
    
         
            +
                        const tablesRefs = Object.values(json2.tables[table4.name].foreignKeys).filter((t2) => SQLiteSquasher.unsquashPushFK(t2).tableTo === tableName).map((it) => SQLiteSquasher.unsquashPushFK(it).tableFrom);
         
     | 
| 
      
 73314 
     | 
    
         
            +
                        tablesReferencingCurrent.push(...tablesRefs);
         
     | 
| 
      
 73315 
     | 
    
         
            +
                      }
         
     | 
| 
      
 73316 
     | 
    
         
            +
                      if (!tablesReferencingCurrent.length) {
         
     | 
| 
      
 73317 
     | 
    
         
            +
                        statementsToExecute.push(..._moveDataStatements2(tableName, json2, dataLoss));
         
     | 
| 
      
 73318 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 73319 
     | 
    
         
            +
                      }
         
     | 
| 
      
 73320 
     | 
    
         
            +
                      const [{ foreign_keys: pragmaState }] = await connection.query(`PRAGMA foreign_keys;`);
         
     | 
| 
      
 73321 
     | 
    
         
            +
                      if (pragmaState)
         
     | 
| 
      
 73322 
     | 
    
         
            +
                        statementsToExecute.push(`PRAGMA foreign_keys=OFF;`);
         
     | 
| 
      
 73323 
     | 
    
         
            +
                      statementsToExecute.push(
         
     | 
| 
      
 73324 
     | 
    
         
            +
                        ..._moveDataStatements2(tableName, json2, dataLoss)
         
     | 
| 
      
 73325 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73326 
     | 
    
         
            +
                      if (pragmaState)
         
     | 
| 
      
 73327 
     | 
    
         
            +
                        statementsToExecute.push(`PRAGMA foreign_keys=ON;`);
         
     | 
| 
      
 73328 
     | 
    
         
            +
                    } else if (statement.type === "alter_table_alter_column_set_generated" || statement.type === "alter_table_alter_column_drop_generated") {
         
     | 
| 
      
 73329 
     | 
    
         
            +
                      const tableName = statement.tableName;
         
     | 
| 
      
 73330 
     | 
    
         
            +
                      const res = await connection.query(
         
     | 
| 
      
 73331 
     | 
    
         
            +
                        `select count("${statement.columnName}") as count from \`${tableName}\``
         
     | 
| 
      
 73332 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73333 
     | 
    
         
            +
                      const count = Number(res[0].count);
         
     | 
| 
      
 73334 
     | 
    
         
            +
                      if (count > 0) {
         
     | 
| 
      
 73335 
     | 
    
         
            +
                        infoToPrint.push(
         
     | 
| 
      
 73336 
     | 
    
         
            +
                          `\xB7 You're about to delete ${source_default.underline(
         
     | 
| 
      
 73337 
     | 
    
         
            +
                            statement.columnName
         
     | 
| 
      
 73338 
     | 
    
         
            +
                          )} column in ${tableName} table with ${count} items`
         
     | 
| 
      
 73339 
     | 
    
         
            +
                        );
         
     | 
| 
      
 73340 
     | 
    
         
            +
                        columnsToRemove.push(`${tableName}_${statement.columnName}`);
         
     | 
| 
      
 73341 
     | 
    
         
            +
                        shouldAskForApprove = true;
         
     | 
| 
      
 73342 
     | 
    
         
            +
                      }
         
     | 
| 
      
 73343 
     | 
    
         
            +
                      const fromJsonStatement = fromJson([statement], "sqlite", "push", "turso", json2);
         
     | 
| 
      
 73344 
     | 
    
         
            +
                      statementsToExecute.push(
         
     | 
| 
      
 73345 
     | 
    
         
            +
                        ...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
         
     | 
| 
      
 73346 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73347 
     | 
    
         
            +
                    } else {
         
     | 
| 
      
 73348 
     | 
    
         
            +
                      const fromJsonStatement = fromJson([statement], "sqlite", "push", "turso", json2);
         
     | 
| 
      
 73349 
     | 
    
         
            +
                      statementsToExecute.push(
         
     | 
| 
      
 73350 
     | 
    
         
            +
                        ...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
         
     | 
| 
      
 73351 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73352 
     | 
    
         
            +
                    }
         
     | 
| 
      
 73353 
     | 
    
         
            +
                  }
         
     | 
| 
      
 73354 
     | 
    
         
            +
                  return {
         
     | 
| 
      
 73355 
     | 
    
         
            +
                    statementsToExecute: [...new Set(statementsToExecute)],
         
     | 
| 
      
 73356 
     | 
    
         
            +
                    shouldAskForApprove,
         
     | 
| 
      
 73357 
     | 
    
         
            +
                    infoToPrint,
         
     | 
| 
      
 73358 
     | 
    
         
            +
                    columnsToRemove: [...new Set(columnsToRemove)],
         
     | 
| 
      
 73359 
     | 
    
         
            +
                    tablesToTruncate: [...new Set(tablesToTruncate)],
         
     | 
| 
      
 73360 
     | 
    
         
            +
                    tablesToRemove: [...new Set(tablesToRemove)]
         
     | 
| 
      
 73361 
     | 
    
         
            +
                  };
         
     | 
| 
      
 73362 
     | 
    
         
            +
                };
         
     | 
| 
      
 73363 
     | 
    
         
            +
              }
         
     | 
| 
      
 73364 
     | 
    
         
            +
            });
         
     | 
| 
      
 73365 
     | 
    
         
            +
             
     | 
| 
       72208 
73366 
     | 
    
         
             
            // src/cli/commands/mysqlPushUtils.ts
         
     | 
| 
       72209 
     | 
    
         
            -
            var import_hanji6, filterStatements,  
     | 
| 
      
 73367 
     | 
    
         
            +
            var import_hanji6, filterStatements, logSuggestionsAndReturn2;
         
     | 
| 
       72210 
73368 
     | 
    
         
             
            var init_mysqlPushUtils = __esm({
         
     | 
| 
       72211 
73369 
     | 
    
         
             
              "src/cli/commands/mysqlPushUtils.ts"() {
         
     | 
| 
       72212 
73370 
     | 
    
         
             
                "use strict";
         
     | 
| 
         @@ -72256,7 +73414,7 @@ var init_mysqlPushUtils = __esm({ 
     | 
|
| 
       72256 
73414 
     | 
    
         
             
                    return true;
         
     | 
| 
       72257 
73415 
     | 
    
         
             
                  });
         
     | 
| 
       72258 
73416 
     | 
    
         
             
                };
         
     | 
| 
       72259 
     | 
    
         
            -
                 
     | 
| 
      
 73417 
     | 
    
         
            +
                logSuggestionsAndReturn2 = async (db, statements, json2) => {
         
     | 
| 
       72260 
73418 
     | 
    
         
             
                  let shouldAskForApprove = false;
         
     | 
| 
       72261 
73419 
     | 
    
         
             
                  const statementsToExecute = [];
         
     | 
| 
       72262 
73420 
     | 
    
         
             
                  const infoToPrint = [];
         
     | 
| 
         @@ -72697,289 +73855,6 @@ var init_pgPushUtils = __esm({ 
     | 
|
| 
       72697 
73855 
     | 
    
         
             
              }
         
     | 
| 
       72698 
73856 
     | 
    
         
             
            });
         
     | 
| 
       72699 
73857 
     | 
    
         | 
| 
       72700 
     | 
    
         
            -
            // src/cli/commands/sqlitePushUtils.ts
         
     | 
| 
       72701 
     | 
    
         
            -
            var _moveDataStatements, getOldTableName, getNewTableName, logSuggestionsAndReturn2;
         
     | 
| 
       72702 
     | 
    
         
            -
            var init_sqlitePushUtils = __esm({
         
     | 
| 
       72703 
     | 
    
         
            -
              "src/cli/commands/sqlitePushUtils.ts"() {
         
     | 
| 
       72704 
     | 
    
         
            -
                "use strict";
         
     | 
| 
       72705 
     | 
    
         
            -
                init_source();
         
     | 
| 
       72706 
     | 
    
         
            -
                init_sqliteSchema();
         
     | 
| 
       72707 
     | 
    
         
            -
                init_sqlgenerator();
         
     | 
| 
       72708 
     | 
    
         
            -
                _moveDataStatements = (tableName, json, dataLoss = false) => {
         
     | 
| 
       72709 
     | 
    
         
            -
                  const statements = [];
         
     | 
| 
       72710 
     | 
    
         
            -
                  statements.push(
         
     | 
| 
       72711 
     | 
    
         
            -
                    new SqliteRenameTableConvertor().convert({
         
     | 
| 
       72712 
     | 
    
         
            -
                      type: "rename_table",
         
     | 
| 
       72713 
     | 
    
         
            -
                      tableNameFrom: tableName,
         
     | 
| 
       72714 
     | 
    
         
            -
                      tableNameTo: `__old_push_${tableName}`,
         
     | 
| 
       72715 
     | 
    
         
            -
                      fromSchema: "",
         
     | 
| 
       72716 
     | 
    
         
            -
                      toSchema: ""
         
     | 
| 
       72717 
     | 
    
         
            -
                    })
         
     | 
| 
       72718 
     | 
    
         
            -
                  );
         
     | 
| 
       72719 
     | 
    
         
            -
                  const tableColumns = Object.values(json.tables[tableName].columns);
         
     | 
| 
       72720 
     | 
    
         
            -
                  const referenceData = Object.values(json.tables[tableName].foreignKeys);
         
     | 
| 
       72721 
     | 
    
         
            -
                  const compositePKs = Object.values(
         
     | 
| 
       72722 
     | 
    
         
            -
                    json.tables[tableName].compositePrimaryKeys
         
     | 
| 
       72723 
     | 
    
         
            -
                  ).map((it) => SQLiteSquasher.unsquashPK(it));
         
     | 
| 
       72724 
     | 
    
         
            -
                  const fks = referenceData.map((it) => SQLiteSquasher.unsquashPushFK(it));
         
     | 
| 
       72725 
     | 
    
         
            -
                  statements.push(
         
     | 
| 
       72726 
     | 
    
         
            -
                    new SQLiteCreateTableConvertor().convert({
         
     | 
| 
       72727 
     | 
    
         
            -
                      type: "sqlite_create_table",
         
     | 
| 
       72728 
     | 
    
         
            -
                      tableName,
         
     | 
| 
       72729 
     | 
    
         
            -
                      columns: tableColumns,
         
     | 
| 
       72730 
     | 
    
         
            -
                      referenceData: fks,
         
     | 
| 
       72731 
     | 
    
         
            -
                      compositePKs
         
     | 
| 
       72732 
     | 
    
         
            -
                    })
         
     | 
| 
       72733 
     | 
    
         
            -
                  );
         
     | 
| 
       72734 
     | 
    
         
            -
                  if (!dataLoss) {
         
     | 
| 
       72735 
     | 
    
         
            -
                    statements.push(
         
     | 
| 
       72736 
     | 
    
         
            -
                      `INSERT INTO "${tableName}" SELECT * FROM "__old_push_${tableName}";`
         
     | 
| 
       72737 
     | 
    
         
            -
                    );
         
     | 
| 
       72738 
     | 
    
         
            -
                  }
         
     | 
| 
       72739 
     | 
    
         
            -
                  statements.push(
         
     | 
| 
       72740 
     | 
    
         
            -
                    new SQLiteDropTableConvertor().convert({
         
     | 
| 
       72741 
     | 
    
         
            -
                      type: "drop_table",
         
     | 
| 
       72742 
     | 
    
         
            -
                      tableName: `__old_push_${tableName}`,
         
     | 
| 
       72743 
     | 
    
         
            -
                      schema: ""
         
     | 
| 
       72744 
     | 
    
         
            -
                    })
         
     | 
| 
       72745 
     | 
    
         
            -
                  );
         
     | 
| 
       72746 
     | 
    
         
            -
                  for (const idx of Object.values(json.tables[tableName].indexes)) {
         
     | 
| 
       72747 
     | 
    
         
            -
                    statements.push(
         
     | 
| 
       72748 
     | 
    
         
            -
                      new CreateSqliteIndexConvertor().convert({
         
     | 
| 
       72749 
     | 
    
         
            -
                        type: "create_index",
         
     | 
| 
       72750 
     | 
    
         
            -
                        tableName,
         
     | 
| 
       72751 
     | 
    
         
            -
                        schema: "",
         
     | 
| 
       72752 
     | 
    
         
            -
                        data: idx
         
     | 
| 
       72753 
     | 
    
         
            -
                      })
         
     | 
| 
       72754 
     | 
    
         
            -
                    );
         
     | 
| 
       72755 
     | 
    
         
            -
                  }
         
     | 
| 
       72756 
     | 
    
         
            -
                  return statements;
         
     | 
| 
       72757 
     | 
    
         
            -
                };
         
     | 
| 
       72758 
     | 
    
         
            -
                getOldTableName = (tableName, meta) => {
         
     | 
| 
       72759 
     | 
    
         
            -
                  for (const key of Object.keys(meta.tables)) {
         
     | 
| 
       72760 
     | 
    
         
            -
                    const value = meta.tables[key];
         
     | 
| 
       72761 
     | 
    
         
            -
                    if (`"${tableName}"` === value) {
         
     | 
| 
       72762 
     | 
    
         
            -
                      return key.substring(1, key.length - 1);
         
     | 
| 
       72763 
     | 
    
         
            -
                    }
         
     | 
| 
       72764 
     | 
    
         
            -
                  }
         
     | 
| 
       72765 
     | 
    
         
            -
                  return tableName;
         
     | 
| 
       72766 
     | 
    
         
            -
                };
         
     | 
| 
       72767 
     | 
    
         
            -
                getNewTableName = (tableName, meta) => {
         
     | 
| 
       72768 
     | 
    
         
            -
                  if (typeof meta.tables[`"${tableName}"`] !== "undefined") {
         
     | 
| 
       72769 
     | 
    
         
            -
                    return meta.tables[`"${tableName}"`].substring(
         
     | 
| 
       72770 
     | 
    
         
            -
                      1,
         
     | 
| 
       72771 
     | 
    
         
            -
                      meta.tables[`"${tableName}"`].length - 1
         
     | 
| 
       72772 
     | 
    
         
            -
                    );
         
     | 
| 
       72773 
     | 
    
         
            -
                  }
         
     | 
| 
       72774 
     | 
    
         
            -
                  return tableName;
         
     | 
| 
       72775 
     | 
    
         
            -
                };
         
     | 
| 
       72776 
     | 
    
         
            -
                logSuggestionsAndReturn2 = async (connection, statements, json1, json2, meta) => {
         
     | 
| 
       72777 
     | 
    
         
            -
                  let shouldAskForApprove = false;
         
     | 
| 
       72778 
     | 
    
         
            -
                  const statementsToExecute = [];
         
     | 
| 
       72779 
     | 
    
         
            -
                  const infoToPrint = [];
         
     | 
| 
       72780 
     | 
    
         
            -
                  const tablesToRemove = [];
         
     | 
| 
       72781 
     | 
    
         
            -
                  const columnsToRemove = [];
         
     | 
| 
       72782 
     | 
    
         
            -
                  const schemasToRemove = [];
         
     | 
| 
       72783 
     | 
    
         
            -
                  const tablesToTruncate = [];
         
     | 
| 
       72784 
     | 
    
         
            -
                  const tablesContext = {};
         
     | 
| 
       72785 
     | 
    
         
            -
                  for (const statement of statements) {
         
     | 
| 
       72786 
     | 
    
         
            -
                    if (statement.type === "drop_table") {
         
     | 
| 
       72787 
     | 
    
         
            -
                      const res = await connection.query(
         
     | 
| 
       72788 
     | 
    
         
            -
                        `select count(*) as count from \`${statement.tableName}\``
         
     | 
| 
       72789 
     | 
    
         
            -
                      );
         
     | 
| 
       72790 
     | 
    
         
            -
                      const count = Number(res[0].count);
         
     | 
| 
       72791 
     | 
    
         
            -
                      if (count > 0) {
         
     | 
| 
       72792 
     | 
    
         
            -
                        infoToPrint.push(
         
     | 
| 
       72793 
     | 
    
         
            -
                          `\xB7 You're about to delete ${source_default.underline(
         
     | 
| 
       72794 
     | 
    
         
            -
                            statement.tableName
         
     | 
| 
       72795 
     | 
    
         
            -
                          )} table with ${count} items`
         
     | 
| 
       72796 
     | 
    
         
            -
                        );
         
     | 
| 
       72797 
     | 
    
         
            -
                        tablesToRemove.push(statement.tableName);
         
     | 
| 
       72798 
     | 
    
         
            -
                        shouldAskForApprove = true;
         
     | 
| 
       72799 
     | 
    
         
            -
                      }
         
     | 
| 
       72800 
     | 
    
         
            -
                      const stmnt = fromJson([statement], "sqlite")[0];
         
     | 
| 
       72801 
     | 
    
         
            -
                      statementsToExecute.push(stmnt);
         
     | 
| 
       72802 
     | 
    
         
            -
                    } else if (statement.type === "alter_table_drop_column") {
         
     | 
| 
       72803 
     | 
    
         
            -
                      const newTableName = getOldTableName(statement.tableName, meta);
         
     | 
| 
       72804 
     | 
    
         
            -
                      const columnIsPartOfPk = Object.values(
         
     | 
| 
       72805 
     | 
    
         
            -
                        json1.tables[newTableName].compositePrimaryKeys
         
     | 
| 
       72806 
     | 
    
         
            -
                      ).find((c) => SQLiteSquasher.unsquashPK(c).includes(statement.columnName));
         
     | 
| 
       72807 
     | 
    
         
            -
                      const columnIsPartOfIndex = Object.values(
         
     | 
| 
       72808 
     | 
    
         
            -
                        json1.tables[newTableName].indexes
         
     | 
| 
       72809 
     | 
    
         
            -
                      ).find((c) => SQLiteSquasher.unsquashIdx(c).columns.includes(statement.columnName));
         
     | 
| 
       72810 
     | 
    
         
            -
                      const columnIsPk = json1.tables[newTableName].columns[statement.columnName].primaryKey;
         
     | 
| 
       72811 
     | 
    
         
            -
                      const columnIsPartOfFk = Object.values(
         
     | 
| 
       72812 
     | 
    
         
            -
                        json1.tables[newTableName].foreignKeys
         
     | 
| 
       72813 
     | 
    
         
            -
                      ).find(
         
     | 
| 
       72814 
     | 
    
         
            -
                        (t2) => SQLiteSquasher.unsquashPushFK(t2).columnsFrom.includes(
         
     | 
| 
       72815 
     | 
    
         
            -
                          statement.columnName
         
     | 
| 
       72816 
     | 
    
         
            -
                        )
         
     | 
| 
       72817 
     | 
    
         
            -
                      );
         
     | 
| 
       72818 
     | 
    
         
            -
                      const res = await connection.query(
         
     | 
| 
       72819 
     | 
    
         
            -
                        `select count(*) as count from \`${newTableName}\``
         
     | 
| 
       72820 
     | 
    
         
            -
                      );
         
     | 
| 
       72821 
     | 
    
         
            -
                      const count = Number(res[0].count);
         
     | 
| 
       72822 
     | 
    
         
            -
                      if (count > 0) {
         
     | 
| 
       72823 
     | 
    
         
            -
                        infoToPrint.push(
         
     | 
| 
       72824 
     | 
    
         
            -
                          `\xB7 You're about to delete ${source_default.underline(
         
     | 
| 
       72825 
     | 
    
         
            -
                            statement.columnName
         
     | 
| 
       72826 
     | 
    
         
            -
                          )} column in ${newTableName} table with ${count} items`
         
     | 
| 
       72827 
     | 
    
         
            -
                        );
         
     | 
| 
       72828 
     | 
    
         
            -
                        columnsToRemove.push(`${newTableName}_${statement.columnName}`);
         
     | 
| 
       72829 
     | 
    
         
            -
                        shouldAskForApprove = true;
         
     | 
| 
       72830 
     | 
    
         
            -
                      }
         
     | 
| 
       72831 
     | 
    
         
            -
                      if (columnIsPk || columnIsPartOfPk || columnIsPartOfIndex || columnIsPartOfFk) {
         
     | 
| 
       72832 
     | 
    
         
            -
                        tablesContext[newTableName] = [
         
     | 
| 
       72833 
     | 
    
         
            -
                          ..._moveDataStatements(statement.tableName, json2, true)
         
     | 
| 
       72834 
     | 
    
         
            -
                        ];
         
     | 
| 
       72835 
     | 
    
         
            -
                        const tablesReferncingCurrent = [];
         
     | 
| 
       72836 
     | 
    
         
            -
                        for (const table4 of Object.values(json1.tables)) {
         
     | 
| 
       72837 
     | 
    
         
            -
                          const tablesRefs = Object.values(json1.tables[table4.name].foreignKeys).filter(
         
     | 
| 
       72838 
     | 
    
         
            -
                            (t2) => SQLiteSquasher.unsquashPushFK(t2).tableTo === newTableName
         
     | 
| 
       72839 
     | 
    
         
            -
                          ).map((t2) => SQLiteSquasher.unsquashPushFK(t2).tableFrom);
         
     | 
| 
       72840 
     | 
    
         
            -
                          tablesReferncingCurrent.push(...tablesRefs);
         
     | 
| 
       72841 
     | 
    
         
            -
                        }
         
     | 
| 
       72842 
     | 
    
         
            -
                        const uniqueTableRefs = [...new Set(tablesReferncingCurrent)];
         
     | 
| 
       72843 
     | 
    
         
            -
                        for (const table4 of uniqueTableRefs) {
         
     | 
| 
       72844 
     | 
    
         
            -
                          if (typeof tablesContext[table4] === "undefined") {
         
     | 
| 
       72845 
     | 
    
         
            -
                            tablesContext[table4] = [..._moveDataStatements(table4, json2)];
         
     | 
| 
       72846 
     | 
    
         
            -
                          }
         
     | 
| 
       72847 
     | 
    
         
            -
                        }
         
     | 
| 
       72848 
     | 
    
         
            -
                      } else {
         
     | 
| 
       72849 
     | 
    
         
            -
                        if (typeof tablesContext[newTableName] === "undefined") {
         
     | 
| 
       72850 
     | 
    
         
            -
                          const stmnt = fromJson([statement], "sqlite")[0];
         
     | 
| 
       72851 
     | 
    
         
            -
                          statementsToExecute.push(stmnt);
         
     | 
| 
       72852 
     | 
    
         
            -
                        }
         
     | 
| 
       72853 
     | 
    
         
            -
                      }
         
     | 
| 
       72854 
     | 
    
         
            -
                    } else if (statement.type === "sqlite_alter_table_add_column") {
         
     | 
| 
       72855 
     | 
    
         
            -
                      const newTableName = getOldTableName(statement.tableName, meta);
         
     | 
| 
       72856 
     | 
    
         
            -
                      if (statement.column.notNull && !statement.column.default) {
         
     | 
| 
       72857 
     | 
    
         
            -
                        const res = await connection.query(
         
     | 
| 
       72858 
     | 
    
         
            -
                          `select count(*) as count from \`${newTableName}\``
         
     | 
| 
       72859 
     | 
    
         
            -
                        );
         
     | 
| 
       72860 
     | 
    
         
            -
                        const count = Number(res[0].count);
         
     | 
| 
       72861 
     | 
    
         
            -
                        if (count > 0) {
         
     | 
| 
       72862 
     | 
    
         
            -
                          infoToPrint.push(
         
     | 
| 
       72863 
     | 
    
         
            -
                            `\xB7 You're about to add not-null ${source_default.underline(
         
     | 
| 
       72864 
     | 
    
         
            -
                              statement.column.name
         
     | 
| 
       72865 
     | 
    
         
            -
                            )} column without default value, which contains ${count} items`
         
     | 
| 
       72866 
     | 
    
         
            -
                          );
         
     | 
| 
       72867 
     | 
    
         
            -
                          tablesToTruncate.push(newTableName);
         
     | 
| 
       72868 
     | 
    
         
            -
                          statementsToExecute.push(`delete from ${newTableName};`);
         
     | 
| 
       72869 
     | 
    
         
            -
                          shouldAskForApprove = true;
         
     | 
| 
       72870 
     | 
    
         
            -
                        }
         
     | 
| 
       72871 
     | 
    
         
            -
                      }
         
     | 
| 
       72872 
     | 
    
         
            -
                      if (statement.column.primaryKey) {
         
     | 
| 
       72873 
     | 
    
         
            -
                        tablesContext[newTableName] = [
         
     | 
| 
       72874 
     | 
    
         
            -
                          ..._moveDataStatements(statement.tableName, json2, true)
         
     | 
| 
       72875 
     | 
    
         
            -
                        ];
         
     | 
| 
       72876 
     | 
    
         
            -
                        const tablesReferncingCurrent = [];
         
     | 
| 
       72877 
     | 
    
         
            -
                        for (const table4 of Object.values(json1.tables)) {
         
     | 
| 
       72878 
     | 
    
         
            -
                          const tablesRefs = Object.values(json1.tables[table4.name].foreignKeys).filter(
         
     | 
| 
       72879 
     | 
    
         
            -
                            (t2) => SQLiteSquasher.unsquashPushFK(t2).tableTo === newTableName
         
     | 
| 
       72880 
     | 
    
         
            -
                          ).map((t2) => SQLiteSquasher.unsquashPushFK(t2).tableFrom);
         
     | 
| 
       72881 
     | 
    
         
            -
                          tablesReferncingCurrent.push(...tablesRefs);
         
     | 
| 
       72882 
     | 
    
         
            -
                        }
         
     | 
| 
       72883 
     | 
    
         
            -
                        const uniqueTableRefs = [...new Set(tablesReferncingCurrent)];
         
     | 
| 
       72884 
     | 
    
         
            -
                        for (const table4 of uniqueTableRefs) {
         
     | 
| 
       72885 
     | 
    
         
            -
                          if (typeof tablesContext[table4] === "undefined") {
         
     | 
| 
       72886 
     | 
    
         
            -
                            tablesContext[table4] = [..._moveDataStatements(table4, json2)];
         
     | 
| 
       72887 
     | 
    
         
            -
                          }
         
     | 
| 
       72888 
     | 
    
         
            -
                        }
         
     | 
| 
       72889 
     | 
    
         
            -
                      } else {
         
     | 
| 
       72890 
     | 
    
         
            -
                        if (typeof tablesContext[newTableName] === "undefined") {
         
     | 
| 
       72891 
     | 
    
         
            -
                          const stmnt = fromJson([statement], "sqlite")[0];
         
     | 
| 
       72892 
     | 
    
         
            -
                          statementsToExecute.push(stmnt);
         
     | 
| 
       72893 
     | 
    
         
            -
                        }
         
     | 
| 
       72894 
     | 
    
         
            -
                      }
         
     | 
| 
       72895 
     | 
    
         
            -
                    } 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") {
         
     | 
| 
       72896 
     | 
    
         
            -
                      if (!(statement.type === "alter_table_alter_column_set_notnull" && statement.columnPk)) {
         
     | 
| 
       72897 
     | 
    
         
            -
                        const newTableName = getOldTableName(statement.tableName, meta);
         
     | 
| 
       72898 
     | 
    
         
            -
                        if (statement.type === "alter_table_alter_column_set_notnull" && typeof statement.columnDefault === "undefined") {
         
     | 
| 
       72899 
     | 
    
         
            -
                          const res = await connection.query(
         
     | 
| 
       72900 
     | 
    
         
            -
                            `select count(*) as count from \`${newTableName}\``
         
     | 
| 
       72901 
     | 
    
         
            -
                          );
         
     | 
| 
       72902 
     | 
    
         
            -
                          const count = Number(res[0].count);
         
     | 
| 
       72903 
     | 
    
         
            -
                          if (count > 0) {
         
     | 
| 
       72904 
     | 
    
         
            -
                            infoToPrint.push(
         
     | 
| 
       72905 
     | 
    
         
            -
                              `\xB7 You're about to add not-null constraint to ${source_default.underline(
         
     | 
| 
       72906 
     | 
    
         
            -
                                statement.columnName
         
     | 
| 
       72907 
     | 
    
         
            -
                              )} column without default value, which contains ${count} items`
         
     | 
| 
       72908 
     | 
    
         
            -
                            );
         
     | 
| 
       72909 
     | 
    
         
            -
                            tablesToTruncate.push(newTableName);
         
     | 
| 
       72910 
     | 
    
         
            -
                            shouldAskForApprove = true;
         
     | 
| 
       72911 
     | 
    
         
            -
                          }
         
     | 
| 
       72912 
     | 
    
         
            -
                          tablesContext[newTableName] = _moveDataStatements(
         
     | 
| 
       72913 
     | 
    
         
            -
                            statement.tableName,
         
     | 
| 
       72914 
     | 
    
         
            -
                            json1,
         
     | 
| 
       72915 
     | 
    
         
            -
                            true
         
     | 
| 
       72916 
     | 
    
         
            -
                          );
         
     | 
| 
       72917 
     | 
    
         
            -
                        } else {
         
     | 
| 
       72918 
     | 
    
         
            -
                          if (typeof tablesContext[newTableName] === "undefined") {
         
     | 
| 
       72919 
     | 
    
         
            -
                            tablesContext[newTableName] = _moveDataStatements(
         
     | 
| 
       72920 
     | 
    
         
            -
                              statement.tableName,
         
     | 
| 
       72921 
     | 
    
         
            -
                              json1
         
     | 
| 
       72922 
     | 
    
         
            -
                            );
         
     | 
| 
       72923 
     | 
    
         
            -
                          }
         
     | 
| 
       72924 
     | 
    
         
            -
                        }
         
     | 
| 
       72925 
     | 
    
         
            -
                        const tablesReferncingCurrent = [];
         
     | 
| 
       72926 
     | 
    
         
            -
                        for (const table4 of Object.values(json1.tables)) {
         
     | 
| 
       72927 
     | 
    
         
            -
                          const tablesRefs = Object.values(json1.tables[table4.name].foreignKeys).filter(
         
     | 
| 
       72928 
     | 
    
         
            -
                            (t2) => SQLiteSquasher.unsquashPushFK(t2).tableTo === newTableName
         
     | 
| 
       72929 
     | 
    
         
            -
                          ).map((t2) => {
         
     | 
| 
       72930 
     | 
    
         
            -
                            return getNewTableName(
         
     | 
| 
       72931 
     | 
    
         
            -
                              SQLiteSquasher.unsquashPushFK(t2).tableFrom,
         
     | 
| 
       72932 
     | 
    
         
            -
                              meta
         
     | 
| 
       72933 
     | 
    
         
            -
                            );
         
     | 
| 
       72934 
     | 
    
         
            -
                          });
         
     | 
| 
       72935 
     | 
    
         
            -
                          tablesReferncingCurrent.push(...tablesRefs);
         
     | 
| 
       72936 
     | 
    
         
            -
                        }
         
     | 
| 
       72937 
     | 
    
         
            -
                        const uniqueTableRefs = [...new Set(tablesReferncingCurrent)];
         
     | 
| 
       72938 
     | 
    
         
            -
                        for (const table4 of uniqueTableRefs) {
         
     | 
| 
       72939 
     | 
    
         
            -
                          if (typeof tablesContext[table4] === "undefined") {
         
     | 
| 
       72940 
     | 
    
         
            -
                            tablesContext[table4] = [..._moveDataStatements(table4, json1)];
         
     | 
| 
       72941 
     | 
    
         
            -
                          }
         
     | 
| 
       72942 
     | 
    
         
            -
                        }
         
     | 
| 
       72943 
     | 
    
         
            -
                      }
         
     | 
| 
       72944 
     | 
    
         
            -
                    } else if (statement.type === "create_reference" || statement.type === "delete_reference" || statement.type === "alter_reference") {
         
     | 
| 
       72945 
     | 
    
         
            -
                      const fk4 = SQLiteSquasher.unsquashPushFK(statement.data);
         
     | 
| 
       72946 
     | 
    
         
            -
                      if (typeof tablesContext[statement.tableName] === "undefined") {
         
     | 
| 
       72947 
     | 
    
         
            -
                        tablesContext[statement.tableName] = _moveDataStatements(
         
     | 
| 
       72948 
     | 
    
         
            -
                          statement.tableName,
         
     | 
| 
       72949 
     | 
    
         
            -
                          json2
         
     | 
| 
       72950 
     | 
    
         
            -
                        );
         
     | 
| 
       72951 
     | 
    
         
            -
                      }
         
     | 
| 
       72952 
     | 
    
         
            -
                    } else if (statement.type === "create_composite_pk" || statement.type === "alter_composite_pk" || statement.type === "delete_composite_pk" || statement.type === "create_unique_constraint" || statement.type === "delete_unique_constraint") {
         
     | 
| 
       72953 
     | 
    
         
            -
                      const newTableName = getOldTableName(statement.tableName, meta);
         
     | 
| 
       72954 
     | 
    
         
            -
                      if (typeof tablesContext[newTableName] === "undefined") {
         
     | 
| 
       72955 
     | 
    
         
            -
                        tablesContext[newTableName] = _moveDataStatements(
         
     | 
| 
       72956 
     | 
    
         
            -
                          statement.tableName,
         
     | 
| 
       72957 
     | 
    
         
            -
                          json2
         
     | 
| 
       72958 
     | 
    
         
            -
                        );
         
     | 
| 
       72959 
     | 
    
         
            -
                      }
         
     | 
| 
       72960 
     | 
    
         
            -
                    } else {
         
     | 
| 
       72961 
     | 
    
         
            -
                      const stmnt = fromJson([statement], "sqlite");
         
     | 
| 
       72962 
     | 
    
         
            -
                      if (typeof stmnt !== "undefined") {
         
     | 
| 
       72963 
     | 
    
         
            -
                        statementsToExecute.push(...stmnt);
         
     | 
| 
       72964 
     | 
    
         
            -
                      }
         
     | 
| 
       72965 
     | 
    
         
            -
                    }
         
     | 
| 
       72966 
     | 
    
         
            -
                  }
         
     | 
| 
       72967 
     | 
    
         
            -
                  for (const context of Object.values(tablesContext)) {
         
     | 
| 
       72968 
     | 
    
         
            -
                    statementsToExecute.push(...context);
         
     | 
| 
       72969 
     | 
    
         
            -
                  }
         
     | 
| 
       72970 
     | 
    
         
            -
                  return {
         
     | 
| 
       72971 
     | 
    
         
            -
                    statementsToExecute,
         
     | 
| 
       72972 
     | 
    
         
            -
                    shouldAskForApprove,
         
     | 
| 
       72973 
     | 
    
         
            -
                    infoToPrint,
         
     | 
| 
       72974 
     | 
    
         
            -
                    columnsToRemove: [...new Set(columnsToRemove)],
         
     | 
| 
       72975 
     | 
    
         
            -
                    schemasToRemove: [...new Set(schemasToRemove)],
         
     | 
| 
       72976 
     | 
    
         
            -
                    tablesToTruncate: [...new Set(tablesToTruncate)],
         
     | 
| 
       72977 
     | 
    
         
            -
                    tablesToRemove: [...new Set(tablesToRemove)]
         
     | 
| 
       72978 
     | 
    
         
            -
                  };
         
     | 
| 
       72979 
     | 
    
         
            -
                };
         
     | 
| 
       72980 
     | 
    
         
            -
              }
         
     | 
| 
       72981 
     | 
    
         
            -
            });
         
     | 
| 
       72982 
     | 
    
         
            -
             
     | 
| 
       72983 
73858 
     | 
    
         
             
            // ../node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/brace-expressions.js
         
     | 
| 
       72984 
73859 
     | 
    
         
             
            var posixClasses, braceEscape, regexpEscape, rangesToString, parseClass;
         
     | 
| 
       72985 
73860 
     | 
    
         
             
            var init_brace_expressions = __esm({
         
     | 
| 
         @@ -74542,11 +75417,12 @@ var init_sqliteIntrospect = __esm({ 
     | 
|
| 
       74542 
75417 
     | 
    
         
             
            // src/cli/commands/push.ts
         
     | 
| 
       74543 
75418 
     | 
    
         
             
            var push_exports = {};
         
     | 
| 
       74544 
75419 
     | 
    
         
             
            __export(push_exports, {
         
     | 
| 
      
 75420 
     | 
    
         
            +
              libSQLPush: () => libSQLPush,
         
     | 
| 
       74545 
75421 
     | 
    
         
             
              mysqlPush: () => mysqlPush,
         
     | 
| 
       74546 
75422 
     | 
    
         
             
              pgPush: () => pgPush,
         
     | 
| 
       74547 
75423 
     | 
    
         
             
              sqlitePush: () => sqlitePush
         
     | 
| 
       74548 
75424 
     | 
    
         
             
            });
         
     | 
| 
       74549 
     | 
    
         
            -
            var import_hanji11, mysqlPush, pgPush, sqlitePush;
         
     | 
| 
      
 75425 
     | 
    
         
            +
            var import_hanji11, mysqlPush, pgPush, sqlitePush, libSQLPush;
         
     | 
| 
       74550 
75426 
     | 
    
         
             
            var init_push = __esm({
         
     | 
| 
       74551 
75427 
     | 
    
         
             
              "src/cli/commands/push.ts"() {
         
     | 
| 
       74552 
75428 
     | 
    
         
             
                "use strict";
         
     | 
| 
         @@ -74555,6 +75431,7 @@ var init_push = __esm({ 
     | 
|
| 
       74555 
75431 
     | 
    
         
             
                init_sqlgenerator();
         
     | 
| 
       74556 
75432 
     | 
    
         
             
                init_selector_ui();
         
     | 
| 
       74557 
75433 
     | 
    
         
             
                init_outputs();
         
     | 
| 
      
 75434 
     | 
    
         
            +
                init_libSqlPushUtils();
         
     | 
| 
       74558 
75435 
     | 
    
         
             
                init_mysqlPushUtils();
         
     | 
| 
       74559 
75436 
     | 
    
         
             
                init_pgPushUtils();
         
     | 
| 
       74560 
75437 
     | 
    
         
             
                init_sqlitePushUtils();
         
     | 
| 
         @@ -74582,7 +75459,7 @@ var init_push = __esm({ 
     | 
|
| 
       74582 
75459 
     | 
    
         
             
                        tablesToTruncate,
         
     | 
| 
       74583 
75460 
     | 
    
         
             
                        infoToPrint,
         
     | 
| 
       74584 
75461 
     | 
    
         
             
                        schemasToRemove
         
     | 
| 
       74585 
     | 
    
         
            -
                      } = await  
     | 
| 
      
 75462 
     | 
    
         
            +
                      } = await logSuggestionsAndReturn2(
         
     | 
| 
       74586 
75463 
     | 
    
         
             
                        db,
         
     | 
| 
       74587 
75464 
     | 
    
         
             
                        filteredStatements,
         
     | 
| 
       74588 
75465 
     | 
    
         
             
                        statements.validatedCur
         
     | 
| 
         @@ -74601,7 +75478,6 @@ var init_push = __esm({ 
     | 
|
| 
       74601 
75478 
     | 
    
         
             
                        }
         
     | 
| 
       74602 
75479 
     | 
    
         
             
                      });
         
     | 
| 
       74603 
75480 
     | 
    
         
             
                      if (verbose) {
         
     | 
| 
       74604 
     | 
    
         
            -
                        console.log();
         
     | 
| 
       74605 
75481 
     | 
    
         
             
                        console.log(
         
     | 
| 
       74606 
75482 
     | 
    
         
             
                          withStyle.warning("You are about to execute current statements:")
         
     | 
| 
       74607 
75483 
     | 
    
         
             
                        );
         
     | 
| 
         @@ -74752,11 +75628,100 @@ var init_push = __esm({ 
     | 
|
| 
       74752 
75628 
     | 
    
         
             
                      tablesToTruncate,
         
     | 
| 
       74753 
75629 
     | 
    
         
             
                      infoToPrint,
         
     | 
| 
       74754 
75630 
     | 
    
         
             
                      schemasToRemove
         
     | 
| 
       74755 
     | 
    
         
            -
                    } = await  
     | 
| 
      
 75631 
     | 
    
         
            +
                    } = await logSuggestionsAndReturn(
         
     | 
| 
       74756 
75632 
     | 
    
         
             
                      db,
         
     | 
| 
       74757 
75633 
     | 
    
         
             
                      statements.statements,
         
     | 
| 
      
 75634 
     | 
    
         
            +
                      statements.squashedPrev,
         
     | 
| 
       74758 
75635 
     | 
    
         
             
                      statements.squashedCur,
         
     | 
| 
      
 75636 
     | 
    
         
            +
                      statements.meta
         
     | 
| 
      
 75637 
     | 
    
         
            +
                    );
         
     | 
| 
      
 75638 
     | 
    
         
            +
                    if (verbose && statementsToExecute.length > 0) {
         
     | 
| 
      
 75639 
     | 
    
         
            +
                      console.log();
         
     | 
| 
      
 75640 
     | 
    
         
            +
                      console.log(
         
     | 
| 
      
 75641 
     | 
    
         
            +
                        withStyle.warning("You are about to execute current statements:")
         
     | 
| 
      
 75642 
     | 
    
         
            +
                      );
         
     | 
| 
      
 75643 
     | 
    
         
            +
                      console.log();
         
     | 
| 
      
 75644 
     | 
    
         
            +
                      console.log(statementsToExecute.map((s2) => source_default.blue(s2)).join("\n"));
         
     | 
| 
      
 75645 
     | 
    
         
            +
                      console.log();
         
     | 
| 
      
 75646 
     | 
    
         
            +
                    }
         
     | 
| 
      
 75647 
     | 
    
         
            +
                    if (!force && strict) {
         
     | 
| 
      
 75648 
     | 
    
         
            +
                      if (!shouldAskForApprove) {
         
     | 
| 
      
 75649 
     | 
    
         
            +
                        const { status, data } = await (0, import_hanji11.render)(
         
     | 
| 
      
 75650 
     | 
    
         
            +
                          new Select(["No, abort", `Yes, I want to execute all statements`])
         
     | 
| 
      
 75651 
     | 
    
         
            +
                        );
         
     | 
| 
      
 75652 
     | 
    
         
            +
                        if ((data == null ? void 0 : data.index) === 0) {
         
     | 
| 
      
 75653 
     | 
    
         
            +
                          (0, import_hanji11.render)(`[${source_default.red("x")}] All changes were aborted`);
         
     | 
| 
      
 75654 
     | 
    
         
            +
                          process.exit(0);
         
     | 
| 
      
 75655 
     | 
    
         
            +
                        }
         
     | 
| 
      
 75656 
     | 
    
         
            +
                      }
         
     | 
| 
      
 75657 
     | 
    
         
            +
                    }
         
     | 
| 
      
 75658 
     | 
    
         
            +
                    if (!force && shouldAskForApprove) {
         
     | 
| 
      
 75659 
     | 
    
         
            +
                      console.log(withStyle.warning("Found data-loss statements:"));
         
     | 
| 
      
 75660 
     | 
    
         
            +
                      console.log(infoToPrint.join("\n"));
         
     | 
| 
      
 75661 
     | 
    
         
            +
                      console.log();
         
     | 
| 
      
 75662 
     | 
    
         
            +
                      console.log(
         
     | 
| 
      
 75663 
     | 
    
         
            +
                        source_default.red.bold(
         
     | 
| 
      
 75664 
     | 
    
         
            +
                          "THIS ACTION WILL CAUSE DATA LOSS AND CANNOT BE REVERTED\n"
         
     | 
| 
      
 75665 
     | 
    
         
            +
                        )
         
     | 
| 
      
 75666 
     | 
    
         
            +
                      );
         
     | 
| 
      
 75667 
     | 
    
         
            +
                      console.log(source_default.white("Do you still want to push changes?"));
         
     | 
| 
      
 75668 
     | 
    
         
            +
                      const { status, data } = await (0, import_hanji11.render)(
         
     | 
| 
      
 75669 
     | 
    
         
            +
                        new Select([
         
     | 
| 
      
 75670 
     | 
    
         
            +
                          "No, abort",
         
     | 
| 
      
 75671 
     | 
    
         
            +
                          `Yes, I want to${tablesToRemove.length > 0 ? ` remove ${tablesToRemove.length} ${tablesToRemove.length > 1 ? "tables" : "table"},` : " "}${columnsToRemove.length > 0 ? ` remove ${columnsToRemove.length} ${columnsToRemove.length > 1 ? "columns" : "column"},` : " "}${tablesToTruncate.length > 0 ? ` truncate ${tablesToTruncate.length} ${tablesToTruncate.length > 1 ? "tables" : "table"}` : ""}`.trimEnd().replace(/(^,)|(,$)/g, "").replace(/ +(?= )/g, "")
         
     | 
| 
      
 75672 
     | 
    
         
            +
                        ])
         
     | 
| 
      
 75673 
     | 
    
         
            +
                      );
         
     | 
| 
      
 75674 
     | 
    
         
            +
                      if ((data == null ? void 0 : data.index) === 0) {
         
     | 
| 
      
 75675 
     | 
    
         
            +
                        (0, import_hanji11.render)(`[${source_default.red("x")}] All changes were aborted`);
         
     | 
| 
      
 75676 
     | 
    
         
            +
                        process.exit(0);
         
     | 
| 
      
 75677 
     | 
    
         
            +
                      }
         
     | 
| 
      
 75678 
     | 
    
         
            +
                    }
         
     | 
| 
      
 75679 
     | 
    
         
            +
                    if (statementsToExecute.length === 0) {
         
     | 
| 
      
 75680 
     | 
    
         
            +
                      (0, import_hanji11.render)(`
         
     | 
| 
      
 75681 
     | 
    
         
            +
            [${source_default.blue("i")}] No changes detected`);
         
     | 
| 
      
 75682 
     | 
    
         
            +
                    } else {
         
     | 
| 
      
 75683 
     | 
    
         
            +
                      if (!("driver" in credentials2)) {
         
     | 
| 
      
 75684 
     | 
    
         
            +
                        await db.query("begin");
         
     | 
| 
      
 75685 
     | 
    
         
            +
                        try {
         
     | 
| 
      
 75686 
     | 
    
         
            +
                          for (const dStmnt of statementsToExecute) {
         
     | 
| 
      
 75687 
     | 
    
         
            +
                            await db.query(dStmnt);
         
     | 
| 
      
 75688 
     | 
    
         
            +
                          }
         
     | 
| 
      
 75689 
     | 
    
         
            +
                          await db.query("commit");
         
     | 
| 
      
 75690 
     | 
    
         
            +
                        } catch (e2) {
         
     | 
| 
      
 75691 
     | 
    
         
            +
                          console.error(e2);
         
     | 
| 
      
 75692 
     | 
    
         
            +
                          await db.query("rollback");
         
     | 
| 
      
 75693 
     | 
    
         
            +
                          process.exit(1);
         
     | 
| 
      
 75694 
     | 
    
         
            +
                        }
         
     | 
| 
      
 75695 
     | 
    
         
            +
                      } else if (credentials2.driver === "turso") {
         
     | 
| 
      
 75696 
     | 
    
         
            +
                        await db.batch(statementsToExecute.map((it) => ({ query: it })));
         
     | 
| 
      
 75697 
     | 
    
         
            +
                      }
         
     | 
| 
      
 75698 
     | 
    
         
            +
                      (0, import_hanji11.render)(`[${source_default.green("\u2713")}] Changes applied`);
         
     | 
| 
      
 75699 
     | 
    
         
            +
                    }
         
     | 
| 
      
 75700 
     | 
    
         
            +
                  }
         
     | 
| 
      
 75701 
     | 
    
         
            +
                };
         
     | 
| 
      
 75702 
     | 
    
         
            +
                libSQLPush = async (schemaPath, verbose, strict, credentials2, tablesFilter, force) => {
         
     | 
| 
      
 75703 
     | 
    
         
            +
                  const { connectToSQLite: connectToSQLite2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
         
     | 
| 
      
 75704 
     | 
    
         
            +
                  const { sqlitePushIntrospect: sqlitePushIntrospect2 } = await Promise.resolve().then(() => (init_sqliteIntrospect(), sqliteIntrospect_exports));
         
     | 
| 
      
 75705 
     | 
    
         
            +
                  const db = await connectToSQLite2(credentials2);
         
     | 
| 
      
 75706 
     | 
    
         
            +
                  const { schema: schema5 } = await sqlitePushIntrospect2(db, tablesFilter);
         
     | 
| 
      
 75707 
     | 
    
         
            +
                  const { prepareLibSQLPush: prepareLibSQLPush2 } = await Promise.resolve().then(() => (init_migrate(), migrate_exports));
         
     | 
| 
      
 75708 
     | 
    
         
            +
                  const statements = await prepareLibSQLPush2(schemaPath, schema5);
         
     | 
| 
      
 75709 
     | 
    
         
            +
                  if (statements.sqlStatements.length === 0) {
         
     | 
| 
      
 75710 
     | 
    
         
            +
                    (0, import_hanji11.render)(`
         
     | 
| 
      
 75711 
     | 
    
         
            +
            [${source_default.blue("i")}] No changes detected`);
         
     | 
| 
      
 75712 
     | 
    
         
            +
                  } else {
         
     | 
| 
      
 75713 
     | 
    
         
            +
                    const {
         
     | 
| 
      
 75714 
     | 
    
         
            +
                      shouldAskForApprove,
         
     | 
| 
      
 75715 
     | 
    
         
            +
                      statementsToExecute,
         
     | 
| 
      
 75716 
     | 
    
         
            +
                      columnsToRemove,
         
     | 
| 
      
 75717 
     | 
    
         
            +
                      tablesToRemove,
         
     | 
| 
      
 75718 
     | 
    
         
            +
                      tablesToTruncate,
         
     | 
| 
      
 75719 
     | 
    
         
            +
                      infoToPrint
         
     | 
| 
      
 75720 
     | 
    
         
            +
                    } = await libSqlLogSuggestionsAndReturn(
         
     | 
| 
      
 75721 
     | 
    
         
            +
                      db,
         
     | 
| 
      
 75722 
     | 
    
         
            +
                      statements.statements,
         
     | 
| 
       74759 
75723 
     | 
    
         
             
                      statements.squashedPrev,
         
     | 
| 
      
 75724 
     | 
    
         
            +
                      statements.squashedCur,
         
     | 
| 
       74760 
75725 
     | 
    
         
             
                      statements.meta
         
     | 
| 
       74761 
75726 
     | 
    
         
             
                    );
         
     | 
| 
       74762 
75727 
     | 
    
         
             
                    if (verbose && statementsToExecute.length > 0) {
         
     | 
| 
         @@ -83109,7 +84074,7 @@ var push = command({ 
     | 
|
| 
       83109 
84074 
     | 
    
         
             
                      schemasFilter,
         
     | 
| 
       83110 
84075 
     | 
    
         
             
                      force
         
     | 
| 
       83111 
84076 
     | 
    
         
             
                    );
         
     | 
| 
       83112 
     | 
    
         
            -
                  } else if (dialect7 === "sqlite") {
         
     | 
| 
      
 84077 
     | 
    
         
            +
                  } else if (dialect7 === "sqlite" && !("driver" in credentials2)) {
         
     | 
| 
       83113 
84078 
     | 
    
         
             
                    const { sqlitePush: sqlitePush2 } = await Promise.resolve().then(() => (init_push(), push_exports));
         
     | 
| 
       83114 
84079 
     | 
    
         
             
                    await sqlitePush2(
         
     | 
| 
       83115 
84080 
     | 
    
         
             
                      schemaPath,
         
     | 
| 
         @@ -83119,6 +84084,16 @@ var push = command({ 
     | 
|
| 
       83119 
84084 
     | 
    
         
             
                      tablesFilter,
         
     | 
| 
       83120 
84085 
     | 
    
         
             
                      force
         
     | 
| 
       83121 
84086 
     | 
    
         
             
                    );
         
     | 
| 
      
 84087 
     | 
    
         
            +
                  } else if (dialect7 === "sqlite" && ("driver" in credentials2 && credentials2.driver === "turso")) {
         
     | 
| 
      
 84088 
     | 
    
         
            +
                    const { libSQLPush: libSQLPush2 } = await Promise.resolve().then(() => (init_push(), push_exports));
         
     | 
| 
      
 84089 
     | 
    
         
            +
                    await libSQLPush2(
         
     | 
| 
      
 84090 
     | 
    
         
            +
                      schemaPath,
         
     | 
| 
      
 84091 
     | 
    
         
            +
                      verbose,
         
     | 
| 
      
 84092 
     | 
    
         
            +
                      strict,
         
     | 
| 
      
 84093 
     | 
    
         
            +
                      credentials2,
         
     | 
| 
      
 84094 
     | 
    
         
            +
                      tablesFilter,
         
     | 
| 
      
 84095 
     | 
    
         
            +
                      force
         
     | 
| 
      
 84096 
     | 
    
         
            +
                    );
         
     | 
| 
       83122 
84097 
     | 
    
         
             
                  } else {
         
     | 
| 
       83123 
84098 
     | 
    
         
             
                    assertUnreachable(dialect7);
         
     | 
| 
       83124 
84099 
     | 
    
         
             
                  }
         
     | 
| 
         @@ -83402,7 +84377,7 @@ init_utils2(); 
     | 
|
| 
       83402 
84377 
     | 
    
         
             
            var version2 = async () => {
         
     | 
| 
       83403 
84378 
     | 
    
         
             
              const { npmVersion } = await ormCoreVersions();
         
     | 
| 
       83404 
84379 
     | 
    
         
             
              const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
         
     | 
| 
       83405 
     | 
    
         
            -
              const envVersion = "0.24.0- 
     | 
| 
      
 84380 
     | 
    
         
            +
              const envVersion = "0.24.0-bb966f7";
         
     | 
| 
       83406 
84381 
     | 
    
         
             
              const kitVersion = envVersion ? `v${envVersion}` : "--";
         
     | 
| 
       83407 
84382 
     | 
    
         
             
              const versions = `drizzle-kit: ${kitVersion}
         
     | 
| 
       83408 
84383 
     | 
    
         
             
            ${ormVersion}`;
         
     |