drizzle-kit 0.24.2-5be80aa → 0.24.2-6fbcf46
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 +651 -1229
- package/api.mjs +651 -1229
- package/bin.cjs +47555 -50804
- package/index.d.mts +4 -3
- package/index.d.ts +4 -3
- package/package.json +2 -2
- package/utils.js +0 -11
- package/utils.mjs +0 -10
    
        package/api.js
    CHANGED
    
    | @@ -8361,13 +8361,6 @@ var init_sqliteSchema = __esm({ | |
| 8361 8361 | 
             
            function isPgArrayType(sqlType) {
         | 
| 8362 8362 | 
             
              return sqlType.match(/.*\[\d*\].*|.*\[\].*/g) !== null;
         | 
| 8363 8363 | 
             
            }
         | 
| 8364 | 
            -
            function findAddedAndRemoved(columnNames1, columnNames2) {
         | 
| 8365 | 
            -
              const set1 = new Set(columnNames1);
         | 
| 8366 | 
            -
              const set2 = new Set(columnNames2);
         | 
| 8367 | 
            -
              const addedColumns = columnNames2.filter((it) => !set1.has(it));
         | 
| 8368 | 
            -
              const removedColumns = columnNames1.filter((it) => !set2.has(it));
         | 
| 8369 | 
            -
              return { addedColumns, removedColumns };
         | 
| 8370 | 
            -
            }
         | 
| 8371 8364 | 
             
            var copy, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey;
         | 
| 8372 8365 | 
             
            var init_utils = __esm({
         | 
| 8373 8366 | 
             
              "src/utils.ts"() {
         | 
| @@ -11477,20 +11470,7 @@ var init_jsonDiffer = __esm({ | |
| 11477 11470 | 
             
            });
         | 
| 11478 11471 |  | 
| 11479 11472 | 
             
            // src/sqlgenerator.ts
         | 
| 11480 | 
            -
             | 
| 11481 | 
            -
              const result = statements.flatMap((statement) => {
         | 
| 11482 | 
            -
                const filtered = convertors.filter((it) => {
         | 
| 11483 | 
            -
                  return it.can(statement, dialect7);
         | 
| 11484 | 
            -
                });
         | 
| 11485 | 
            -
                const convertor = filtered.length === 1 ? filtered[0] : void 0;
         | 
| 11486 | 
            -
                if (!convertor) {
         | 
| 11487 | 
            -
                  return "";
         | 
| 11488 | 
            -
                }
         | 
| 11489 | 
            -
                return convertor.convert(statement, json2, action);
         | 
| 11490 | 
            -
              }).filter((it) => it !== "");
         | 
| 11491 | 
            -
              return result;
         | 
| 11492 | 
            -
            }
         | 
| 11493 | 
            -
            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;
         | 
| 11473 | 
            +
            var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, SQLiteAlterTableAddUniqueConstraintConvertor, SQLiteAlterTableDropUniqueConstraintConvertor, CreatePgSequenceConvertor, DropPgSequenceConvertor, RenamePgSequenceConvertor, MovePgSequenceConvertor, AlterPgSequenceConvertor, CreateTypeEnumConvertor, AlterTypeAddValueConvertor, PgDropTableConvertor, MySQLDropTableConvertor, SQLiteDropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, SQLiteAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, SqliteAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, PgAlterTableAlterColumnDropGeneratedConvertor, PgAlterTableAlterColumnSetExpressionConvertor, PgAlterTableAlterColumnAlterrGeneratedConvertor, SqliteAlterTableAlterColumnDropGeneratedConvertor, SqliteAlterTableAlterColumnSetExpressionConvertor, SqliteAlterTableAlterColumnAlterGeneratedConvertor, MySqlAlterTableAlterColumnAlterrGeneratedConvertor, MySqlAlterTableAddPk, MySqlAlterTableDropPk, MySqlModifyColumn, SqliteAlterTableAlterColumnDropDefaultConvertor, PgAlterTableCreateCompositePrimaryKeyConvertor, PgAlterTableDeleteCompositePrimaryKeyConvertor, PgAlterTableAlterCompositePrimaryKeyConvertor, MySqlAlterTableCreateCompositePrimaryKeyConvertor, MySqlAlterTableDeleteCompositePrimaryKeyConvertor, MySqlAlterTableAlterCompositePrimaryKeyConvertor, SqliteAlterTableCreateCompositePrimaryKeyConvertor, SqliteAlterTableDeleteCompositePrimaryKeyConvertor, SqliteAlterTableAlterCompositePrimaryKeyConvertor, PgAlterTableAlterColumnSetPrimaryKeyConvertor, PgAlterTableAlterColumnDropPrimaryKeyConvertor, PgAlterTableAlterColumnSetNotNullConvertor, SqliteAlterTableAlterColumnSetNotNullConvertor, SqliteAlterTableAlterColumnSetAutoincrementConvertor, SqliteAlterTableAlterColumnDropAutoincrementConvertor, PgAlterTableAlterColumnDropNotNullConvertor, SqliteAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, SqliteCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, SqliteAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, SqliteDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, PgCreateSchemaConvertor, PgRenameSchemaConvertor, PgDropSchemaConvertor, PgAlterTableSetSchemaConvertor, PgAlterTableSetNewSchemaConvertor, PgAlterTableRemoveFromSchemaConvertor, SqliteDropIndexConvertor, MySqlDropIndexConvertor, convertors, fromJson;
         | 
| 11494 11474 | 
             
            var init_sqlgenerator = __esm({
         | 
| 11495 11475 | 
             
              "src/sqlgenerator.ts"() {
         | 
| 11496 11476 | 
             
                "use strict";
         | 
| @@ -11642,7 +11622,7 @@ var init_sqlgenerator = __esm({ | |
| 11642 11622 | 
             
                };
         | 
| 11643 11623 | 
             
                SQLiteCreateTableConvertor = class extends Convertor {
         | 
| 11644 11624 | 
             
                  can(statement, dialect7) {
         | 
| 11645 | 
            -
                    return statement.type === "sqlite_create_table" &&  | 
| 11625 | 
            +
                    return statement.type === "sqlite_create_table" && dialect7 === "sqlite";
         | 
| 11646 11626 | 
             
                  }
         | 
| 11647 11627 | 
             
                  convert(st) {
         | 
| 11648 11628 | 
             
                    const {
         | 
| @@ -11812,6 +11792,32 @@ var init_sqlgenerator = __esm({ | |
| 11812 11792 | 
             
                    return `ALTER TABLE \`${statement.tableName}\` DROP INDEX \`${unsquashed.name}\`;`;
         | 
| 11813 11793 | 
             
                  }
         | 
| 11814 11794 | 
             
                };
         | 
| 11795 | 
            +
                SQLiteAlterTableAddUniqueConstraintConvertor = class extends Convertor {
         | 
| 11796 | 
            +
                  can(statement, dialect7) {
         | 
| 11797 | 
            +
                    return statement.type === "create_unique_constraint" && dialect7 === "sqlite";
         | 
| 11798 | 
            +
                  }
         | 
| 11799 | 
            +
                  convert(statement) {
         | 
| 11800 | 
            +
                    return `/*
         | 
| 11801 | 
            +
             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
         | 
| 11802 | 
            +
             Please refer to: https://www.techonthenet.com/sqlite/unique.php
         | 
| 11803 | 
            +
             | 
| 11804 | 
            +
             Due to that we don't generate migration automatically and it has to be done manually
         | 
| 11805 | 
            +
            */`;
         | 
| 11806 | 
            +
                  }
         | 
| 11807 | 
            +
                };
         | 
| 11808 | 
            +
                SQLiteAlterTableDropUniqueConstraintConvertor = class extends Convertor {
         | 
| 11809 | 
            +
                  can(statement, dialect7) {
         | 
| 11810 | 
            +
                    return statement.type === "delete_unique_constraint" && dialect7 === "sqlite";
         | 
| 11811 | 
            +
                  }
         | 
| 11812 | 
            +
                  convert(statement) {
         | 
| 11813 | 
            +
                    return `/*
         | 
| 11814 | 
            +
             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
         | 
| 11815 | 
            +
             Please refer to: https://www.techonthenet.com/sqlite/unique.php
         | 
| 11816 | 
            +
             | 
| 11817 | 
            +
             Due to that we don't generate migration automatically and it has to be done manually
         | 
| 11818 | 
            +
            */`;
         | 
| 11819 | 
            +
                  }
         | 
| 11820 | 
            +
                };
         | 
| 11815 11821 | 
             
                CreatePgSequenceConvertor = class extends Convertor {
         | 
| 11816 11822 | 
             
                  can(statement, dialect7) {
         | 
| 11817 11823 | 
             
                    return statement.type === "create_sequence" && dialect7 === "postgresql";
         | 
| @@ -11919,7 +11925,7 @@ var init_sqlgenerator = __esm({ | |
| 11919 11925 | 
             
                };
         | 
| 11920 11926 | 
             
                SQLiteDropTableConvertor = class extends Convertor {
         | 
| 11921 11927 | 
             
                  can(statement, dialect7) {
         | 
| 11922 | 
            -
                    return statement.type === "drop_table" &&  | 
| 11928 | 
            +
                    return statement.type === "drop_table" && dialect7 === "sqlite";
         | 
| 11923 11929 | 
             
                  }
         | 
| 11924 11930 | 
             
                  convert(statement) {
         | 
| 11925 11931 | 
             
                    const { tableName } = statement;
         | 
| @@ -11939,7 +11945,7 @@ var init_sqlgenerator = __esm({ | |
| 11939 11945 | 
             
                };
         | 
| 11940 11946 | 
             
                SqliteRenameTableConvertor = class extends Convertor {
         | 
| 11941 11947 | 
             
                  can(statement, dialect7) {
         | 
| 11942 | 
            -
                    return statement.type === "rename_table" &&  | 
| 11948 | 
            +
                    return statement.type === "rename_table" && dialect7 === "sqlite";
         | 
| 11943 11949 | 
             
                  }
         | 
| 11944 11950 | 
             
                  convert(statement) {
         | 
| 11945 11951 | 
             
                    const { tableNameFrom, tableNameTo } = statement;
         | 
| @@ -11976,11 +11982,11 @@ var init_sqlgenerator = __esm({ | |
| 11976 11982 | 
             
                };
         | 
| 11977 11983 | 
             
                SQLiteAlterTableRenameColumnConvertor = class extends Convertor {
         | 
| 11978 11984 | 
             
                  can(statement, dialect7) {
         | 
| 11979 | 
            -
                    return statement.type === "alter_table_rename_column" &&  | 
| 11985 | 
            +
                    return statement.type === "alter_table_rename_column" && dialect7 === "sqlite";
         | 
| 11980 11986 | 
             
                  }
         | 
| 11981 11987 | 
             
                  convert(statement) {
         | 
| 11982 11988 | 
             
                    const { tableName, oldColumnName, newColumnName } = statement;
         | 
| 11983 | 
            -
                    return `ALTER TABLE \`${tableName}\` RENAME COLUMN  | 
| 11989 | 
            +
                    return `ALTER TABLE \`${tableName}\` RENAME COLUMN \`${oldColumnName}\` TO \`${newColumnName}\`;`;
         | 
| 11984 11990 | 
             
                  }
         | 
| 11985 11991 | 
             
                };
         | 
| 11986 11992 | 
             
                PgAlterTableDropColumnConvertor = class extends Convertor {
         | 
| @@ -12004,7 +12010,7 @@ var init_sqlgenerator = __esm({ | |
| 12004 12010 | 
             
                };
         | 
| 12005 12011 | 
             
                SQLiteAlterTableDropColumnConvertor = class extends Convertor {
         | 
| 12006 12012 | 
             
                  can(statement, dialect7) {
         | 
| 12007 | 
            -
                    return statement.type === "alter_table_drop_column" &&  | 
| 12013 | 
            +
                    return statement.type === "alter_table_drop_column" && dialect7 === "sqlite";
         | 
| 12008 12014 | 
             
                  }
         | 
| 12009 12015 | 
             
                  convert(statement) {
         | 
| 12010 12016 | 
             
                    const { tableName, columnName } = statement;
         | 
| @@ -12057,7 +12063,7 @@ var init_sqlgenerator = __esm({ | |
| 12057 12063 | 
             
                };
         | 
| 12058 12064 | 
             
                SQLiteAlterTableAddColumnConvertor = class extends Convertor {
         | 
| 12059 12065 | 
             
                  can(statement, dialect7) {
         | 
| 12060 | 
            -
                    return statement.type === "sqlite_alter_table_add_column" &&  | 
| 12066 | 
            +
                    return statement.type === "sqlite_alter_table_add_column" && dialect7 === "sqlite";
         | 
| 12061 12067 | 
             
                  }
         | 
| 12062 12068 | 
             
                  convert(statement) {
         | 
| 12063 12069 | 
             
                    const { tableName, column: column4, referenceData } = statement;
         | 
| @@ -12081,6 +12087,21 @@ var init_sqlgenerator = __esm({ | |
| 12081 12087 | 
             
                    return `ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${columnName}" SET DATA TYPE ${newDataType};`;
         | 
| 12082 12088 | 
             
                  }
         | 
| 12083 12089 | 
             
                };
         | 
| 12090 | 
            +
                SQLiteAlterTableAlterColumnSetTypeConvertor = class extends Convertor {
         | 
| 12091 | 
            +
                  can(statement, dialect7) {
         | 
| 12092 | 
            +
                    return statement.type === "alter_table_alter_column_set_type" && dialect7 === "sqlite";
         | 
| 12093 | 
            +
                  }
         | 
| 12094 | 
            +
                  convert(statement) {
         | 
| 12095 | 
            +
                    return `/*
         | 
| 12096 | 
            +
             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
         | 
| 12097 | 
            +
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         | 
| 12098 | 
            +
                              https://www.sqlite.org/lang_altertable.html
         | 
| 12099 | 
            +
                              https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
         | 
| 12100 | 
            +
             | 
| 12101 | 
            +
             Due to that we don't generate migration automatically and it has to be done manually
         | 
| 12102 | 
            +
            */`;
         | 
| 12103 | 
            +
                  }
         | 
| 12104 | 
            +
                };
         | 
| 12084 12105 | 
             
                PgAlterTableAlterColumnSetDefaultConvertor = class extends Convertor {
         | 
| 12085 12106 | 
             
                  can(statement, dialect7) {
         | 
| 12086 12107 | 
             
                    return statement.type === "alter_table_alter_column_set_default" && dialect7 === "postgresql";
         | 
| @@ -12091,6 +12112,21 @@ var init_sqlgenerator = __esm({ | |
| 12091 12112 | 
             
                    return `ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${columnName}" SET DEFAULT ${statement.newDefaultValue};`;
         | 
| 12092 12113 | 
             
                  }
         | 
| 12093 12114 | 
             
                };
         | 
| 12115 | 
            +
                SqliteAlterTableAlterColumnSetDefaultConvertor = class extends Convertor {
         | 
| 12116 | 
            +
                  can(statement, dialect7) {
         | 
| 12117 | 
            +
                    return statement.type === "alter_table_alter_column_set_default" && dialect7 === "sqlite";
         | 
| 12118 | 
            +
                  }
         | 
| 12119 | 
            +
                  convert(statement) {
         | 
| 12120 | 
            +
                    return `/*
         | 
| 12121 | 
            +
             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
         | 
| 12122 | 
            +
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         | 
| 12123 | 
            +
                              https://www.sqlite.org/lang_altertable.html
         | 
| 12124 | 
            +
                              https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
         | 
| 12125 | 
            +
             | 
| 12126 | 
            +
             Due to that we don't generate migration automatically and it has to be done manually
         | 
| 12127 | 
            +
            */`;
         | 
| 12128 | 
            +
                  }
         | 
| 12129 | 
            +
                };
         | 
| 12094 12130 | 
             
                PgAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
         | 
| 12095 12131 | 
             
                  can(statement, dialect7) {
         | 
| 12096 12132 | 
             
                    return statement.type === "alter_table_alter_column_drop_default" && dialect7 === "postgresql";
         | 
| @@ -12189,7 +12225,7 @@ var init_sqlgenerator = __esm({ | |
| 12189 12225 | 
             
                };
         | 
| 12190 12226 | 
             
                SqliteAlterTableAlterColumnDropGeneratedConvertor = class extends Convertor {
         | 
| 12191 12227 | 
             
                  can(statement, dialect7) {
         | 
| 12192 | 
            -
                    return statement.type === "alter_table_alter_column_drop_generated" &&  | 
| 12228 | 
            +
                    return statement.type === "alter_table_alter_column_drop_generated" && dialect7 === "sqlite";
         | 
| 12193 12229 | 
             
                  }
         | 
| 12194 12230 | 
             
                  convert(statement) {
         | 
| 12195 12231 | 
             
                    const {
         | 
| @@ -12230,7 +12266,7 @@ var init_sqlgenerator = __esm({ | |
| 12230 12266 | 
             
                };
         | 
| 12231 12267 | 
             
                SqliteAlterTableAlterColumnSetExpressionConvertor = class extends Convertor {
         | 
| 12232 12268 | 
             
                  can(statement, dialect7) {
         | 
| 12233 | 
            -
                    return statement.type === "alter_table_alter_column_set_generated" &&  | 
| 12269 | 
            +
                    return statement.type === "alter_table_alter_column_set_generated" && dialect7 === "sqlite";
         | 
| 12234 12270 | 
             
                  }
         | 
| 12235 12271 | 
             
                  convert(statement) {
         | 
| 12236 12272 | 
             
                    const {
         | 
| @@ -12271,7 +12307,7 @@ var init_sqlgenerator = __esm({ | |
| 12271 12307 | 
             
                };
         | 
| 12272 12308 | 
             
                SqliteAlterTableAlterColumnAlterGeneratedConvertor = class extends Convertor {
         | 
| 12273 12309 | 
             
                  can(statement, dialect7) {
         | 
| 12274 | 
            -
                    return statement.type === "alter_table_alter_column_alter_generated" &&  | 
| 12310 | 
            +
                    return statement.type === "alter_table_alter_column_alter_generated" && dialect7 === "sqlite";
         | 
| 12275 12311 | 
             
                  }
         | 
| 12276 12312 | 
             
                  convert(statement) {
         | 
| 12277 12313 | 
             
                    const {
         | 
| @@ -12364,67 +12400,6 @@ var init_sqlgenerator = __esm({ | |
| 12364 12400 | 
             
                    return `ALTER TABLE \`${statement.tableName}\` DROP PRIMARY KEY`;
         | 
| 12365 12401 | 
             
                  }
         | 
| 12366 12402 | 
             
                };
         | 
| 12367 | 
            -
                LibSQLModifyColumn = class extends Convertor {
         | 
| 12368 | 
            -
                  can(statement, dialect7) {
         | 
| 12369 | 
            -
                    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 === "turso";
         | 
| 12370 | 
            -
                  }
         | 
| 12371 | 
            -
                  convert(statement, json2) {
         | 
| 12372 | 
            -
                    const { tableName, columnName } = statement;
         | 
| 12373 | 
            -
                    let columnType = ``;
         | 
| 12374 | 
            -
                    let columnDefault = "";
         | 
| 12375 | 
            -
                    let columnNotNull = "";
         | 
| 12376 | 
            -
                    const sqlStatements = [];
         | 
| 12377 | 
            -
                    const indexes = [];
         | 
| 12378 | 
            -
                    for (const table4 of Object.values(json2.tables)) {
         | 
| 12379 | 
            -
                      for (const index4 of Object.values(table4.indexes)) {
         | 
| 12380 | 
            -
                        const unsquashed = SQLiteSquasher.unsquashIdx(index4);
         | 
| 12381 | 
            -
                        sqlStatements.push(`DROP INDEX IF EXISTS "${unsquashed.name}";`);
         | 
| 12382 | 
            -
                        indexes.push({ ...unsquashed, tableName: table4.name });
         | 
| 12383 | 
            -
                      }
         | 
| 12384 | 
            -
                    }
         | 
| 12385 | 
            -
                    switch (statement.type) {
         | 
| 12386 | 
            -
                      case "alter_table_alter_column_set_type":
         | 
| 12387 | 
            -
                        columnType = ` ${statement.newDataType}`;
         | 
| 12388 | 
            -
                        columnDefault = statement.columnDefault ? ` DEFAULT ${statement.columnDefault}` : "";
         | 
| 12389 | 
            -
                        columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
         | 
| 12390 | 
            -
                        break;
         | 
| 12391 | 
            -
                      case "alter_table_alter_column_drop_notnull":
         | 
| 12392 | 
            -
                        columnType = ` ${statement.newDataType}`;
         | 
| 12393 | 
            -
                        columnDefault = statement.columnDefault ? ` DEFAULT ${statement.columnDefault}` : "";
         | 
| 12394 | 
            -
                        columnNotNull = "";
         | 
| 12395 | 
            -
                        break;
         | 
| 12396 | 
            -
                      case "alter_table_alter_column_set_notnull":
         | 
| 12397 | 
            -
                        columnType = ` ${statement.newDataType}`;
         | 
| 12398 | 
            -
                        columnDefault = statement.columnDefault ? ` DEFAULT ${statement.columnDefault}` : "";
         | 
| 12399 | 
            -
                        columnNotNull = ` NOT NULL`;
         | 
| 12400 | 
            -
                        break;
         | 
| 12401 | 
            -
                      case "alter_table_alter_column_set_default":
         | 
| 12402 | 
            -
                        columnType = ` ${statement.newDataType}`;
         | 
| 12403 | 
            -
                        columnDefault = ` DEFAULT ${statement.newDefaultValue}`;
         | 
| 12404 | 
            -
                        columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
         | 
| 12405 | 
            -
                        break;
         | 
| 12406 | 
            -
                      case "alter_table_alter_column_drop_default":
         | 
| 12407 | 
            -
                        columnType = ` ${statement.newDataType}`;
         | 
| 12408 | 
            -
                        columnDefault = "";
         | 
| 12409 | 
            -
                        columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
         | 
| 12410 | 
            -
                        break;
         | 
| 12411 | 
            -
                    }
         | 
| 12412 | 
            -
                    columnDefault = columnDefault instanceof Date ? columnDefault.toISOString() : columnDefault;
         | 
| 12413 | 
            -
                    sqlStatements.push(
         | 
| 12414 | 
            -
                      `ALTER TABLE \`${tableName}\` ALTER COLUMN "${columnName}" TO "${columnName}"${columnType}${columnNotNull}${columnDefault};`
         | 
| 12415 | 
            -
                    );
         | 
| 12416 | 
            -
                    for (const index4 of indexes) {
         | 
| 12417 | 
            -
                      const indexPart = index4.isUnique ? "UNIQUE INDEX" : "INDEX";
         | 
| 12418 | 
            -
                      const whereStatement = index4.where ? ` WHERE ${index4.where}` : "";
         | 
| 12419 | 
            -
                      const uniqueString = index4.columns.map((it) => `\`${it}\``).join(",");
         | 
| 12420 | 
            -
                      const tableName2 = index4.tableName;
         | 
| 12421 | 
            -
                      sqlStatements.push(
         | 
| 12422 | 
            -
                        `CREATE ${indexPart} \`${index4.name}\` ON \`${tableName2}\` (${uniqueString})${whereStatement};`
         | 
| 12423 | 
            -
                      );
         | 
| 12424 | 
            -
                    }
         | 
| 12425 | 
            -
                    return sqlStatements;
         | 
| 12426 | 
            -
                  }
         | 
| 12427 | 
            -
                };
         | 
| 12428 12403 | 
             
                MySqlModifyColumn = class extends Convertor {
         | 
| 12429 12404 | 
             
                  can(statement, dialect7) {
         | 
| 12430 12405 | 
             
                    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";
         | 
| @@ -12562,6 +12537,21 @@ var init_sqlgenerator = __esm({ | |
| 12562 12537 | 
             
                    return `ALTER TABLE \`${tableName}\` MODIFY COLUMN \`${columnName}\`${columnType}${columnAutoincrement}${columnGenerated}${columnNotNull}${columnDefault}${columnOnUpdate};`;
         | 
| 12563 12538 | 
             
                  }
         | 
| 12564 12539 | 
             
                };
         | 
| 12540 | 
            +
                SqliteAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
         | 
| 12541 | 
            +
                  can(statement, dialect7) {
         | 
| 12542 | 
            +
                    return statement.type === "alter_table_alter_column_drop_default" && dialect7 === "sqlite";
         | 
| 12543 | 
            +
                  }
         | 
| 12544 | 
            +
                  convert(statement) {
         | 
| 12545 | 
            +
                    return `/*
         | 
| 12546 | 
            +
             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
         | 
| 12547 | 
            +
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         | 
| 12548 | 
            +
                              https://www.sqlite.org/lang_altertable.html
         | 
| 12549 | 
            +
                              https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
         | 
| 12550 | 
            +
             | 
| 12551 | 
            +
             Due to that we don't generate migration automatically and it has to be done manually
         | 
| 12552 | 
            +
            */`;
         | 
| 12553 | 
            +
                  }
         | 
| 12554 | 
            +
                };
         | 
| 12565 12555 | 
             
                PgAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
         | 
| 12566 12556 | 
             
                  can(statement, dialect7) {
         | 
| 12567 12557 | 
             
                    return statement.type === "create_composite_pk" && dialect7 === "postgresql";
         | 
| @@ -12626,6 +12616,85 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo | |
| 12626 12616 | 
             
                    return `ALTER TABLE \`${statement.tableName}\` DROP PRIMARY KEY, ADD PRIMARY KEY(\`${newColumns.join("`,`")}\`);`;
         | 
| 12627 12617 | 
             
                  }
         | 
| 12628 12618 | 
             
                };
         | 
| 12619 | 
            +
                SqliteAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
         | 
| 12620 | 
            +
                  can(statement, dialect7) {
         | 
| 12621 | 
            +
                    return statement.type === "create_composite_pk" && dialect7 === "sqlite";
         | 
| 12622 | 
            +
                  }
         | 
| 12623 | 
            +
                  convert(statement) {
         | 
| 12624 | 
            +
                    let msg = "/*\n";
         | 
| 12625 | 
            +
                    msg += `You're trying to add PRIMARY KEY(${statement.data}) to '${statement.tableName}' table
         | 
| 12626 | 
            +
            `;
         | 
| 12627 | 
            +
                    msg += "SQLite does not support adding primary key to an already created table\n";
         | 
| 12628 | 
            +
                    msg += "You can do it in 3 steps with drizzle orm:\n";
         | 
| 12629 | 
            +
                    msg += " - create new mirror table with needed pk, rename current table to old_table, generate SQL\n";
         | 
| 12630 | 
            +
                    msg += " - migrate old data from one table to another\n";
         | 
| 12631 | 
            +
                    msg += " - delete old_table in schema, generate sql\n\n";
         | 
| 12632 | 
            +
                    msg += "or create manual migration like below:\n\n";
         | 
| 12633 | 
            +
                    msg += "ALTER TABLE table_name RENAME TO old_table;\n";
         | 
| 12634 | 
            +
                    msg += "CREATE TABLE table_name (\n";
         | 
| 12635 | 
            +
                    msg += "	column1 datatype [ NULL | NOT NULL ],\n";
         | 
| 12636 | 
            +
                    msg += "	column2 datatype [ NULL | NOT NULL ],\n";
         | 
| 12637 | 
            +
                    msg += "	...\n";
         | 
| 12638 | 
            +
                    msg += "	PRIMARY KEY (pk_col1, pk_col2, ... pk_col_n)\n";
         | 
| 12639 | 
            +
                    msg += " );\n";
         | 
| 12640 | 
            +
                    msg += "INSERT INTO table_name SELECT * FROM old_table;\n\n";
         | 
| 12641 | 
            +
                    msg += "Due to that we don't generate migration automatically and it has to be done manually\n";
         | 
| 12642 | 
            +
                    msg += "*/\n";
         | 
| 12643 | 
            +
                    return msg;
         | 
| 12644 | 
            +
                  }
         | 
| 12645 | 
            +
                };
         | 
| 12646 | 
            +
                SqliteAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
         | 
| 12647 | 
            +
                  can(statement, dialect7) {
         | 
| 12648 | 
            +
                    return statement.type === "delete_composite_pk" && dialect7 === "sqlite";
         | 
| 12649 | 
            +
                  }
         | 
| 12650 | 
            +
                  convert(statement) {
         | 
| 12651 | 
            +
                    let msg = "/*\n";
         | 
| 12652 | 
            +
                    msg += `You're trying to delete PRIMARY KEY(${statement.data}) from '${statement.tableName}' table
         | 
| 12653 | 
            +
            `;
         | 
| 12654 | 
            +
                    msg += "SQLite does not supportprimary key deletion from existing table\n";
         | 
| 12655 | 
            +
                    msg += "You can do it in 3 steps with drizzle orm:\n";
         | 
| 12656 | 
            +
                    msg += " - create new mirror table table without pk, rename current table to old_table, generate SQL\n";
         | 
| 12657 | 
            +
                    msg += " - migrate old data from one table to another\n";
         | 
| 12658 | 
            +
                    msg += " - delete old_table in schema, generate sql\n\n";
         | 
| 12659 | 
            +
                    msg += "or create manual migration like below:\n\n";
         | 
| 12660 | 
            +
                    msg += "ALTER TABLE table_name RENAME TO old_table;\n";
         | 
| 12661 | 
            +
                    msg += "CREATE TABLE table_name (\n";
         | 
| 12662 | 
            +
                    msg += "	column1 datatype [ NULL | NOT NULL ],\n";
         | 
| 12663 | 
            +
                    msg += "	column2 datatype [ NULL | NOT NULL ],\n";
         | 
| 12664 | 
            +
                    msg += "	...\n";
         | 
| 12665 | 
            +
                    msg += "	PRIMARY KEY (pk_col1, pk_col2, ... pk_col_n)\n";
         | 
| 12666 | 
            +
                    msg += " );\n";
         | 
| 12667 | 
            +
                    msg += "INSERT INTO table_name SELECT * FROM old_table;\n\n";
         | 
| 12668 | 
            +
                    msg += "Due to that we don't generate migration automatically and it has to be done manually\n";
         | 
| 12669 | 
            +
                    msg += "*/\n";
         | 
| 12670 | 
            +
                    return msg;
         | 
| 12671 | 
            +
                  }
         | 
| 12672 | 
            +
                };
         | 
| 12673 | 
            +
                SqliteAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
         | 
| 12674 | 
            +
                  can(statement, dialect7) {
         | 
| 12675 | 
            +
                    return statement.type === "alter_composite_pk" && dialect7 === "sqlite";
         | 
| 12676 | 
            +
                  }
         | 
| 12677 | 
            +
                  convert(statement) {
         | 
| 12678 | 
            +
                    let msg = "/*\n";
         | 
| 12679 | 
            +
                    msg += "SQLite does not support altering primary key\n";
         | 
| 12680 | 
            +
                    msg += "You can do it in 3 steps with drizzle orm:\n";
         | 
| 12681 | 
            +
                    msg += " - create new mirror table with needed pk, rename current table to old_table, generate SQL\n";
         | 
| 12682 | 
            +
                    msg += " - migrate old data from one table to another\n";
         | 
| 12683 | 
            +
                    msg += " - delete old_table in schema, generate sql\n\n";
         | 
| 12684 | 
            +
                    msg += "or create manual migration like below:\n\n";
         | 
| 12685 | 
            +
                    msg += "ALTER TABLE table_name RENAME TO old_table;\n";
         | 
| 12686 | 
            +
                    msg += "CREATE TABLE table_name (\n";
         | 
| 12687 | 
            +
                    msg += "	column1 datatype [ NULL | NOT NULL ],\n";
         | 
| 12688 | 
            +
                    msg += "	column2 datatype [ NULL | NOT NULL ],\n";
         | 
| 12689 | 
            +
                    msg += "	...\n";
         | 
| 12690 | 
            +
                    msg += "	PRIMARY KEY (pk_col1, pk_col2, ... pk_col_n)\n";
         | 
| 12691 | 
            +
                    msg += " );\n";
         | 
| 12692 | 
            +
                    msg += "INSERT INTO table_name SELECT * FROM old_table;\n\n";
         | 
| 12693 | 
            +
                    msg += "Due to that we don't generate migration automatically and it has to be done manually\n";
         | 
| 12694 | 
            +
                    msg += "*/\n";
         | 
| 12695 | 
            +
                    return msg;
         | 
| 12696 | 
            +
                  }
         | 
| 12697 | 
            +
                };
         | 
| 12629 12698 | 
             
                PgAlterTableAlterColumnSetPrimaryKeyConvertor = class extends Convertor {
         | 
| 12630 12699 | 
             
                  can(statement, dialect7) {
         | 
| 12631 12700 | 
             
                    return statement.type === "alter_table_alter_column_set_pk" && dialect7 === "postgresql";
         | 
| @@ -12670,6 +12739,51 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo | |
| 12670 12739 | 
             
                    return `ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${columnName}" SET NOT NULL;`;
         | 
| 12671 12740 | 
             
                  }
         | 
| 12672 12741 | 
             
                };
         | 
| 12742 | 
            +
                SqliteAlterTableAlterColumnSetNotNullConvertor = class extends Convertor {
         | 
| 12743 | 
            +
                  can(statement, dialect7) {
         | 
| 12744 | 
            +
                    return statement.type === "alter_table_alter_column_set_notnull" && dialect7 === "sqlite";
         | 
| 12745 | 
            +
                  }
         | 
| 12746 | 
            +
                  convert(statement) {
         | 
| 12747 | 
            +
                    return `/*
         | 
| 12748 | 
            +
             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
         | 
| 12749 | 
            +
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         | 
| 12750 | 
            +
                              https://www.sqlite.org/lang_altertable.html
         | 
| 12751 | 
            +
                              https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
         | 
| 12752 | 
            +
             | 
| 12753 | 
            +
             Due to that we don't generate migration automatically and it has to be done manually
         | 
| 12754 | 
            +
            */`;
         | 
| 12755 | 
            +
                  }
         | 
| 12756 | 
            +
                };
         | 
| 12757 | 
            +
                SqliteAlterTableAlterColumnSetAutoincrementConvertor = class extends Convertor {
         | 
| 12758 | 
            +
                  can(statement, dialect7) {
         | 
| 12759 | 
            +
                    return statement.type === "alter_table_alter_column_set_autoincrement" && dialect7 === "sqlite";
         | 
| 12760 | 
            +
                  }
         | 
| 12761 | 
            +
                  convert(statement) {
         | 
| 12762 | 
            +
                    return `/*
         | 
| 12763 | 
            +
             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
         | 
| 12764 | 
            +
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         | 
| 12765 | 
            +
                              https://www.sqlite.org/lang_altertable.html
         | 
| 12766 | 
            +
                              https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
         | 
| 12767 | 
            +
             | 
| 12768 | 
            +
             Due to that we don't generate migration automatically and it has to be done manually
         | 
| 12769 | 
            +
            */`;
         | 
| 12770 | 
            +
                  }
         | 
| 12771 | 
            +
                };
         | 
| 12772 | 
            +
                SqliteAlterTableAlterColumnDropAutoincrementConvertor = class extends Convertor {
         | 
| 12773 | 
            +
                  can(statement, dialect7) {
         | 
| 12774 | 
            +
                    return statement.type === "alter_table_alter_column_drop_autoincrement" && dialect7 === "sqlite";
         | 
| 12775 | 
            +
                  }
         | 
| 12776 | 
            +
                  convert(statement) {
         | 
| 12777 | 
            +
                    return `/*
         | 
| 12778 | 
            +
             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
         | 
| 12779 | 
            +
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         | 
| 12780 | 
            +
                              https://www.sqlite.org/lang_altertable.html
         | 
| 12781 | 
            +
                              https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
         | 
| 12782 | 
            +
             | 
| 12783 | 
            +
             Due to that we don't generate migration automatically and it has to be done manually
         | 
| 12784 | 
            +
            */`;
         | 
| 12785 | 
            +
                  }
         | 
| 12786 | 
            +
                };
         | 
| 12673 12787 | 
             
                PgAlterTableAlterColumnDropNotNullConvertor = class extends Convertor {
         | 
| 12674 12788 | 
             
                  can(statement, dialect7) {
         | 
| 12675 12789 | 
             
                    return statement.type === "alter_table_alter_column_drop_notnull" && dialect7 === "postgresql";
         | 
| @@ -12680,6 +12794,21 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo | |
| 12680 12794 | 
             
                    return `ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${columnName}" DROP NOT NULL;`;
         | 
| 12681 12795 | 
             
                  }
         | 
| 12682 12796 | 
             
                };
         | 
| 12797 | 
            +
                SqliteAlterTableAlterColumnDropNotNullConvertor = class extends Convertor {
         | 
| 12798 | 
            +
                  can(statement, dialect7) {
         | 
| 12799 | 
            +
                    return statement.type === "alter_table_alter_column_drop_notnull" && dialect7 === "sqlite";
         | 
| 12800 | 
            +
                  }
         | 
| 12801 | 
            +
                  convert(statement) {
         | 
| 12802 | 
            +
                    return `/*
         | 
| 12803 | 
            +
             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
         | 
| 12804 | 
            +
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         | 
| 12805 | 
            +
                              https://www.sqlite.org/lang_altertable.html
         | 
| 12806 | 
            +
                              https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
         | 
| 12807 | 
            +
             | 
| 12808 | 
            +
             Due to that we don't generate migration automatically and it has to be done manually
         | 
| 12809 | 
            +
            */`;
         | 
| 12810 | 
            +
                  }
         | 
| 12811 | 
            +
                };
         | 
| 12683 12812 | 
             
                PgCreateForeignKeyConvertor = class extends Convertor {
         | 
| 12684 12813 | 
             
                  can(statement, dialect7) {
         | 
| 12685 12814 | 
             
                    return statement.type === "create_reference" && dialect7 === "postgresql";
         | 
| @@ -12710,21 +12839,18 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo | |
| 12710 12839 | 
             
                    return sql2;
         | 
| 12711 12840 | 
             
                  }
         | 
| 12712 12841 | 
             
                };
         | 
| 12713 | 
            -
                 | 
| 12842 | 
            +
                SqliteCreateForeignKeyConvertor = class extends Convertor {
         | 
| 12714 12843 | 
             
                  can(statement, dialect7) {
         | 
| 12715 | 
            -
                    return statement.type === "create_reference" && dialect7 === " | 
| 12844 | 
            +
                    return statement.type === "create_reference" && dialect7 === "sqlite";
         | 
| 12716 12845 | 
             
                  }
         | 
| 12717 | 
            -
                  convert(statement | 
| 12718 | 
            -
                     | 
| 12719 | 
            -
             | 
| 12720 | 
            -
             | 
| 12721 | 
            -
             | 
| 12722 | 
            -
             | 
| 12723 | 
            -
             | 
| 12724 | 
            -
             | 
| 12725 | 
            -
                    const columnFrom = columnsFrom[0];
         | 
| 12726 | 
            -
                    const columnTo = columnsTo[0];
         | 
| 12727 | 
            -
                    return `ALTER TABLE \`${tableFrom}\` ALTER COLUMN "${columnFrom}" TO "${columnFrom}"${columnTypeValue}${columnNotNullValue}${columnsDefaultValue} REFERENCES ${tableTo}(${columnTo})${onDeleteStatement}${onUpdateStatement};`;
         | 
| 12846 | 
            +
                  convert(statement) {
         | 
| 12847 | 
            +
                    return `/*
         | 
| 12848 | 
            +
             SQLite does not support "Creating foreign key on existing column" out of the box, we do not generate automatic migration for that, so it has to be done manually
         | 
| 12849 | 
            +
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         | 
| 12850 | 
            +
                              https://www.sqlite.org/lang_altertable.html
         | 
| 12851 | 
            +
             | 
| 12852 | 
            +
             Due to that we don't generate migration automatically and it has to be done manually
         | 
| 12853 | 
            +
            */`;
         | 
| 12728 12854 | 
             
                  }
         | 
| 12729 12855 | 
             
                };
         | 
| 12730 12856 | 
             
                MySqlCreateForeignKeyConvertor = class extends Convertor {
         | 
| @@ -12773,6 +12899,20 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo | |
| 12773 12899 | 
             
                    return sql2;
         | 
| 12774 12900 | 
             
                  }
         | 
| 12775 12901 | 
             
                };
         | 
| 12902 | 
            +
                SqliteAlterForeignKeyConvertor = class extends Convertor {
         | 
| 12903 | 
            +
                  can(statement, dialect7) {
         | 
| 12904 | 
            +
                    return statement.type === "alter_reference" && dialect7 === "sqlite";
         | 
| 12905 | 
            +
                  }
         | 
| 12906 | 
            +
                  convert(statement) {
         | 
| 12907 | 
            +
                    return `/*
         | 
| 12908 | 
            +
             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
         | 
| 12909 | 
            +
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         | 
| 12910 | 
            +
                              https://www.sqlite.org/lang_altertable.html
         | 
| 12911 | 
            +
             | 
| 12912 | 
            +
             Due to that we don't generate migration automatically and it has to be done manually
         | 
| 12913 | 
            +
            */`;
         | 
| 12914 | 
            +
                  }
         | 
| 12915 | 
            +
                };
         | 
| 12776 12916 | 
             
                PgDeleteForeignKeyConvertor = class extends Convertor {
         | 
| 12777 12917 | 
             
                  can(statement, dialect7) {
         | 
| 12778 12918 | 
             
                    return statement.type === "delete_reference" && dialect7 === "postgresql";
         | 
| @@ -12785,6 +12925,20 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo | |
| 12785 12925 | 
             
            `;
         | 
| 12786 12926 | 
             
                  }
         | 
| 12787 12927 | 
             
                };
         | 
| 12928 | 
            +
                SqliteDeleteForeignKeyConvertor = class extends Convertor {
         | 
| 12929 | 
            +
                  can(statement, dialect7) {
         | 
| 12930 | 
            +
                    return statement.type === "delete_reference" && dialect7 === "sqlite";
         | 
| 12931 | 
            +
                  }
         | 
| 12932 | 
            +
                  convert(statement) {
         | 
| 12933 | 
            +
                    return `/*
         | 
| 12934 | 
            +
             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
         | 
| 12935 | 
            +
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         | 
| 12936 | 
            +
                              https://www.sqlite.org/lang_altertable.html
         | 
| 12937 | 
            +
             | 
| 12938 | 
            +
             Due to that we don't generate migration automatically and it has to be done manually
         | 
| 12939 | 
            +
            */`;
         | 
| 12940 | 
            +
                  }
         | 
| 12941 | 
            +
                };
         | 
| 12788 12942 | 
             
                MySqlDeleteForeignKeyConvertor = class extends Convertor {
         | 
| 12789 12943 | 
             
                  can(statement, dialect7) {
         | 
| 12790 12944 | 
             
                    return statement.type === "delete_reference" && dialect7 === "mysql";
         | 
| @@ -12845,7 +12999,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo | |
| 12845 12999 | 
             
                };
         | 
| 12846 13000 | 
             
                CreateSqliteIndexConvertor = class extends Convertor {
         | 
| 12847 13001 | 
             
                  can(statement, dialect7) {
         | 
| 12848 | 
            -
                    return statement.type === "create_index" &&  | 
| 13002 | 
            +
                    return statement.type === "create_index" && dialect7 === "sqlite";
         | 
| 12849 13003 | 
             
                  }
         | 
| 12850 13004 | 
             
                  convert(statement) {
         | 
| 12851 13005 | 
             
                    const { name: name2, columns, isUnique, where } = SQLiteSquasher.unsquashIdx(
         | 
| @@ -12932,7 +13086,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo | |
| 12932 13086 | 
             
                };
         | 
| 12933 13087 | 
             
                SqliteDropIndexConvertor = class extends Convertor {
         | 
| 12934 13088 | 
             
                  can(statement, dialect7) {
         | 
| 12935 | 
            -
                    return statement.type === "drop_index" &&  | 
| 13089 | 
            +
                    return statement.type === "drop_index" && dialect7 === "sqlite";
         | 
| 12936 13090 | 
             
                  }
         | 
| 12937 13091 | 
             
                  convert(statement) {
         | 
| 12938 13092 | 
             
                    const { name: name2 } = PgSquasher.unsquashIdx(statement.data);
         | 
| @@ -12948,96 +13102,10 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo | |
| 12948 13102 | 
             
                    return `DROP INDEX \`${name2}\` ON \`${statement.tableName}\`;`;
         | 
| 12949 13103 | 
             
                  }
         | 
| 12950 13104 | 
             
                };
         | 
| 12951 | 
            -
                SQLiteRecreateTableConvertor = class extends Convertor {
         | 
| 12952 | 
            -
                  can(statement, dialect7) {
         | 
| 12953 | 
            -
                    return statement.type === "recreate_table" && dialect7 === "sqlite";
         | 
| 12954 | 
            -
                  }
         | 
| 12955 | 
            -
                  convert(statement) {
         | 
| 12956 | 
            -
                    const { tableName, columns, compositePKs, referenceData } = statement;
         | 
| 12957 | 
            -
                    const columnNames = columns.map((it) => `"${it.name}"`).join(", ");
         | 
| 12958 | 
            -
                    const newTableName = `__new_${tableName}`;
         | 
| 12959 | 
            -
                    const sqlStatements = [];
         | 
| 12960 | 
            -
                    sqlStatements.push(`PRAGMA foreign_keys=OFF;`);
         | 
| 12961 | 
            -
                    sqlStatements.push(
         | 
| 12962 | 
            -
                      new SQLiteCreateTableConvertor().convert({
         | 
| 12963 | 
            -
                        type: "sqlite_create_table",
         | 
| 12964 | 
            -
                        tableName: newTableName,
         | 
| 12965 | 
            -
                        columns,
         | 
| 12966 | 
            -
                        referenceData,
         | 
| 12967 | 
            -
                        compositePKs
         | 
| 12968 | 
            -
                      })
         | 
| 12969 | 
            -
                    );
         | 
| 12970 | 
            -
                    sqlStatements.push(
         | 
| 12971 | 
            -
                      `INSERT INTO \`${newTableName}\`(${columnNames}) SELECT ${columnNames} FROM \`${tableName}\`;`
         | 
| 12972 | 
            -
                    );
         | 
| 12973 | 
            -
                    sqlStatements.push(
         | 
| 12974 | 
            -
                      new SQLiteDropTableConvertor().convert({
         | 
| 12975 | 
            -
                        type: "drop_table",
         | 
| 12976 | 
            -
                        tableName,
         | 
| 12977 | 
            -
                        schema: ""
         | 
| 12978 | 
            -
                      })
         | 
| 12979 | 
            -
                    );
         | 
| 12980 | 
            -
                    sqlStatements.push(
         | 
| 12981 | 
            -
                      new SqliteRenameTableConvertor().convert({
         | 
| 12982 | 
            -
                        fromSchema: "",
         | 
| 12983 | 
            -
                        tableNameFrom: newTableName,
         | 
| 12984 | 
            -
                        tableNameTo: tableName,
         | 
| 12985 | 
            -
                        toSchema: "",
         | 
| 12986 | 
            -
                        type: "rename_table"
         | 
| 12987 | 
            -
                      })
         | 
| 12988 | 
            -
                    );
         | 
| 12989 | 
            -
                    sqlStatements.push(`PRAGMA foreign_keys=ON;`);
         | 
| 12990 | 
            -
                    return sqlStatements;
         | 
| 12991 | 
            -
                  }
         | 
| 12992 | 
            -
                };
         | 
| 12993 | 
            -
                LibSQLRecreateTableConvertor = class extends Convertor {
         | 
| 12994 | 
            -
                  can(statement, dialect7) {
         | 
| 12995 | 
            -
                    return statement.type === "recreate_table" && dialect7 === "turso";
         | 
| 12996 | 
            -
                  }
         | 
| 12997 | 
            -
                  convert(statement) {
         | 
| 12998 | 
            -
                    const { tableName, columns, compositePKs, referenceData } = statement;
         | 
| 12999 | 
            -
                    const columnNames = columns.map((it) => `"${it.name}"`).join(", ");
         | 
| 13000 | 
            -
                    const newTableName = `__new_${tableName}`;
         | 
| 13001 | 
            -
                    const sqlStatements = [];
         | 
| 13002 | 
            -
                    sqlStatements.push(`PRAGMA foreign_keys=OFF;`);
         | 
| 13003 | 
            -
                    sqlStatements.push(
         | 
| 13004 | 
            -
                      new SQLiteCreateTableConvertor().convert({
         | 
| 13005 | 
            -
                        type: "sqlite_create_table",
         | 
| 13006 | 
            -
                        tableName: newTableName,
         | 
| 13007 | 
            -
                        columns,
         | 
| 13008 | 
            -
                        referenceData,
         | 
| 13009 | 
            -
                        compositePKs
         | 
| 13010 | 
            -
                      })
         | 
| 13011 | 
            -
                    );
         | 
| 13012 | 
            -
                    sqlStatements.push(
         | 
| 13013 | 
            -
                      `INSERT INTO \`${newTableName}\`(${columnNames}) SELECT ${columnNames} FROM \`${tableName}\`;`
         | 
| 13014 | 
            -
                    );
         | 
| 13015 | 
            -
                    sqlStatements.push(
         | 
| 13016 | 
            -
                      new SQLiteDropTableConvertor().convert({
         | 
| 13017 | 
            -
                        type: "drop_table",
         | 
| 13018 | 
            -
                        tableName,
         | 
| 13019 | 
            -
                        schema: ""
         | 
| 13020 | 
            -
                      })
         | 
| 13021 | 
            -
                    );
         | 
| 13022 | 
            -
                    sqlStatements.push(
         | 
| 13023 | 
            -
                      new SqliteRenameTableConvertor().convert({
         | 
| 13024 | 
            -
                        fromSchema: "",
         | 
| 13025 | 
            -
                        tableNameFrom: newTableName,
         | 
| 13026 | 
            -
                        tableNameTo: tableName,
         | 
| 13027 | 
            -
                        toSchema: "",
         | 
| 13028 | 
            -
                        type: "rename_table"
         | 
| 13029 | 
            -
                      })
         | 
| 13030 | 
            -
                    );
         | 
| 13031 | 
            -
                    sqlStatements.push(`PRAGMA foreign_keys=ON;`);
         | 
| 13032 | 
            -
                    return sqlStatements;
         | 
| 13033 | 
            -
                  }
         | 
| 13034 | 
            -
                };
         | 
| 13035 13105 | 
             
                convertors = [];
         | 
| 13036 13106 | 
             
                convertors.push(new PgCreateTableConvertor());
         | 
| 13037 13107 | 
             
                convertors.push(new MySqlCreateTableConvertor());
         | 
| 13038 13108 | 
             
                convertors.push(new SQLiteCreateTableConvertor());
         | 
| 13039 | 
            -
                convertors.push(new SQLiteRecreateTableConvertor());
         | 
| 13040 | 
            -
                convertors.push(new LibSQLRecreateTableConvertor());
         | 
| 13041 13109 | 
             
                convertors.push(new CreateTypeEnumConvertor());
         | 
| 13042 13110 | 
             
                convertors.push(new CreatePgSequenceConvertor());
         | 
| 13043 13111 | 
             
                convertors.push(new DropPgSequenceConvertor());
         | 
| @@ -13085,7 +13153,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo | |
| 13085 13153 | 
             
                convertors.push(new SqliteAlterTableAlterColumnAlterGeneratedConvertor());
         | 
| 13086 13154 | 
             
                convertors.push(new SqliteAlterTableAlterColumnSetExpressionConvertor());
         | 
| 13087 13155 | 
             
                convertors.push(new MySqlModifyColumn());
         | 
| 13088 | 
            -
                convertors.push(new LibSQLModifyColumn());
         | 
| 13089 13156 | 
             
                convertors.push(new PgCreateForeignKeyConvertor());
         | 
| 13090 13157 | 
             
                convertors.push(new MySqlCreateForeignKeyConvertor());
         | 
| 13091 13158 | 
             
                convertors.push(new PgAlterForeignKeyConvertor());
         | 
| @@ -13097,10 +13164,24 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo | |
| 13097 13164 | 
             
                convertors.push(new PgAlterTableSetSchemaConvertor());
         | 
| 13098 13165 | 
             
                convertors.push(new PgAlterTableSetNewSchemaConvertor());
         | 
| 13099 13166 | 
             
                convertors.push(new PgAlterTableRemoveFromSchemaConvertor());
         | 
| 13100 | 
            -
                convertors.push(new  | 
| 13167 | 
            +
                convertors.push(new SQLiteAlterTableAlterColumnSetTypeConvertor());
         | 
| 13168 | 
            +
                convertors.push(new SqliteAlterForeignKeyConvertor());
         | 
| 13169 | 
            +
                convertors.push(new SqliteDeleteForeignKeyConvertor());
         | 
| 13170 | 
            +
                convertors.push(new SqliteCreateForeignKeyConvertor());
         | 
| 13171 | 
            +
                convertors.push(new SQLiteAlterTableAddUniqueConstraintConvertor());
         | 
| 13172 | 
            +
                convertors.push(new SQLiteAlterTableDropUniqueConstraintConvertor());
         | 
| 13101 13173 | 
             
                convertors.push(new PgAlterTableAlterColumnDropGenerated());
         | 
| 13102 13174 | 
             
                convertors.push(new PgAlterTableAlterColumnSetGenerated());
         | 
| 13103 13175 | 
             
                convertors.push(new PgAlterTableAlterColumnAlterGenerated());
         | 
| 13176 | 
            +
                convertors.push(new SqliteAlterTableAlterColumnSetNotNullConvertor());
         | 
| 13177 | 
            +
                convertors.push(new SqliteAlterTableAlterColumnDropNotNullConvertor());
         | 
| 13178 | 
            +
                convertors.push(new SqliteAlterTableAlterColumnSetDefaultConvertor());
         | 
| 13179 | 
            +
                convertors.push(new SqliteAlterTableAlterColumnDropDefaultConvertor());
         | 
| 13180 | 
            +
                convertors.push(new SqliteAlterTableAlterColumnSetAutoincrementConvertor());
         | 
| 13181 | 
            +
                convertors.push(new SqliteAlterTableAlterColumnDropAutoincrementConvertor());
         | 
| 13182 | 
            +
                convertors.push(new SqliteAlterTableCreateCompositePrimaryKeyConvertor());
         | 
| 13183 | 
            +
                convertors.push(new SqliteAlterTableDeleteCompositePrimaryKeyConvertor());
         | 
| 13184 | 
            +
                convertors.push(new SqliteAlterTableAlterCompositePrimaryKeyConvertor());
         | 
| 13104 13185 | 
             
                convertors.push(new PgAlterTableCreateCompositePrimaryKeyConvertor());
         | 
| 13105 13186 | 
             
                convertors.push(new PgAlterTableDeleteCompositePrimaryKeyConvertor());
         | 
| 13106 13187 | 
             
                convertors.push(new PgAlterTableAlterCompositePrimaryKeyConvertor());
         | 
| @@ -13109,6 +13190,19 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo | |
| 13109 13190 | 
             
                convertors.push(new MySqlAlterTableCreateCompositePrimaryKeyConvertor());
         | 
| 13110 13191 | 
             
                convertors.push(new MySqlAlterTableAddPk());
         | 
| 13111 13192 | 
             
                convertors.push(new MySqlAlterTableAlterCompositePrimaryKeyConvertor());
         | 
| 13193 | 
            +
                fromJson = (statements, dialect7) => {
         | 
| 13194 | 
            +
                  const result = statements.flatMap((statement) => {
         | 
| 13195 | 
            +
                    const filtered = convertors.filter((it) => {
         | 
| 13196 | 
            +
                      return it.can(statement, dialect7);
         | 
| 13197 | 
            +
                    });
         | 
| 13198 | 
            +
                    const convertor = filtered.length === 1 ? filtered[0] : void 0;
         | 
| 13199 | 
            +
                    if (!convertor) {
         | 
| 13200 | 
            +
                      return "";
         | 
| 13201 | 
            +
                    }
         | 
| 13202 | 
            +
                    return convertor.convert(statement);
         | 
| 13203 | 
            +
                  }).filter((it) => it !== "");
         | 
| 13204 | 
            +
                  return result;
         | 
| 13205 | 
            +
                };
         | 
| 13112 13206 | 
             
                https: `
         | 
| 13113 13207 | 
             
            create table users (
         | 
| 13114 13208 | 
             
            	id int,
         | 
| @@ -13135,248 +13229,12 @@ drop type __venum; | |
| 13135 13229 | 
             
              }
         | 
| 13136 13230 | 
             
            });
         | 
| 13137 13231 |  | 
| 13138 | 
            -
            // src/cli/commands/sqlitePushUtils.ts
         | 
| 13139 | 
            -
            var _moveDataStatements, getOldTableName, getNewTableName, logSuggestionsAndReturn;
         | 
| 13140 | 
            -
            var init_sqlitePushUtils = __esm({
         | 
| 13141 | 
            -
              "src/cli/commands/sqlitePushUtils.ts"() {
         | 
| 13142 | 
            -
                "use strict";
         | 
| 13143 | 
            -
                init_source();
         | 
| 13144 | 
            -
                init_sqliteSchema();
         | 
| 13145 | 
            -
                init_sqlgenerator();
         | 
| 13146 | 
            -
                init_utils();
         | 
| 13147 | 
            -
                _moveDataStatements = (tableName, json, dataLoss = false) => {
         | 
| 13148 | 
            -
                  const statements = [];
         | 
| 13149 | 
            -
                  const newTableName = `__new_${tableName}`;
         | 
| 13150 | 
            -
                  const tableColumns = Object.values(json.tables[tableName].columns);
         | 
| 13151 | 
            -
                  const referenceData = Object.values(json.tables[tableName].foreignKeys);
         | 
| 13152 | 
            -
                  const compositePKs = Object.values(
         | 
| 13153 | 
            -
                    json.tables[tableName].compositePrimaryKeys
         | 
| 13154 | 
            -
                  ).map((it) => SQLiteSquasher.unsquashPK(it));
         | 
| 13155 | 
            -
                  const fks = referenceData.map((it) => SQLiteSquasher.unsquashPushFK(it));
         | 
| 13156 | 
            -
                  statements.push(
         | 
| 13157 | 
            -
                    new SQLiteCreateTableConvertor().convert({
         | 
| 13158 | 
            -
                      type: "sqlite_create_table",
         | 
| 13159 | 
            -
                      tableName: newTableName,
         | 
| 13160 | 
            -
                      columns: tableColumns,
         | 
| 13161 | 
            -
                      referenceData: fks,
         | 
| 13162 | 
            -
                      compositePKs
         | 
| 13163 | 
            -
                    })
         | 
| 13164 | 
            -
                  );
         | 
| 13165 | 
            -
                  if (!dataLoss) {
         | 
| 13166 | 
            -
                    const columns = Object.keys(json.tables[tableName].columns).map(
         | 
| 13167 | 
            -
                      (c) => `"${c}"`
         | 
| 13168 | 
            -
                    );
         | 
| 13169 | 
            -
                    statements.push(
         | 
| 13170 | 
            -
                      `INSERT INTO \`${newTableName}\`(${columns.join(
         | 
| 13171 | 
            -
                        ", "
         | 
| 13172 | 
            -
                      )}) SELECT ${columns.join(", ")} FROM \`${tableName}\`;`
         | 
| 13173 | 
            -
                    );
         | 
| 13174 | 
            -
                  }
         | 
| 13175 | 
            -
                  statements.push(
         | 
| 13176 | 
            -
                    new SQLiteDropTableConvertor().convert({
         | 
| 13177 | 
            -
                      type: "drop_table",
         | 
| 13178 | 
            -
                      tableName,
         | 
| 13179 | 
            -
                      schema: ""
         | 
| 13180 | 
            -
                    })
         | 
| 13181 | 
            -
                  );
         | 
| 13182 | 
            -
                  statements.push(
         | 
| 13183 | 
            -
                    new SqliteRenameTableConvertor().convert({
         | 
| 13184 | 
            -
                      fromSchema: "",
         | 
| 13185 | 
            -
                      tableNameFrom: newTableName,
         | 
| 13186 | 
            -
                      tableNameTo: tableName,
         | 
| 13187 | 
            -
                      toSchema: "",
         | 
| 13188 | 
            -
                      type: "rename_table"
         | 
| 13189 | 
            -
                    })
         | 
| 13190 | 
            -
                  );
         | 
| 13191 | 
            -
                  for (const idx of Object.values(json.tables[tableName].indexes)) {
         | 
| 13192 | 
            -
                    statements.push(
         | 
| 13193 | 
            -
                      new CreateSqliteIndexConvertor().convert({
         | 
| 13194 | 
            -
                        type: "create_index",
         | 
| 13195 | 
            -
                        tableName,
         | 
| 13196 | 
            -
                        schema: "",
         | 
| 13197 | 
            -
                        data: idx
         | 
| 13198 | 
            -
                      })
         | 
| 13199 | 
            -
                    );
         | 
| 13200 | 
            -
                  }
         | 
| 13201 | 
            -
                  return statements;
         | 
| 13202 | 
            -
                };
         | 
| 13203 | 
            -
                getOldTableName = (tableName, meta) => {
         | 
| 13204 | 
            -
                  for (const key of Object.keys(meta.tables)) {
         | 
| 13205 | 
            -
                    const value = meta.tables[key];
         | 
| 13206 | 
            -
                    if (`"${tableName}"` === value) {
         | 
| 13207 | 
            -
                      return key.substring(1, key.length - 1);
         | 
| 13208 | 
            -
                    }
         | 
| 13209 | 
            -
                  }
         | 
| 13210 | 
            -
                  return tableName;
         | 
| 13211 | 
            -
                };
         | 
| 13212 | 
            -
                getNewTableName = (tableName, meta) => {
         | 
| 13213 | 
            -
                  if (typeof meta.tables[`"${tableName}"`] !== "undefined") {
         | 
| 13214 | 
            -
                    return meta.tables[`"${tableName}"`].substring(
         | 
| 13215 | 
            -
                      1,
         | 
| 13216 | 
            -
                      meta.tables[`"${tableName}"`].length - 1
         | 
| 13217 | 
            -
                    );
         | 
| 13218 | 
            -
                  }
         | 
| 13219 | 
            -
                  return tableName;
         | 
| 13220 | 
            -
                };
         | 
| 13221 | 
            -
                logSuggestionsAndReturn = async (connection, statements, json1, json2, meta) => {
         | 
| 13222 | 
            -
                  let shouldAskForApprove = false;
         | 
| 13223 | 
            -
                  const statementsToExecute = [];
         | 
| 13224 | 
            -
                  const infoToPrint = [];
         | 
| 13225 | 
            -
                  const tablesToRemove = [];
         | 
| 13226 | 
            -
                  const columnsToRemove = [];
         | 
| 13227 | 
            -
                  const schemasToRemove = [];
         | 
| 13228 | 
            -
                  const tablesToTruncate = [];
         | 
| 13229 | 
            -
                  for (const statement of statements) {
         | 
| 13230 | 
            -
                    if (statement.type === "drop_table") {
         | 
| 13231 | 
            -
                      const res = await connection.query(
         | 
| 13232 | 
            -
                        `select count(*) as count from \`${statement.tableName}\``
         | 
| 13233 | 
            -
                      );
         | 
| 13234 | 
            -
                      const count2 = Number(res[0].count);
         | 
| 13235 | 
            -
                      if (count2 > 0) {
         | 
| 13236 | 
            -
                        infoToPrint.push(
         | 
| 13237 | 
            -
                          `\xB7 You're about to delete ${source_default.underline(
         | 
| 13238 | 
            -
                            statement.tableName
         | 
| 13239 | 
            -
                          )} table with ${count2} items`
         | 
| 13240 | 
            -
                        );
         | 
| 13241 | 
            -
                        tablesToRemove.push(statement.tableName);
         | 
| 13242 | 
            -
                        shouldAskForApprove = true;
         | 
| 13243 | 
            -
                      }
         | 
| 13244 | 
            -
                      const fromJsonStatement = fromJson([statement], "sqlite", "push");
         | 
| 13245 | 
            -
                      statementsToExecute.push(
         | 
| 13246 | 
            -
                        ...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
         | 
| 13247 | 
            -
                      );
         | 
| 13248 | 
            -
                    } else if (statement.type === "alter_table_drop_column") {
         | 
| 13249 | 
            -
                      const tableName = statement.tableName;
         | 
| 13250 | 
            -
                      const columnName = statement.columnName;
         | 
| 13251 | 
            -
                      const res = await connection.query(
         | 
| 13252 | 
            -
                        `select count(\`${tableName}\`.\`${columnName}\`) as count from \`${tableName}\``
         | 
| 13253 | 
            -
                      );
         | 
| 13254 | 
            -
                      const count2 = Number(res[0].count);
         | 
| 13255 | 
            -
                      if (count2 > 0) {
         | 
| 13256 | 
            -
                        infoToPrint.push(
         | 
| 13257 | 
            -
                          `\xB7 You're about to delete ${source_default.underline(
         | 
| 13258 | 
            -
                            columnName
         | 
| 13259 | 
            -
                          )} column in ${tableName} table with ${count2} items`
         | 
| 13260 | 
            -
                        );
         | 
| 13261 | 
            -
                        columnsToRemove.push(`${tableName}_${statement.columnName}`);
         | 
| 13262 | 
            -
                        shouldAskForApprove = true;
         | 
| 13263 | 
            -
                      }
         | 
| 13264 | 
            -
                      const fromJsonStatement = fromJson([statement], "sqlite", "push");
         | 
| 13265 | 
            -
                      statementsToExecute.push(
         | 
| 13266 | 
            -
                        ...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
         | 
| 13267 | 
            -
                      );
         | 
| 13268 | 
            -
                    } else if (statement.type === "sqlite_alter_table_add_column" && (statement.column.notNull && !statement.column.default)) {
         | 
| 13269 | 
            -
                      const tableName = statement.tableName;
         | 
| 13270 | 
            -
                      const columnName = statement.column.name;
         | 
| 13271 | 
            -
                      const res = await connection.query(
         | 
| 13272 | 
            -
                        `select count(*) as count from \`${tableName}\``
         | 
| 13273 | 
            -
                      );
         | 
| 13274 | 
            -
                      const count2 = Number(res[0].count);
         | 
| 13275 | 
            -
                      if (count2 > 0) {
         | 
| 13276 | 
            -
                        infoToPrint.push(
         | 
| 13277 | 
            -
                          `\xB7 You're about to add not-null ${source_default.underline(
         | 
| 13278 | 
            -
                            columnName
         | 
| 13279 | 
            -
                          )} column without default value, which contains ${count2} items`
         | 
| 13280 | 
            -
                        );
         | 
| 13281 | 
            -
                        tablesToTruncate.push(tableName);
         | 
| 13282 | 
            -
                        statementsToExecute.push(`delete from ${tableName};`);
         | 
| 13283 | 
            -
                        shouldAskForApprove = true;
         | 
| 13284 | 
            -
                      }
         | 
| 13285 | 
            -
                      const fromJsonStatement = fromJson([statement], "sqlite", "push");
         | 
| 13286 | 
            -
                      statementsToExecute.push(
         | 
| 13287 | 
            -
                        ...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
         | 
| 13288 | 
            -
                      );
         | 
| 13289 | 
            -
                    } else if (statement.type === "recreate_table") {
         | 
| 13290 | 
            -
                      const tableName = statement.tableName;
         | 
| 13291 | 
            -
                      const oldTableName = getOldTableName(tableName, meta);
         | 
| 13292 | 
            -
                      let dataLoss = false;
         | 
| 13293 | 
            -
                      const prevColumnNames = Object.keys(json1.tables[oldTableName].columns);
         | 
| 13294 | 
            -
                      const currentColumnNames = Object.keys(json2.tables[tableName].columns);
         | 
| 13295 | 
            -
                      const { removedColumns, addedColumns } = findAddedAndRemoved(
         | 
| 13296 | 
            -
                        prevColumnNames,
         | 
| 13297 | 
            -
                        currentColumnNames
         | 
| 13298 | 
            -
                      );
         | 
| 13299 | 
            -
                      if (removedColumns.length) {
         | 
| 13300 | 
            -
                        for (const removedColumn of removedColumns) {
         | 
| 13301 | 
            -
                          const res = await connection.query(
         | 
| 13302 | 
            -
                            `select count(\`${tableName}\`.\`${removedColumn}\`) as count from \`${tableName}\``
         | 
| 13303 | 
            -
                          );
         | 
| 13304 | 
            -
                          const count2 = Number(res[0].count);
         | 
| 13305 | 
            -
                          if (count2 > 0) {
         | 
| 13306 | 
            -
                            infoToPrint.push(
         | 
| 13307 | 
            -
                              `\xB7 You're about to delete ${source_default.underline(
         | 
| 13308 | 
            -
                                removedColumn
         | 
| 13309 | 
            -
                              )} column in ${tableName} table with ${count2} items`
         | 
| 13310 | 
            -
                            );
         | 
| 13311 | 
            -
                            columnsToRemove.push(removedColumn);
         | 
| 13312 | 
            -
                            shouldAskForApprove = true;
         | 
| 13313 | 
            -
                          }
         | 
| 13314 | 
            -
                        }
         | 
| 13315 | 
            -
                      }
         | 
| 13316 | 
            -
                      if (addedColumns.length) {
         | 
| 13317 | 
            -
                        for (const addedColumn of addedColumns) {
         | 
| 13318 | 
            -
                          const [res] = await connection.query(
         | 
| 13319 | 
            -
                            `select count(*) as count from \`${tableName}\``
         | 
| 13320 | 
            -
                          );
         | 
| 13321 | 
            -
                          const columnConf = json2.tables[tableName].columns[addedColumn];
         | 
| 13322 | 
            -
                          const count2 = Number(res.count);
         | 
| 13323 | 
            -
                          if (count2 > 0 && columnConf.notNull && !columnConf.default) {
         | 
| 13324 | 
            -
                            dataLoss = true;
         | 
| 13325 | 
            -
                            infoToPrint.push(
         | 
| 13326 | 
            -
                              `\xB7 You're about to add not-null ${source_default.underline(
         | 
| 13327 | 
            -
                                addedColumn
         | 
| 13328 | 
            -
                              )} column without default value to table, which contains ${count2} items`
         | 
| 13329 | 
            -
                            );
         | 
| 13330 | 
            -
                            shouldAskForApprove = true;
         | 
| 13331 | 
            -
                            tablesToTruncate.push(tableName);
         | 
| 13332 | 
            -
                            statementsToExecute.push(`DELETE FROM \`${tableName}\`;`);
         | 
| 13333 | 
            -
                          }
         | 
| 13334 | 
            -
                        }
         | 
| 13335 | 
            -
                      }
         | 
| 13336 | 
            -
                      const tablesReferencingCurrent = [];
         | 
| 13337 | 
            -
                      for (const table4 of Object.values(json2.tables)) {
         | 
| 13338 | 
            -
                        const tablesRefs = Object.values(json2.tables[table4.name].foreignKeys).filter((t) => SQLiteSquasher.unsquashPushFK(t).tableTo === tableName).map((it) => SQLiteSquasher.unsquashPushFK(it).tableFrom);
         | 
| 13339 | 
            -
                        tablesReferencingCurrent.push(...tablesRefs);
         | 
| 13340 | 
            -
                      }
         | 
| 13341 | 
            -
                      if (!tablesReferencingCurrent.length) {
         | 
| 13342 | 
            -
                        statementsToExecute.push(..._moveDataStatements(tableName, json2, dataLoss));
         | 
| 13343 | 
            -
                        continue;
         | 
| 13344 | 
            -
                      }
         | 
| 13345 | 
            -
                      const [{ foreign_keys: pragmaState }] = await connection.query(`PRAGMA foreign_keys;`);
         | 
| 13346 | 
            -
                      if (pragmaState) {
         | 
| 13347 | 
            -
                        statementsToExecute.push(`PRAGMA foreign_keys=OFF;`);
         | 
| 13348 | 
            -
                      }
         | 
| 13349 | 
            -
                      statementsToExecute.push(..._moveDataStatements(tableName, json2, dataLoss));
         | 
| 13350 | 
            -
                      if (pragmaState) {
         | 
| 13351 | 
            -
                        statementsToExecute.push(`PRAGMA foreign_keys=ON;`);
         | 
| 13352 | 
            -
                      }
         | 
| 13353 | 
            -
                    } else {
         | 
| 13354 | 
            -
                      const fromJsonStatement = fromJson([statement], "sqlite", "push");
         | 
| 13355 | 
            -
                      statementsToExecute.push(
         | 
| 13356 | 
            -
                        ...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
         | 
| 13357 | 
            -
                      );
         | 
| 13358 | 
            -
                    }
         | 
| 13359 | 
            -
                  }
         | 
| 13360 | 
            -
                  return {
         | 
| 13361 | 
            -
                    statementsToExecute,
         | 
| 13362 | 
            -
                    shouldAskForApprove,
         | 
| 13363 | 
            -
                    infoToPrint,
         | 
| 13364 | 
            -
                    columnsToRemove: [...new Set(columnsToRemove)],
         | 
| 13365 | 
            -
                    schemasToRemove: [...new Set(schemasToRemove)],
         | 
| 13366 | 
            -
                    tablesToTruncate: [...new Set(tablesToTruncate)],
         | 
| 13367 | 
            -
                    tablesToRemove: [...new Set(tablesToRemove)]
         | 
| 13368 | 
            -
                  };
         | 
| 13369 | 
            -
                };
         | 
| 13370 | 
            -
              }
         | 
| 13371 | 
            -
            });
         | 
| 13372 | 
            -
             | 
| 13373 13232 | 
             
            // src/jsonStatements.ts
         | 
| 13374 | 
            -
            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,  | 
| 13233 | 
            +
            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;
         | 
| 13375 13234 | 
             
            var init_jsonStatements = __esm({
         | 
| 13376 13235 | 
             
              "src/jsonStatements.ts"() {
         | 
| 13377 13236 | 
             
                "use strict";
         | 
| 13378 13237 | 
             
                init_source();
         | 
| 13379 | 
            -
                init_sqlitePushUtils();
         | 
| 13380 13238 | 
             
                init_views();
         | 
| 13381 13239 | 
             
                init_mysqlSchema();
         | 
| 13382 13240 | 
             
                init_pgSchema();
         | 
| @@ -14160,52 +14018,9 @@ var init_jsonStatements = __esm({ | |
| 14160 14018 | 
             
                    const columnPk = json2.tables[tableName].columns[columnName].primaryKey;
         | 
| 14161 14019 | 
             
                    const columnGenerated = json2.tables[tableName].columns[columnName].generated;
         | 
| 14162 14020 | 
             
                    const compositePk = json2.tables[tableName].compositePrimaryKeys[`${tableName}_${columnName}`];
         | 
| 14163 | 
            -
                    if (column4. | 
| 14021 | 
            +
                    if (typeof column4.name !== "string") {
         | 
| 14164 14022 | 
             
                      statements.push({
         | 
| 14165 | 
            -
                        type: " | 
| 14166 | 
            -
                        tableName,
         | 
| 14167 | 
            -
                        columnName,
         | 
| 14168 | 
            -
                        schema: schema4,
         | 
| 14169 | 
            -
                        newDataType: columnType,
         | 
| 14170 | 
            -
                        columnDefault,
         | 
| 14171 | 
            -
                        columnOnUpdate,
         | 
| 14172 | 
            -
                        columnNotNull,
         | 
| 14173 | 
            -
                        columnAutoIncrement,
         | 
| 14174 | 
            -
                        columnPk
         | 
| 14175 | 
            -
                      });
         | 
| 14176 | 
            -
                    }
         | 
| 14177 | 
            -
                    if (column4.autoincrement?.type === "changed") {
         | 
| 14178 | 
            -
                      const type = column4.autoincrement.new ? "alter_table_alter_column_set_autoincrement" : "alter_table_alter_column_drop_autoincrement";
         | 
| 14179 | 
            -
                      statements.push({
         | 
| 14180 | 
            -
                        type,
         | 
| 14181 | 
            -
                        tableName,
         | 
| 14182 | 
            -
                        columnName,
         | 
| 14183 | 
            -
                        schema: schema4,
         | 
| 14184 | 
            -
                        newDataType: columnType,
         | 
| 14185 | 
            -
                        columnDefault,
         | 
| 14186 | 
            -
                        columnOnUpdate,
         | 
| 14187 | 
            -
                        columnNotNull,
         | 
| 14188 | 
            -
                        columnAutoIncrement,
         | 
| 14189 | 
            -
                        columnPk
         | 
| 14190 | 
            -
                      });
         | 
| 14191 | 
            -
                    }
         | 
| 14192 | 
            -
                    if (column4.autoincrement?.type === "deleted") {
         | 
| 14193 | 
            -
                      statements.push({
         | 
| 14194 | 
            -
                        type: "alter_table_alter_column_drop_autoincrement",
         | 
| 14195 | 
            -
                        tableName,
         | 
| 14196 | 
            -
                        columnName,
         | 
| 14197 | 
            -
                        schema: schema4,
         | 
| 14198 | 
            -
                        newDataType: columnType,
         | 
| 14199 | 
            -
                        columnDefault,
         | 
| 14200 | 
            -
                        columnOnUpdate,
         | 
| 14201 | 
            -
                        columnNotNull,
         | 
| 14202 | 
            -
                        columnAutoIncrement,
         | 
| 14203 | 
            -
                        columnPk
         | 
| 14204 | 
            -
                      });
         | 
| 14205 | 
            -
                    }
         | 
| 14206 | 
            -
                    if (typeof column4.name !== "string") {
         | 
| 14207 | 
            -
                      statements.push({
         | 
| 14208 | 
            -
                        type: "alter_table_rename_column",
         | 
| 14023 | 
            +
                        type: "alter_table_rename_column",
         | 
| 14209 14024 | 
             
                        tableName,
         | 
| 14210 14025 | 
             
                        oldColumnName: column4.name.old,
         | 
| 14211 14026 | 
             
                        newColumnName: column4.name.new,
         | 
| @@ -14466,37 +14281,6 @@ var init_jsonStatements = __esm({ | |
| 14466 14281 | 
             
                    };
         | 
| 14467 14282 | 
             
                  });
         | 
| 14468 14283 | 
             
                };
         | 
| 14469 | 
            -
                prepareLibSQLCreateReferencesJson = (tableName, schema4, foreignKeys, json2, action) => {
         | 
| 14470 | 
            -
                  return Object.values(foreignKeys).map((fkData) => {
         | 
| 14471 | 
            -
                    const { columnsFrom, tableFrom, columnsTo } = action === "push" ? SQLiteSquasher.unsquashPushFK(fkData) : SQLiteSquasher.unsquashFK(fkData);
         | 
| 14472 | 
            -
                    let isMulticolumn = false;
         | 
| 14473 | 
            -
                    if (columnsFrom.length > 1 || columnsTo.length > 1) {
         | 
| 14474 | 
            -
                      isMulticolumn = true;
         | 
| 14475 | 
            -
                      return {
         | 
| 14476 | 
            -
                        type: "create_reference",
         | 
| 14477 | 
            -
                        tableName,
         | 
| 14478 | 
            -
                        data: fkData,
         | 
| 14479 | 
            -
                        schema: schema4,
         | 
| 14480 | 
            -
                        isMulticolumn
         | 
| 14481 | 
            -
                      };
         | 
| 14482 | 
            -
                    }
         | 
| 14483 | 
            -
                    const columnFrom = columnsFrom[0];
         | 
| 14484 | 
            -
                    const {
         | 
| 14485 | 
            -
                      notNull: columnNotNull,
         | 
| 14486 | 
            -
                      default: columnDefault,
         | 
| 14487 | 
            -
                      type: columnType
         | 
| 14488 | 
            -
                    } = json2.tables[tableFrom].columns[columnFrom];
         | 
| 14489 | 
            -
                    return {
         | 
| 14490 | 
            -
                      type: "create_reference",
         | 
| 14491 | 
            -
                      tableName,
         | 
| 14492 | 
            -
                      data: fkData,
         | 
| 14493 | 
            -
                      schema: schema4,
         | 
| 14494 | 
            -
                      columnNotNull,
         | 
| 14495 | 
            -
                      columnDefault,
         | 
| 14496 | 
            -
                      columnType
         | 
| 14497 | 
            -
                    };
         | 
| 14498 | 
            -
                  });
         | 
| 14499 | 
            -
                };
         | 
| 14500 14284 | 
             
                prepareDropReferencesJson = (tableName, schema4, foreignKeys) => {
         | 
| 14501 14285 | 
             
                  return Object.values(foreignKeys).map((fkData) => {
         | 
| 14502 14286 | 
             
                    return {
         | 
| @@ -14507,53 +14291,6 @@ var init_jsonStatements = __esm({ | |
| 14507 14291 | 
             
                    };
         | 
| 14508 14292 | 
             
                  });
         | 
| 14509 14293 | 
             
                };
         | 
| 14510 | 
            -
                prepareLibSQLDropReferencesJson = (tableName, schema4, foreignKeys, json2, meta, action) => {
         | 
| 14511 | 
            -
                  const statements = Object.values(foreignKeys).map((fkData) => {
         | 
| 14512 | 
            -
                    const { columnsFrom, tableFrom, columnsTo, name: name2, tableTo, onDelete, onUpdate } = action === "push" ? SQLiteSquasher.unsquashPushFK(fkData) : SQLiteSquasher.unsquashFK(fkData);
         | 
| 14513 | 
            -
                    const keys = Object.keys(json2.tables[tableName].columns);
         | 
| 14514 | 
            -
                    const filtered = columnsFrom.filter((it) => keys.includes(it));
         | 
| 14515 | 
            -
                    const fullDrop = filtered.length === 0;
         | 
| 14516 | 
            -
                    if (fullDrop) return;
         | 
| 14517 | 
            -
                    let isMulticolumn = false;
         | 
| 14518 | 
            -
                    if (columnsFrom.length > 1 || columnsTo.length > 1) {
         | 
| 14519 | 
            -
                      isMulticolumn = true;
         | 
| 14520 | 
            -
                      return {
         | 
| 14521 | 
            -
                        type: "delete_reference",
         | 
| 14522 | 
            -
                        tableName,
         | 
| 14523 | 
            -
                        data: fkData,
         | 
| 14524 | 
            -
                        schema: schema4,
         | 
| 14525 | 
            -
                        isMulticolumn
         | 
| 14526 | 
            -
                      };
         | 
| 14527 | 
            -
                    }
         | 
| 14528 | 
            -
                    const columnFrom = columnsFrom[0];
         | 
| 14529 | 
            -
                    const newTableName = getNewTableName(tableFrom, meta);
         | 
| 14530 | 
            -
                    const {
         | 
| 14531 | 
            -
                      notNull: columnNotNull,
         | 
| 14532 | 
            -
                      default: columnDefault,
         | 
| 14533 | 
            -
                      type: columnType
         | 
| 14534 | 
            -
                    } = json2.tables[newTableName].columns[columnFrom];
         | 
| 14535 | 
            -
                    const fkToSquash = {
         | 
| 14536 | 
            -
                      columnsFrom,
         | 
| 14537 | 
            -
                      columnsTo,
         | 
| 14538 | 
            -
                      name: name2,
         | 
| 14539 | 
            -
                      tableFrom: newTableName,
         | 
| 14540 | 
            -
                      tableTo,
         | 
| 14541 | 
            -
                      onDelete,
         | 
| 14542 | 
            -
                      onUpdate
         | 
| 14543 | 
            -
                    };
         | 
| 14544 | 
            -
                    const foreignKey = action === "push" ? SQLiteSquasher.squashPushFK(fkToSquash) : SQLiteSquasher.squashFK(fkToSquash);
         | 
| 14545 | 
            -
                    return {
         | 
| 14546 | 
            -
                      type: "delete_reference",
         | 
| 14547 | 
            -
                      tableName,
         | 
| 14548 | 
            -
                      data: foreignKey,
         | 
| 14549 | 
            -
                      schema: schema4,
         | 
| 14550 | 
            -
                      columnNotNull,
         | 
| 14551 | 
            -
                      columnDefault,
         | 
| 14552 | 
            -
                      columnType
         | 
| 14553 | 
            -
                    };
         | 
| 14554 | 
            -
                  });
         | 
| 14555 | 
            -
                  return statements.filter((it) => it);
         | 
| 14556 | 
            -
                };
         | 
| 14557 14294 | 
             
                prepareAlterReferencesJson = (tableName, schema4, foreignKeys) => {
         | 
| 14558 14295 | 
             
                  const stmts = [];
         | 
| 14559 14296 | 
             
                  Object.values(foreignKeys).map((val) => {
         | 
| @@ -14707,292 +14444,10 @@ var init_jsonStatements = __esm({ | |
| 14707 14444 | 
             
              }
         | 
| 14708 14445 | 
             
            });
         | 
| 14709 14446 |  | 
| 14710 | 
            -
            // src/statementCombiner.ts
         | 
| 14711 | 
            -
            var prepareLibSQLRecreateTable, prepareSQLiteRecreateTable, libSQLCombineStatements, sqliteCombineStatements;
         | 
| 14712 | 
            -
            var init_statementCombiner = __esm({
         | 
| 14713 | 
            -
              "src/statementCombiner.ts"() {
         | 
| 14714 | 
            -
                "use strict";
         | 
| 14715 | 
            -
                init_jsonStatements();
         | 
| 14716 | 
            -
                init_sqliteSchema();
         | 
| 14717 | 
            -
                prepareLibSQLRecreateTable = (table4, action) => {
         | 
| 14718 | 
            -
                  const { name: name2, columns, uniqueConstraints, indexes } = table4;
         | 
| 14719 | 
            -
                  const composites = Object.values(table4.compositePrimaryKeys).map(
         | 
| 14720 | 
            -
                    (it) => SQLiteSquasher.unsquashPK(it)
         | 
| 14721 | 
            -
                  );
         | 
| 14722 | 
            -
                  const references2 = Object.values(table4.foreignKeys);
         | 
| 14723 | 
            -
                  const fks = references2.map(
         | 
| 14724 | 
            -
                    (it) => action === "push" ? SQLiteSquasher.unsquashPushFK(it) : SQLiteSquasher.unsquashFK(it)
         | 
| 14725 | 
            -
                  );
         | 
| 14726 | 
            -
                  const statements = [
         | 
| 14727 | 
            -
                    {
         | 
| 14728 | 
            -
                      type: "recreate_table",
         | 
| 14729 | 
            -
                      tableName: name2,
         | 
| 14730 | 
            -
                      columns: Object.values(columns),
         | 
| 14731 | 
            -
                      compositePKs: composites,
         | 
| 14732 | 
            -
                      referenceData: fks,
         | 
| 14733 | 
            -
                      uniqueConstraints: Object.values(uniqueConstraints)
         | 
| 14734 | 
            -
                    }
         | 
| 14735 | 
            -
                  ];
         | 
| 14736 | 
            -
                  if (Object.keys(indexes).length) {
         | 
| 14737 | 
            -
                    statements.push(...prepareCreateIndexesJson(name2, "", indexes));
         | 
| 14738 | 
            -
                  }
         | 
| 14739 | 
            -
                  return statements;
         | 
| 14740 | 
            -
                };
         | 
| 14741 | 
            -
                prepareSQLiteRecreateTable = (table4, action) => {
         | 
| 14742 | 
            -
                  const { name: name2, columns, uniqueConstraints, indexes } = table4;
         | 
| 14743 | 
            -
                  const composites = Object.values(table4.compositePrimaryKeys).map(
         | 
| 14744 | 
            -
                    (it) => SQLiteSquasher.unsquashPK(it)
         | 
| 14745 | 
            -
                  );
         | 
| 14746 | 
            -
                  const references2 = Object.values(table4.foreignKeys);
         | 
| 14747 | 
            -
                  const fks = references2.map(
         | 
| 14748 | 
            -
                    (it) => action === "push" ? SQLiteSquasher.unsquashPushFK(it) : SQLiteSquasher.unsquashFK(it)
         | 
| 14749 | 
            -
                  );
         | 
| 14750 | 
            -
                  const statements = [
         | 
| 14751 | 
            -
                    {
         | 
| 14752 | 
            -
                      type: "recreate_table",
         | 
| 14753 | 
            -
                      tableName: name2,
         | 
| 14754 | 
            -
                      columns: Object.values(columns),
         | 
| 14755 | 
            -
                      compositePKs: composites,
         | 
| 14756 | 
            -
                      referenceData: fks,
         | 
| 14757 | 
            -
                      uniqueConstraints: Object.values(uniqueConstraints)
         | 
| 14758 | 
            -
                    }
         | 
| 14759 | 
            -
                  ];
         | 
| 14760 | 
            -
                  if (Object.keys(indexes).length) {
         | 
| 14761 | 
            -
                    statements.push(...prepareCreateIndexesJson(name2, "", indexes));
         | 
| 14762 | 
            -
                  }
         | 
| 14763 | 
            -
                  return statements;
         | 
| 14764 | 
            -
                };
         | 
| 14765 | 
            -
                libSQLCombineStatements = (statements, json2, action) => {
         | 
| 14766 | 
            -
                  const newStatements = {};
         | 
| 14767 | 
            -
                  for (const statement of statements) {
         | 
| 14768 | 
            -
                    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") {
         | 
| 14769 | 
            -
                      const tableName2 = statement.tableName;
         | 
| 14770 | 
            -
                      const statementsForTable2 = newStatements[tableName2];
         | 
| 14771 | 
            -
                      if (!statementsForTable2) {
         | 
| 14772 | 
            -
                        newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         | 
| 14773 | 
            -
                        continue;
         | 
| 14774 | 
            -
                      }
         | 
| 14775 | 
            -
                      if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         | 
| 14776 | 
            -
                        const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         | 
| 14777 | 
            -
                        const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         | 
| 14778 | 
            -
                        if (wasRename) {
         | 
| 14779 | 
            -
                          newStatements[tableName2].push(...preparedStatements);
         | 
| 14780 | 
            -
                        } else {
         | 
| 14781 | 
            -
                          newStatements[tableName2] = preparedStatements;
         | 
| 14782 | 
            -
                        }
         | 
| 14783 | 
            -
                        continue;
         | 
| 14784 | 
            -
                      }
         | 
| 14785 | 
            -
                      continue;
         | 
| 14786 | 
            -
                    }
         | 
| 14787 | 
            -
                    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") {
         | 
| 14788 | 
            -
                      const { tableName: tableName2, columnName, columnPk } = statement;
         | 
| 14789 | 
            -
                      const columnIsPartOfForeignKey = Object.values(
         | 
| 14790 | 
            -
                        json2.tables[tableName2].foreignKeys
         | 
| 14791 | 
            -
                      ).some((it) => {
         | 
| 14792 | 
            -
                        const unsquashFk = action === "push" ? SQLiteSquasher.unsquashPushFK(it) : SQLiteSquasher.unsquashFK(it);
         | 
| 14793 | 
            -
                        return unsquashFk.columnsFrom.includes(columnName);
         | 
| 14794 | 
            -
                      });
         | 
| 14795 | 
            -
                      const statementsForTable2 = newStatements[tableName2];
         | 
| 14796 | 
            -
                      if (!statementsForTable2 && (columnIsPartOfForeignKey || columnPk)) {
         | 
| 14797 | 
            -
                        newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         | 
| 14798 | 
            -
                        continue;
         | 
| 14799 | 
            -
                      }
         | 
| 14800 | 
            -
                      if (statementsForTable2 && (columnIsPartOfForeignKey || columnPk)) {
         | 
| 14801 | 
            -
                        if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         | 
| 14802 | 
            -
                          const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         | 
| 14803 | 
            -
                          const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         | 
| 14804 | 
            -
                          if (wasRename) {
         | 
| 14805 | 
            -
                            newStatements[tableName2].push(...preparedStatements);
         | 
| 14806 | 
            -
                          } else {
         | 
| 14807 | 
            -
                            newStatements[tableName2] = preparedStatements;
         | 
| 14808 | 
            -
                          }
         | 
| 14809 | 
            -
                        }
         | 
| 14810 | 
            -
                        continue;
         | 
| 14811 | 
            -
                      }
         | 
| 14812 | 
            -
                      if (statementsForTable2 && !(columnIsPartOfForeignKey || columnPk)) {
         | 
| 14813 | 
            -
                        if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         | 
| 14814 | 
            -
                          newStatements[tableName2].push(statement);
         | 
| 14815 | 
            -
                        }
         | 
| 14816 | 
            -
                        continue;
         | 
| 14817 | 
            -
                      }
         | 
| 14818 | 
            -
                      newStatements[tableName2] = [statement];
         | 
| 14819 | 
            -
                      continue;
         | 
| 14820 | 
            -
                    }
         | 
| 14821 | 
            -
                    if (statement.type === "create_reference") {
         | 
| 14822 | 
            -
                      const tableName2 = statement.tableName;
         | 
| 14823 | 
            -
                      const data = action === "push" ? SQLiteSquasher.unsquashPushFK(statement.data) : SQLiteSquasher.unsquashFK(statement.data);
         | 
| 14824 | 
            -
                      const statementsForTable2 = newStatements[tableName2];
         | 
| 14825 | 
            -
                      if (!statementsForTable2) {
         | 
| 14826 | 
            -
                        newStatements[tableName2] = statement.isMulticolumn ? prepareLibSQLRecreateTable(json2.tables[tableName2], action) : [statement];
         | 
| 14827 | 
            -
                        continue;
         | 
| 14828 | 
            -
                      }
         | 
| 14829 | 
            -
                      if (!statement.isMulticolumn && statementsForTable2.some(
         | 
| 14830 | 
            -
                        (st) => st.type === "sqlite_alter_table_add_column" && st.column.name === data.columnsFrom[0]
         | 
| 14831 | 
            -
                      )) {
         | 
| 14832 | 
            -
                        continue;
         | 
| 14833 | 
            -
                      }
         | 
| 14834 | 
            -
                      if (statement.isMulticolumn) {
         | 
| 14835 | 
            -
                        if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         | 
| 14836 | 
            -
                          const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         | 
| 14837 | 
            -
                          const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         | 
| 14838 | 
            -
                          if (wasRename) {
         | 
| 14839 | 
            -
                            newStatements[tableName2].push(...preparedStatements);
         | 
| 14840 | 
            -
                          } else {
         | 
| 14841 | 
            -
                            newStatements[tableName2] = preparedStatements;
         | 
| 14842 | 
            -
                          }
         | 
| 14843 | 
            -
                          continue;
         | 
| 14844 | 
            -
                        }
         | 
| 14845 | 
            -
                        continue;
         | 
| 14846 | 
            -
                      }
         | 
| 14847 | 
            -
                      if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         | 
| 14848 | 
            -
                        newStatements[tableName2].push(statement);
         | 
| 14849 | 
            -
                      }
         | 
| 14850 | 
            -
                      continue;
         | 
| 14851 | 
            -
                    }
         | 
| 14852 | 
            -
                    if (statement.type === "delete_reference") {
         | 
| 14853 | 
            -
                      const tableName2 = statement.tableName;
         | 
| 14854 | 
            -
                      const statementsForTable2 = newStatements[tableName2];
         | 
| 14855 | 
            -
                      if (!statementsForTable2) {
         | 
| 14856 | 
            -
                        newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         | 
| 14857 | 
            -
                        continue;
         | 
| 14858 | 
            -
                      }
         | 
| 14859 | 
            -
                      if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         | 
| 14860 | 
            -
                        const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         | 
| 14861 | 
            -
                        const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         | 
| 14862 | 
            -
                        if (wasRename) {
         | 
| 14863 | 
            -
                          newStatements[tableName2].push(...preparedStatements);
         | 
| 14864 | 
            -
                        } else {
         | 
| 14865 | 
            -
                          newStatements[tableName2] = preparedStatements;
         | 
| 14866 | 
            -
                        }
         | 
| 14867 | 
            -
                        continue;
         | 
| 14868 | 
            -
                      }
         | 
| 14869 | 
            -
                      continue;
         | 
| 14870 | 
            -
                    }
         | 
| 14871 | 
            -
                    if (statement.type === "sqlite_alter_table_add_column" && statement.column.primaryKey) {
         | 
| 14872 | 
            -
                      const tableName2 = statement.tableName;
         | 
| 14873 | 
            -
                      const statementsForTable2 = newStatements[tableName2];
         | 
| 14874 | 
            -
                      if (!statementsForTable2) {
         | 
| 14875 | 
            -
                        newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         | 
| 14876 | 
            -
                        continue;
         | 
| 14877 | 
            -
                      }
         | 
| 14878 | 
            -
                      if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         | 
| 14879 | 
            -
                        const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         | 
| 14880 | 
            -
                        const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         | 
| 14881 | 
            -
                        if (wasRename) {
         | 
| 14882 | 
            -
                          newStatements[tableName2].push(...preparedStatements);
         | 
| 14883 | 
            -
                        } else {
         | 
| 14884 | 
            -
                          newStatements[tableName2] = preparedStatements;
         | 
| 14885 | 
            -
                        }
         | 
| 14886 | 
            -
                        continue;
         | 
| 14887 | 
            -
                      }
         | 
| 14888 | 
            -
                      continue;
         | 
| 14889 | 
            -
                    }
         | 
| 14890 | 
            -
                    const tableName = statement.type === "rename_table" ? statement.tableNameTo : statement.tableName;
         | 
| 14891 | 
            -
                    const statementsForTable = newStatements[tableName];
         | 
| 14892 | 
            -
                    if (!statementsForTable) {
         | 
| 14893 | 
            -
                      newStatements[tableName] = [statement];
         | 
| 14894 | 
            -
                      continue;
         | 
| 14895 | 
            -
                    }
         | 
| 14896 | 
            -
                    if (!statementsForTable.some(({ type }) => type === "recreate_table")) {
         | 
| 14897 | 
            -
                      newStatements[tableName].push(statement);
         | 
| 14898 | 
            -
                    }
         | 
| 14899 | 
            -
                  }
         | 
| 14900 | 
            -
                  const combinedStatements = Object.values(newStatements).flat();
         | 
| 14901 | 
            -
                  const renamedTables = combinedStatements.filter((it) => it.type === "rename_table");
         | 
| 14902 | 
            -
                  const renamedColumns = combinedStatements.filter((it) => it.type === "alter_table_rename_column");
         | 
| 14903 | 
            -
                  const rest = combinedStatements.filter((it) => it.type !== "rename_table" && it.type !== "alter_table_rename_column");
         | 
| 14904 | 
            -
                  return [...renamedTables, ...renamedColumns, ...rest];
         | 
| 14905 | 
            -
                };
         | 
| 14906 | 
            -
                sqliteCombineStatements = (statements, json2, action) => {
         | 
| 14907 | 
            -
                  const newStatements = {};
         | 
| 14908 | 
            -
                  for (const statement of statements) {
         | 
| 14909 | 
            -
                    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") {
         | 
| 14910 | 
            -
                      const tableName2 = statement.tableName;
         | 
| 14911 | 
            -
                      const statementsForTable2 = newStatements[tableName2];
         | 
| 14912 | 
            -
                      if (!statementsForTable2) {
         | 
| 14913 | 
            -
                        newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         | 
| 14914 | 
            -
                        continue;
         | 
| 14915 | 
            -
                      }
         | 
| 14916 | 
            -
                      if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         | 
| 14917 | 
            -
                        const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         | 
| 14918 | 
            -
                        const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         | 
| 14919 | 
            -
                        if (wasRename) {
         | 
| 14920 | 
            -
                          newStatements[tableName2].push(...preparedStatements);
         | 
| 14921 | 
            -
                        } else {
         | 
| 14922 | 
            -
                          newStatements[tableName2] = preparedStatements;
         | 
| 14923 | 
            -
                        }
         | 
| 14924 | 
            -
                        continue;
         | 
| 14925 | 
            -
                      }
         | 
| 14926 | 
            -
                      continue;
         | 
| 14927 | 
            -
                    }
         | 
| 14928 | 
            -
                    if (statement.type === "sqlite_alter_table_add_column" && statement.column.primaryKey) {
         | 
| 14929 | 
            -
                      const tableName2 = statement.tableName;
         | 
| 14930 | 
            -
                      const statementsForTable2 = newStatements[tableName2];
         | 
| 14931 | 
            -
                      if (!statementsForTable2) {
         | 
| 14932 | 
            -
                        newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         | 
| 14933 | 
            -
                        continue;
         | 
| 14934 | 
            -
                      }
         | 
| 14935 | 
            -
                      if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         | 
| 14936 | 
            -
                        const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         | 
| 14937 | 
            -
                        const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         | 
| 14938 | 
            -
                        if (wasRename) {
         | 
| 14939 | 
            -
                          newStatements[tableName2].push(...preparedStatements);
         | 
| 14940 | 
            -
                        } else {
         | 
| 14941 | 
            -
                          newStatements[tableName2] = preparedStatements;
         | 
| 14942 | 
            -
                        }
         | 
| 14943 | 
            -
                        continue;
         | 
| 14944 | 
            -
                      }
         | 
| 14945 | 
            -
                      continue;
         | 
| 14946 | 
            -
                    }
         | 
| 14947 | 
            -
                    if (statement.type === "create_reference") {
         | 
| 14948 | 
            -
                      const tableName2 = statement.tableName;
         | 
| 14949 | 
            -
                      const data = action === "push" ? SQLiteSquasher.unsquashPushFK(statement.data) : SQLiteSquasher.unsquashFK(statement.data);
         | 
| 14950 | 
            -
                      const statementsForTable2 = newStatements[tableName2];
         | 
| 14951 | 
            -
                      if (!statementsForTable2) {
         | 
| 14952 | 
            -
                        newStatements[tableName2] = prepareSQLiteRecreateTable(json2.tables[tableName2], action);
         | 
| 14953 | 
            -
                        continue;
         | 
| 14954 | 
            -
                      }
         | 
| 14955 | 
            -
                      if (data.columnsFrom.length === 1 && statementsForTable2.some(
         | 
| 14956 | 
            -
                        (st) => st.type === "sqlite_alter_table_add_column" && st.column.name === data.columnsFrom[0]
         | 
| 14957 | 
            -
                      )) {
         | 
| 14958 | 
            -
                        continue;
         | 
| 14959 | 
            -
                      }
         | 
| 14960 | 
            -
                      if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         | 
| 14961 | 
            -
                        const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         | 
| 14962 | 
            -
                        const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         | 
| 14963 | 
            -
                        if (wasRename) {
         | 
| 14964 | 
            -
                          newStatements[tableName2].push(...preparedStatements);
         | 
| 14965 | 
            -
                        } else {
         | 
| 14966 | 
            -
                          newStatements[tableName2] = preparedStatements;
         | 
| 14967 | 
            -
                        }
         | 
| 14968 | 
            -
                        continue;
         | 
| 14969 | 
            -
                      }
         | 
| 14970 | 
            -
                      continue;
         | 
| 14971 | 
            -
                    }
         | 
| 14972 | 
            -
                    const tableName = statement.type === "rename_table" ? statement.tableNameTo : statement.tableName;
         | 
| 14973 | 
            -
                    const statementsForTable = newStatements[tableName];
         | 
| 14974 | 
            -
                    if (!statementsForTable) {
         | 
| 14975 | 
            -
                      newStatements[tableName] = [statement];
         | 
| 14976 | 
            -
                      continue;
         | 
| 14977 | 
            -
                    }
         | 
| 14978 | 
            -
                    if (!statementsForTable.some(({ type }) => type === "recreate_table")) {
         | 
| 14979 | 
            -
                      newStatements[tableName].push(statement);
         | 
| 14980 | 
            -
                    }
         | 
| 14981 | 
            -
                  }
         | 
| 14982 | 
            -
                  const combinedStatements = Object.values(newStatements).flat();
         | 
| 14983 | 
            -
                  const renamedTables = combinedStatements.filter((it) => it.type === "rename_table");
         | 
| 14984 | 
            -
                  const renamedColumns = combinedStatements.filter((it) => it.type === "alter_table_rename_column");
         | 
| 14985 | 
            -
                  const rest = combinedStatements.filter((it) => it.type !== "rename_table" && it.type !== "alter_table_rename_column");
         | 
| 14986 | 
            -
                  return [...renamedTables, ...renamedColumns, ...rest];
         | 
| 14987 | 
            -
                };
         | 
| 14988 | 
            -
              }
         | 
| 14989 | 
            -
            });
         | 
| 14990 | 
            -
             | 
| 14991 14447 | 
             
            // src/snapshotsDiffer.ts
         | 
| 14992 14448 | 
             
            var snapshotsDiffer_exports = {};
         | 
| 14993 14449 | 
             
            __export(snapshotsDiffer_exports, {
         | 
| 14994 14450 | 
             
              alteredTableScheme: () => alteredTableScheme,
         | 
| 14995 | 
            -
              applyLibSQLSnapshotsDiff: () => applyLibSQLSnapshotsDiff,
         | 
| 14996 14451 | 
             
              applyMysqlSnapshotsDiff: () => applyMysqlSnapshotsDiff,
         | 
| 14997 14452 | 
             
              applyPgSnapshotsDiff: () => applyPgSnapshotsDiff,
         | 
| 14998 14453 | 
             
              applySqliteSnapshotsDiff: () => applySqliteSnapshotsDiff,
         | 
| @@ -15002,7 +14457,7 @@ __export(snapshotsDiffer_exports, { | |
| 15002 14457 | 
             
              makePatched: () => makePatched,
         | 
| 15003 14458 | 
             
              makeSelfOrPatched: () => makeSelfOrPatched
         | 
| 15004 14459 | 
             
            });
         | 
| 15005 | 
            -
            var makeChanged, makeSelfOrChanged, makePatched, makeSelfOrPatched, columnSchema, alteredColumnSchema, enumSchema2, changedEnumSchema, tableScheme, alteredTableScheme, diffResultScheme, diffResultSchemeMysql, diffResultSchemeSQLite, schemaChangeFor, nameChangeFor, nameSchemaChangeFor, columnChangeFor, applyPgSnapshotsDiff, applyMysqlSnapshotsDiff, applySqliteSnapshotsDiff | 
| 14460 | 
            +
            var makeChanged, makeSelfOrChanged, makePatched, makeSelfOrPatched, columnSchema, alteredColumnSchema, enumSchema2, changedEnumSchema, tableScheme, alteredTableScheme, diffResultScheme, diffResultSchemeMysql, diffResultSchemeSQLite, schemaChangeFor, nameChangeFor, nameSchemaChangeFor, columnChangeFor, applyPgSnapshotsDiff, applyMysqlSnapshotsDiff, applySqliteSnapshotsDiff;
         | 
| 15006 14461 | 
             
            var init_snapshotsDiffer = __esm({
         | 
| 15007 14462 | 
             
              "src/snapshotsDiffer.ts"() {
         | 
| 15008 14463 | 
             
                "use strict";
         | 
| @@ -15014,7 +14469,6 @@ var init_snapshotsDiffer = __esm({ | |
| 15014 14469 | 
             
                init_mysqlSchema();
         | 
| 15015 14470 | 
             
                init_pgSchema();
         | 
| 15016 14471 | 
             
                init_sqliteSchema();
         | 
| 15017 | 
            -
                init_statementCombiner();
         | 
| 15018 14472 | 
             
                init_utils();
         | 
| 15019 14473 | 
             
                makeChanged = (schema4) => {
         | 
| 15020 14474 | 
             
                  return objectType({
         | 
| @@ -15901,339 +15355,40 @@ var init_snapshotsDiffer = __esm({ | |
| 15901 15355 | 
             
                  const jsonAddedUniqueConstraints = [];
         | 
| 15902 15356 | 
             
                  const jsonDeletedUniqueConstraints = [];
         | 
| 15903 15357 | 
             
                  const jsonAlteredUniqueConstraints = [];
         | 
| 15904 | 
            -
                  const jsonRenameColumnsStatements = columnRenames.map((it) => prepareRenameColumns(it.table, "", it.renames)).flat();
         | 
| 15905 | 
            -
                  const jsonAddColumnsStatemets = columnCreates.map((it) => _prepareAddColumns(it.table, "", it.columns)).flat();
         | 
| 15906 | 
            -
                  const jsonDropColumnsStatemets = columnDeletes.map((it) => _prepareDropColumns(it.table, "", it.columns)).flat();
         | 
| 15907 | 
            -
                  alteredTables.forEach((it) => {
         | 
| 15908 | 
            -
                    let addedColumns = [];
         | 
| 15909 | 
            -
                    for (const addedPkName of Object.keys(it.addedCompositePKs)) {
         | 
| 15910 | 
            -
                      const addedPkColumns = it.addedCompositePKs[addedPkName];
         | 
| 15911 | 
            -
                      addedColumns = MySqlSquasher.unsquashPK(addedPkColumns).columns;
         | 
| 15912 | 
            -
                    }
         | 
| 15913 | 
            -
                    let deletedColumns = [];
         | 
| 15914 | 
            -
                    for (const deletedPkName of Object.keys(it.deletedCompositePKs)) {
         | 
| 15915 | 
            -
                      const deletedPkColumns = it.deletedCompositePKs[deletedPkName];
         | 
| 15916 | 
            -
                      deletedColumns = MySqlSquasher.unsquashPK(deletedPkColumns).columns;
         | 
| 15917 | 
            -
                    }
         | 
| 15918 | 
            -
                    const doPerformDeleteAndCreate = JSON.stringify(addedColumns) !== JSON.stringify(deletedColumns);
         | 
| 15919 | 
            -
                    let addedCompositePKs = [];
         | 
| 15920 | 
            -
                    let deletedCompositePKs = [];
         | 
| 15921 | 
            -
                    let alteredCompositePKs = [];
         | 
| 15922 | 
            -
                    addedCompositePKs = prepareAddCompositePrimaryKeyMySql(
         | 
| 15923 | 
            -
                      it.name,
         | 
| 15924 | 
            -
                      it.addedCompositePKs,
         | 
| 15925 | 
            -
                      prevFull,
         | 
| 15926 | 
            -
                      curFull
         | 
| 15927 | 
            -
                    );
         | 
| 15928 | 
            -
                    deletedCompositePKs = prepareDeleteCompositePrimaryKeyMySql(
         | 
| 15929 | 
            -
                      it.name,
         | 
| 15930 | 
            -
                      it.deletedCompositePKs,
         | 
| 15931 | 
            -
                      prevFull
         | 
| 15932 | 
            -
                    );
         | 
| 15933 | 
            -
                    alteredCompositePKs = prepareAlterCompositePrimaryKeyMySql(
         | 
| 15934 | 
            -
                      it.name,
         | 
| 15935 | 
            -
                      it.alteredCompositePKs,
         | 
| 15936 | 
            -
                      prevFull,
         | 
| 15937 | 
            -
                      curFull
         | 
| 15938 | 
            -
                    );
         | 
| 15939 | 
            -
                    let addedUniqueConstraints = [];
         | 
| 15940 | 
            -
                    let deletedUniqueConstraints = [];
         | 
| 15941 | 
            -
                    let alteredUniqueConstraints = [];
         | 
| 15942 | 
            -
                    addedUniqueConstraints = prepareAddUniqueConstraintPg(
         | 
| 15943 | 
            -
                      it.name,
         | 
| 15944 | 
            -
                      it.schema,
         | 
| 15945 | 
            -
                      it.addedUniqueConstraints
         | 
| 15946 | 
            -
                    );
         | 
| 15947 | 
            -
                    deletedUniqueConstraints = prepareDeleteUniqueConstraintPg(
         | 
| 15948 | 
            -
                      it.name,
         | 
| 15949 | 
            -
                      it.schema,
         | 
| 15950 | 
            -
                      it.deletedUniqueConstraints
         | 
| 15951 | 
            -
                    );
         | 
| 15952 | 
            -
                    if (it.alteredUniqueConstraints) {
         | 
| 15953 | 
            -
                      const added = {};
         | 
| 15954 | 
            -
                      const deleted = {};
         | 
| 15955 | 
            -
                      for (const k of Object.keys(it.alteredUniqueConstraints)) {
         | 
| 15956 | 
            -
                        added[k] = it.alteredUniqueConstraints[k].__new;
         | 
| 15957 | 
            -
                        deleted[k] = it.alteredUniqueConstraints[k].__old;
         | 
| 15958 | 
            -
                      }
         | 
| 15959 | 
            -
                      addedUniqueConstraints.push(
         | 
| 15960 | 
            -
                        ...prepareAddUniqueConstraintPg(it.name, it.schema, added)
         | 
| 15961 | 
            -
                      );
         | 
| 15962 | 
            -
                      deletedUniqueConstraints.push(
         | 
| 15963 | 
            -
                        ...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
         | 
| 15964 | 
            -
                      );
         | 
| 15965 | 
            -
                    }
         | 
| 15966 | 
            -
                    jsonAddedCompositePKs.push(...addedCompositePKs);
         | 
| 15967 | 
            -
                    jsonDeletedCompositePKs.push(...deletedCompositePKs);
         | 
| 15968 | 
            -
                    jsonAlteredCompositePKs.push(...alteredCompositePKs);
         | 
| 15969 | 
            -
                    jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
         | 
| 15970 | 
            -
                    jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
         | 
| 15971 | 
            -
                    jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
         | 
| 15972 | 
            -
                  });
         | 
| 15973 | 
            -
                  const rColumns = jsonRenameColumnsStatements.map((it) => {
         | 
| 15974 | 
            -
                    const tableName = it.tableName;
         | 
| 15975 | 
            -
                    const schema4 = it.schema;
         | 
| 15976 | 
            -
                    return {
         | 
| 15977 | 
            -
                      from: { schema: schema4, table: tableName, column: it.oldColumnName },
         | 
| 15978 | 
            -
                      to: { schema: schema4, table: tableName, column: it.newColumnName }
         | 
| 15979 | 
            -
                    };
         | 
| 15980 | 
            -
                  });
         | 
| 15981 | 
            -
                  const jsonTableAlternations = alteredTables.map((it) => {
         | 
| 15982 | 
            -
                    return prepareAlterColumnsMysql(
         | 
| 15983 | 
            -
                      it.name,
         | 
| 15984 | 
            -
                      it.schema,
         | 
| 15985 | 
            -
                      it.altered,
         | 
| 15986 | 
            -
                      json1,
         | 
| 15987 | 
            -
                      json2,
         | 
| 15988 | 
            -
                      action
         | 
| 15989 | 
            -
                    );
         | 
| 15990 | 
            -
                  }).flat();
         | 
| 15991 | 
            -
                  const jsonCreateIndexesForAllAlteredTables = alteredTables.map((it) => {
         | 
| 15992 | 
            -
                    return prepareCreateIndexesJson(
         | 
| 15993 | 
            -
                      it.name,
         | 
| 15994 | 
            -
                      it.schema,
         | 
| 15995 | 
            -
                      it.addedIndexes || {},
         | 
| 15996 | 
            -
                      curFull.internal
         | 
| 15997 | 
            -
                    );
         | 
| 15998 | 
            -
                  }).flat();
         | 
| 15999 | 
            -
                  const jsonDropIndexesForAllAlteredTables = alteredTables.map((it) => {
         | 
| 16000 | 
            -
                    return prepareDropIndexesJson(
         | 
| 16001 | 
            -
                      it.name,
         | 
| 16002 | 
            -
                      it.schema,
         | 
| 16003 | 
            -
                      it.deletedIndexes || {}
         | 
| 16004 | 
            -
                    );
         | 
| 16005 | 
            -
                  }).flat();
         | 
| 16006 | 
            -
                  alteredTables.forEach((it) => {
         | 
| 16007 | 
            -
                    const droppedIndexes = Object.keys(it.alteredIndexes).reduce(
         | 
| 16008 | 
            -
                      (current, item) => {
         | 
| 16009 | 
            -
                        current[item] = it.alteredIndexes[item].__old;
         | 
| 16010 | 
            -
                        return current;
         | 
| 16011 | 
            -
                      },
         | 
| 16012 | 
            -
                      {}
         | 
| 16013 | 
            -
                    );
         | 
| 16014 | 
            -
                    const createdIndexes = Object.keys(it.alteredIndexes).reduce(
         | 
| 16015 | 
            -
                      (current, item) => {
         | 
| 16016 | 
            -
                        current[item] = it.alteredIndexes[item].__new;
         | 
| 16017 | 
            -
                        return current;
         | 
| 16018 | 
            -
                      },
         | 
| 16019 | 
            -
                      {}
         | 
| 16020 | 
            -
                    );
         | 
| 16021 | 
            -
                    jsonCreateIndexesForAllAlteredTables.push(
         | 
| 16022 | 
            -
                      ...prepareCreateIndexesJson(it.name, it.schema, createdIndexes || {})
         | 
| 16023 | 
            -
                    );
         | 
| 16024 | 
            -
                    jsonDropIndexesForAllAlteredTables.push(
         | 
| 16025 | 
            -
                      ...prepareDropIndexesJson(it.name, it.schema, droppedIndexes || {})
         | 
| 16026 | 
            -
                    );
         | 
| 16027 | 
            -
                  });
         | 
| 16028 | 
            -
                  const jsonCreateReferencesForCreatedTables = createdTables.map((it) => {
         | 
| 16029 | 
            -
                    return prepareCreateReferencesJson(it.name, it.schema, it.foreignKeys);
         | 
| 16030 | 
            -
                  }).flat();
         | 
| 16031 | 
            -
                  const jsonReferencesForAllAlteredTables = alteredTables.map((it) => {
         | 
| 16032 | 
            -
                    const forAdded = prepareCreateReferencesJson(
         | 
| 16033 | 
            -
                      it.name,
         | 
| 16034 | 
            -
                      it.schema,
         | 
| 16035 | 
            -
                      it.addedForeignKeys
         | 
| 16036 | 
            -
                    );
         | 
| 16037 | 
            -
                    const forAltered = prepareDropReferencesJson(
         | 
| 16038 | 
            -
                      it.name,
         | 
| 16039 | 
            -
                      it.schema,
         | 
| 16040 | 
            -
                      it.deletedForeignKeys
         | 
| 16041 | 
            -
                    );
         | 
| 16042 | 
            -
                    const alteredFKs = prepareAlterReferencesJson(
         | 
| 16043 | 
            -
                      it.name,
         | 
| 16044 | 
            -
                      it.schema,
         | 
| 16045 | 
            -
                      it.alteredForeignKeys
         | 
| 16046 | 
            -
                    );
         | 
| 16047 | 
            -
                    return [...forAdded, ...forAltered, ...alteredFKs];
         | 
| 16048 | 
            -
                  }).flat();
         | 
| 16049 | 
            -
                  const jsonCreatedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
         | 
| 16050 | 
            -
                    (t) => t.type === "create_reference"
         | 
| 16051 | 
            -
                  );
         | 
| 16052 | 
            -
                  const jsonDroppedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
         | 
| 16053 | 
            -
                    (t) => t.type === "delete_reference"
         | 
| 16054 | 
            -
                  );
         | 
| 16055 | 
            -
                  const jsonMySqlCreateTables = createdTables.map((it) => {
         | 
| 16056 | 
            -
                    return prepareMySqlCreateTableJson(
         | 
| 16057 | 
            -
                      it,
         | 
| 16058 | 
            -
                      curFull,
         | 
| 16059 | 
            -
                      curFull.internal
         | 
| 16060 | 
            -
                    );
         | 
| 16061 | 
            -
                  });
         | 
| 16062 | 
            -
                  jsonStatements.push(...jsonMySqlCreateTables);
         | 
| 16063 | 
            -
                  jsonStatements.push(...jsonDropTables);
         | 
| 16064 | 
            -
                  jsonStatements.push(...jsonRenameTables);
         | 
| 16065 | 
            -
                  jsonStatements.push(...jsonRenameColumnsStatements);
         | 
| 16066 | 
            -
                  jsonStatements.push(...jsonDeletedUniqueConstraints);
         | 
| 16067 | 
            -
                  jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
         | 
| 16068 | 
            -
                  jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
         | 
| 16069 | 
            -
                  jsonStatements.push(...jsonDeletedCompositePKs);
         | 
| 16070 | 
            -
                  jsonStatements.push(...jsonTableAlternations);
         | 
| 16071 | 
            -
                  jsonStatements.push(...jsonAddedCompositePKs);
         | 
| 16072 | 
            -
                  jsonStatements.push(...jsonAddedUniqueConstraints);
         | 
| 16073 | 
            -
                  jsonStatements.push(...jsonDeletedUniqueConstraints);
         | 
| 16074 | 
            -
                  jsonStatements.push(...jsonAddColumnsStatemets);
         | 
| 16075 | 
            -
                  jsonStatements.push(...jsonCreateReferencesForCreatedTables);
         | 
| 16076 | 
            -
                  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
         | 
| 16077 | 
            -
                  jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
         | 
| 16078 | 
            -
                  jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
         | 
| 16079 | 
            -
                  jsonStatements.push(...jsonDropColumnsStatemets);
         | 
| 16080 | 
            -
                  jsonStatements.push(...jsonAlteredCompositePKs);
         | 
| 16081 | 
            -
                  jsonStatements.push(...jsonAddedUniqueConstraints);
         | 
| 16082 | 
            -
                  jsonStatements.push(...jsonAlteredUniqueConstraints);
         | 
| 16083 | 
            -
                  const sqlStatements = fromJson(jsonStatements, "mysql");
         | 
| 16084 | 
            -
                  const uniqueSqlStatements = [];
         | 
| 16085 | 
            -
                  sqlStatements.forEach((ss) => {
         | 
| 16086 | 
            -
                    if (!uniqueSqlStatements.includes(ss)) {
         | 
| 16087 | 
            -
                      uniqueSqlStatements.push(ss);
         | 
| 16088 | 
            -
                    }
         | 
| 16089 | 
            -
                  });
         | 
| 16090 | 
            -
                  const rTables = renamedTables.map((it) => {
         | 
| 16091 | 
            -
                    return { from: it.from, to: it.to };
         | 
| 16092 | 
            -
                  });
         | 
| 16093 | 
            -
                  const _meta = prepareMigrationMeta([], rTables, rColumns);
         | 
| 16094 | 
            -
                  return {
         | 
| 16095 | 
            -
                    statements: jsonStatements,
         | 
| 16096 | 
            -
                    sqlStatements: uniqueSqlStatements,
         | 
| 16097 | 
            -
                    _meta
         | 
| 16098 | 
            -
                  };
         | 
| 16099 | 
            -
                };
         | 
| 16100 | 
            -
                applySqliteSnapshotsDiff = async (json1, json2, tablesResolver2, columnsResolver2, prevFull, curFull, action) => {
         | 
| 16101 | 
            -
                  const tablesDiff = diffSchemasOrTables(json1.tables, json2.tables);
         | 
| 16102 | 
            -
                  const {
         | 
| 16103 | 
            -
                    created: createdTables,
         | 
| 16104 | 
            -
                    deleted: deletedTables,
         | 
| 16105 | 
            -
                    renamed: renamedTables
         | 
| 16106 | 
            -
                  } = await tablesResolver2({
         | 
| 16107 | 
            -
                    created: tablesDiff.added,
         | 
| 16108 | 
            -
                    deleted: tablesDiff.deleted
         | 
| 16109 | 
            -
                  });
         | 
| 16110 | 
            -
                  const tablesPatchedSnap1 = copy(json1);
         | 
| 16111 | 
            -
                  tablesPatchedSnap1.tables = mapEntries(tablesPatchedSnap1.tables, (_2, it) => {
         | 
| 16112 | 
            -
                    const { name: name2 } = nameChangeFor(it, renamedTables);
         | 
| 16113 | 
            -
                    it.name = name2;
         | 
| 16114 | 
            -
                    return [name2, it];
         | 
| 16115 | 
            -
                  });
         | 
| 16116 | 
            -
                  const res = diffColumns(tablesPatchedSnap1.tables, json2.tables);
         | 
| 16117 | 
            -
                  const columnRenames = [];
         | 
| 16118 | 
            -
                  const columnCreates = [];
         | 
| 16119 | 
            -
                  const columnDeletes = [];
         | 
| 16120 | 
            -
                  for (let entry of Object.values(res)) {
         | 
| 16121 | 
            -
                    const { renamed, created, deleted } = await columnsResolver2({
         | 
| 16122 | 
            -
                      tableName: entry.name,
         | 
| 16123 | 
            -
                      schema: entry.schema,
         | 
| 16124 | 
            -
                      deleted: entry.columns.deleted,
         | 
| 16125 | 
            -
                      created: entry.columns.added
         | 
| 16126 | 
            -
                    });
         | 
| 16127 | 
            -
                    if (created.length > 0) {
         | 
| 16128 | 
            -
                      columnCreates.push({
         | 
| 16129 | 
            -
                        table: entry.name,
         | 
| 16130 | 
            -
                        columns: created
         | 
| 16131 | 
            -
                      });
         | 
| 16132 | 
            -
                    }
         | 
| 16133 | 
            -
                    if (deleted.length > 0) {
         | 
| 16134 | 
            -
                      columnDeletes.push({
         | 
| 16135 | 
            -
                        table: entry.name,
         | 
| 16136 | 
            -
                        columns: deleted
         | 
| 16137 | 
            -
                      });
         | 
| 16138 | 
            -
                    }
         | 
| 16139 | 
            -
                    if (renamed.length > 0) {
         | 
| 16140 | 
            -
                      columnRenames.push({
         | 
| 16141 | 
            -
                        table: entry.name,
         | 
| 16142 | 
            -
                        renames: renamed
         | 
| 16143 | 
            -
                      });
         | 
| 16144 | 
            -
                    }
         | 
| 16145 | 
            -
                  }
         | 
| 16146 | 
            -
                  const columnRenamesDict = columnRenames.reduce(
         | 
| 16147 | 
            -
                    (acc, it) => {
         | 
| 16148 | 
            -
                      acc[it.table] = it.renames;
         | 
| 16149 | 
            -
                      return acc;
         | 
| 16150 | 
            -
                    },
         | 
| 16151 | 
            -
                    {}
         | 
| 16152 | 
            -
                  );
         | 
| 16153 | 
            -
                  const columnsPatchedSnap1 = copy(tablesPatchedSnap1);
         | 
| 16154 | 
            -
                  columnsPatchedSnap1.tables = mapEntries(
         | 
| 16155 | 
            -
                    columnsPatchedSnap1.tables,
         | 
| 16156 | 
            -
                    (tableKey2, tableValue) => {
         | 
| 16157 | 
            -
                      const patchedColumns = mapKeys(
         | 
| 16158 | 
            -
                        tableValue.columns,
         | 
| 16159 | 
            -
                        (columnKey, column4) => {
         | 
| 16160 | 
            -
                          const rens = columnRenamesDict[tableValue.name] || [];
         | 
| 16161 | 
            -
                          const newName = columnChangeFor(columnKey, rens);
         | 
| 16162 | 
            -
                          column4.name = newName;
         | 
| 16163 | 
            -
                          return newName;
         | 
| 16164 | 
            -
                        }
         | 
| 16165 | 
            -
                      );
         | 
| 16166 | 
            -
                      tableValue.columns = patchedColumns;
         | 
| 16167 | 
            -
                      return [tableKey2, tableValue];
         | 
| 16168 | 
            -
                    }
         | 
| 16169 | 
            -
                  );
         | 
| 16170 | 
            -
                  const diffResult = applyJsonDiff(columnsPatchedSnap1, json2);
         | 
| 16171 | 
            -
                  const typedResult = diffResultSchemeSQLite.parse(diffResult);
         | 
| 16172 | 
            -
                  const tablesMap = {};
         | 
| 16173 | 
            -
                  typedResult.alteredTablesWithColumns.forEach((obj) => {
         | 
| 16174 | 
            -
                    tablesMap[obj.name] = obj;
         | 
| 16175 | 
            -
                  });
         | 
| 16176 | 
            -
                  const jsonCreateTables = createdTables.map((it) => {
         | 
| 16177 | 
            -
                    return prepareSQLiteCreateTable(it, action);
         | 
| 16178 | 
            -
                  });
         | 
| 16179 | 
            -
                  const jsonCreateIndexesForCreatedTables = createdTables.map((it) => {
         | 
| 16180 | 
            -
                    return prepareCreateIndexesJson(
         | 
| 16181 | 
            -
                      it.name,
         | 
| 16182 | 
            -
                      it.schema,
         | 
| 16183 | 
            -
                      it.indexes,
         | 
| 16184 | 
            -
                      curFull.internal
         | 
| 16185 | 
            -
                    );
         | 
| 16186 | 
            -
                  }).flat();
         | 
| 16187 | 
            -
                  const jsonDropTables = deletedTables.map((it) => {
         | 
| 16188 | 
            -
                    return prepareDropTableJson(it);
         | 
| 16189 | 
            -
                  });
         | 
| 16190 | 
            -
                  const jsonRenameTables = renamedTables.map((it) => {
         | 
| 16191 | 
            -
                    return prepareRenameTableJson(it.from, it.to);
         | 
| 16192 | 
            -
                  });
         | 
| 16193 | 
            -
                  const jsonRenameColumnsStatements = columnRenames.map((it) => prepareRenameColumns(it.table, "", it.renames)).flat();
         | 
| 16194 | 
            -
                  const jsonDropColumnsStatemets = columnDeletes.map((it) => _prepareDropColumns(it.table, "", it.columns)).flat();
         | 
| 16195 | 
            -
                  const jsonAddColumnsStatemets = columnCreates.map((it) => {
         | 
| 16196 | 
            -
                    return _prepareSqliteAddColumns(
         | 
| 16197 | 
            -
                      it.table,
         | 
| 16198 | 
            -
                      it.columns,
         | 
| 16199 | 
            -
                      tablesMap[it.table] && tablesMap[it.table].addedForeignKeys ? Object.values(tablesMap[it.table].addedForeignKeys) : []
         | 
| 16200 | 
            -
                    );
         | 
| 16201 | 
            -
                  }).flat();
         | 
| 16202 | 
            -
                  const allAltered = typedResult.alteredTablesWithColumns;
         | 
| 16203 | 
            -
                  const jsonAddedCompositePKs = [];
         | 
| 16204 | 
            -
                  const jsonDeletedCompositePKs = [];
         | 
| 16205 | 
            -
                  const jsonAlteredCompositePKs = [];
         | 
| 16206 | 
            -
                  const jsonAddedUniqueConstraints = [];
         | 
| 16207 | 
            -
                  const jsonDeletedUniqueConstraints = [];
         | 
| 16208 | 
            -
                  const jsonAlteredUniqueConstraints = [];
         | 
| 16209 | 
            -
                  allAltered.forEach((it) => {
         | 
| 15358 | 
            +
                  const jsonRenameColumnsStatements = columnRenames.map((it) => prepareRenameColumns(it.table, "", it.renames)).flat();
         | 
| 15359 | 
            +
                  const jsonAddColumnsStatemets = columnCreates.map((it) => _prepareAddColumns(it.table, "", it.columns)).flat();
         | 
| 15360 | 
            +
                  const jsonDropColumnsStatemets = columnDeletes.map((it) => _prepareDropColumns(it.table, "", it.columns)).flat();
         | 
| 15361 | 
            +
                  alteredTables.forEach((it) => {
         | 
| 16210 15362 | 
             
                    let addedColumns = [];
         | 
| 16211 15363 | 
             
                    for (const addedPkName of Object.keys(it.addedCompositePKs)) {
         | 
| 16212 15364 | 
             
                      const addedPkColumns = it.addedCompositePKs[addedPkName];
         | 
| 16213 | 
            -
                      addedColumns =  | 
| 15365 | 
            +
                      addedColumns = MySqlSquasher.unsquashPK(addedPkColumns).columns;
         | 
| 16214 15366 | 
             
                    }
         | 
| 16215 15367 | 
             
                    let deletedColumns = [];
         | 
| 16216 15368 | 
             
                    for (const deletedPkName of Object.keys(it.deletedCompositePKs)) {
         | 
| 16217 15369 | 
             
                      const deletedPkColumns = it.deletedCompositePKs[deletedPkName];
         | 
| 16218 | 
            -
                      deletedColumns =  | 
| 15370 | 
            +
                      deletedColumns = MySqlSquasher.unsquashPK(deletedPkColumns).columns;
         | 
| 16219 15371 | 
             
                    }
         | 
| 16220 15372 | 
             
                    const doPerformDeleteAndCreate = JSON.stringify(addedColumns) !== JSON.stringify(deletedColumns);
         | 
| 16221 15373 | 
             
                    let addedCompositePKs = [];
         | 
| 16222 15374 | 
             
                    let deletedCompositePKs = [];
         | 
| 16223 15375 | 
             
                    let alteredCompositePKs = [];
         | 
| 16224 | 
            -
                     | 
| 16225 | 
            -
                      addedCompositePKs = prepareAddCompositePrimaryKeySqlite(
         | 
| 16226 | 
            -
                        it.name,
         | 
| 16227 | 
            -
                        it.addedCompositePKs
         | 
| 16228 | 
            -
                      );
         | 
| 16229 | 
            -
                      deletedCompositePKs = prepareDeleteCompositePrimaryKeySqlite(
         | 
| 16230 | 
            -
                        it.name,
         | 
| 16231 | 
            -
                        it.deletedCompositePKs
         | 
| 16232 | 
            -
                      );
         | 
| 16233 | 
            -
                    }
         | 
| 16234 | 
            -
                    alteredCompositePKs = prepareAlterCompositePrimaryKeySqlite(
         | 
| 15376 | 
            +
                    addedCompositePKs = prepareAddCompositePrimaryKeyMySql(
         | 
| 16235 15377 | 
             
                      it.name,
         | 
| 16236 | 
            -
                      it. | 
| 15378 | 
            +
                      it.addedCompositePKs,
         | 
| 15379 | 
            +
                      prevFull,
         | 
| 15380 | 
            +
                      curFull
         | 
| 15381 | 
            +
                    );
         | 
| 15382 | 
            +
                    deletedCompositePKs = prepareDeleteCompositePrimaryKeyMySql(
         | 
| 15383 | 
            +
                      it.name,
         | 
| 15384 | 
            +
                      it.deletedCompositePKs,
         | 
| 15385 | 
            +
                      prevFull
         | 
| 15386 | 
            +
                    );
         | 
| 15387 | 
            +
                    alteredCompositePKs = prepareAlterCompositePrimaryKeyMySql(
         | 
| 15388 | 
            +
                      it.name,
         | 
| 15389 | 
            +
                      it.alteredCompositePKs,
         | 
| 15390 | 
            +
                      prevFull,
         | 
| 15391 | 
            +
                      curFull
         | 
| 16237 15392 | 
             
                    );
         | 
| 16238 15393 | 
             
                    let addedUniqueConstraints = [];
         | 
| 16239 15394 | 
             
                    let deletedUniqueConstraints = [];
         | 
| @@ -16277,10 +15432,17 @@ var init_snapshotsDiffer = __esm({ | |
| 16277 15432 | 
             
                      to: { schema: schema4, table: tableName, column: it.newColumnName }
         | 
| 16278 15433 | 
             
                    };
         | 
| 16279 15434 | 
             
                  });
         | 
| 16280 | 
            -
                  const jsonTableAlternations =  | 
| 16281 | 
            -
                    return  | 
| 15435 | 
            +
                  const jsonTableAlternations = alteredTables.map((it) => {
         | 
| 15436 | 
            +
                    return prepareAlterColumnsMysql(
         | 
| 15437 | 
            +
                      it.name,
         | 
| 15438 | 
            +
                      it.schema,
         | 
| 15439 | 
            +
                      it.altered,
         | 
| 15440 | 
            +
                      json1,
         | 
| 15441 | 
            +
                      json2,
         | 
| 15442 | 
            +
                      action
         | 
| 15443 | 
            +
                    );
         | 
| 16282 15444 | 
             
                  }).flat();
         | 
| 16283 | 
            -
                  const jsonCreateIndexesForAllAlteredTables =  | 
| 15445 | 
            +
                  const jsonCreateIndexesForAllAlteredTables = alteredTables.map((it) => {
         | 
| 16284 15446 | 
             
                    return prepareCreateIndexesJson(
         | 
| 16285 15447 | 
             
                      it.name,
         | 
| 16286 15448 | 
             
                      it.schema,
         | 
| @@ -16288,14 +15450,14 @@ var init_snapshotsDiffer = __esm({ | |
| 16288 15450 | 
             
                      curFull.internal
         | 
| 16289 15451 | 
             
                    );
         | 
| 16290 15452 | 
             
                  }).flat();
         | 
| 16291 | 
            -
                  const jsonDropIndexesForAllAlteredTables =  | 
| 15453 | 
            +
                  const jsonDropIndexesForAllAlteredTables = alteredTables.map((it) => {
         | 
| 16292 15454 | 
             
                    return prepareDropIndexesJson(
         | 
| 16293 15455 | 
             
                      it.name,
         | 
| 16294 15456 | 
             
                      it.schema,
         | 
| 16295 15457 | 
             
                      it.deletedIndexes || {}
         | 
| 16296 15458 | 
             
                    );
         | 
| 16297 15459 | 
             
                  }).flat();
         | 
| 16298 | 
            -
                   | 
| 15460 | 
            +
                  alteredTables.forEach((it) => {
         | 
| 16299 15461 | 
             
                    const droppedIndexes = Object.keys(it.alteredIndexes).reduce(
         | 
| 16300 15462 | 
             
                      (current, item) => {
         | 
| 16301 15463 | 
             
                        current[item] = it.alteredIndexes[item].__old;
         | 
| @@ -16311,18 +15473,16 @@ var init_snapshotsDiffer = __esm({ | |
| 16311 15473 | 
             
                      {}
         | 
| 16312 15474 | 
             
                    );
         | 
| 16313 15475 | 
             
                    jsonCreateIndexesForAllAlteredTables.push(
         | 
| 16314 | 
            -
                      ...prepareCreateIndexesJson(
         | 
| 16315 | 
            -
                        it.name,
         | 
| 16316 | 
            -
                        it.schema,
         | 
| 16317 | 
            -
                        createdIndexes || {},
         | 
| 16318 | 
            -
                        curFull.internal
         | 
| 16319 | 
            -
                      )
         | 
| 15476 | 
            +
                      ...prepareCreateIndexesJson(it.name, it.schema, createdIndexes || {})
         | 
| 16320 15477 | 
             
                    );
         | 
| 16321 15478 | 
             
                    jsonDropIndexesForAllAlteredTables.push(
         | 
| 16322 15479 | 
             
                      ...prepareDropIndexesJson(it.name, it.schema, droppedIndexes || {})
         | 
| 16323 15480 | 
             
                    );
         | 
| 16324 15481 | 
             
                  });
         | 
| 16325 | 
            -
                  const  | 
| 15482 | 
            +
                  const jsonCreateReferencesForCreatedTables = createdTables.map((it) => {
         | 
| 15483 | 
            +
                    return prepareCreateReferencesJson(it.name, it.schema, it.foreignKeys);
         | 
| 15484 | 
            +
                  }).flat();
         | 
| 15485 | 
            +
                  const jsonReferencesForAllAlteredTables = alteredTables.map((it) => {
         | 
| 16326 15486 | 
             
                    const forAdded = prepareCreateReferencesJson(
         | 
| 16327 15487 | 
             
                      it.name,
         | 
| 16328 15488 | 
             
                      it.schema,
         | 
| @@ -16346,25 +15506,35 @@ var init_snapshotsDiffer = __esm({ | |
| 16346 15506 | 
             
                  const jsonDroppedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
         | 
| 16347 15507 | 
             
                    (t) => t.type === "delete_reference"
         | 
| 16348 15508 | 
             
                  );
         | 
| 16349 | 
            -
                  const  | 
| 16350 | 
            -
             | 
| 15509 | 
            +
                  const jsonMySqlCreateTables = createdTables.map((it) => {
         | 
| 15510 | 
            +
                    return prepareMySqlCreateTableJson(
         | 
| 15511 | 
            +
                      it,
         | 
| 15512 | 
            +
                      curFull,
         | 
| 15513 | 
            +
                      curFull.internal
         | 
| 15514 | 
            +
                    );
         | 
| 15515 | 
            +
                  });
         | 
| 15516 | 
            +
                  jsonStatements.push(...jsonMySqlCreateTables);
         | 
| 16351 15517 | 
             
                  jsonStatements.push(...jsonDropTables);
         | 
| 16352 15518 | 
             
                  jsonStatements.push(...jsonRenameTables);
         | 
| 16353 15519 | 
             
                  jsonStatements.push(...jsonRenameColumnsStatements);
         | 
| 15520 | 
            +
                  jsonStatements.push(...jsonDeletedUniqueConstraints);
         | 
| 16354 15521 | 
             
                  jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
         | 
| 16355 15522 | 
             
                  jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
         | 
| 16356 15523 | 
             
                  jsonStatements.push(...jsonDeletedCompositePKs);
         | 
| 16357 15524 | 
             
                  jsonStatements.push(...jsonTableAlternations);
         | 
| 16358 15525 | 
             
                  jsonStatements.push(...jsonAddedCompositePKs);
         | 
| 15526 | 
            +
                  jsonStatements.push(...jsonAddedUniqueConstraints);
         | 
| 15527 | 
            +
                  jsonStatements.push(...jsonDeletedUniqueConstraints);
         | 
| 16359 15528 | 
             
                  jsonStatements.push(...jsonAddColumnsStatemets);
         | 
| 15529 | 
            +
                  jsonStatements.push(...jsonCreateReferencesForCreatedTables);
         | 
| 16360 15530 | 
             
                  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
         | 
| 16361 | 
            -
                  jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
         | 
| 16362 15531 | 
             
                  jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
         | 
| 15532 | 
            +
                  jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
         | 
| 16363 15533 | 
             
                  jsonStatements.push(...jsonDropColumnsStatemets);
         | 
| 16364 15534 | 
             
                  jsonStatements.push(...jsonAlteredCompositePKs);
         | 
| 15535 | 
            +
                  jsonStatements.push(...jsonAddedUniqueConstraints);
         | 
| 16365 15536 | 
             
                  jsonStatements.push(...jsonAlteredUniqueConstraints);
         | 
| 16366 | 
            -
                  const  | 
| 16367 | 
            -
                  const sqlStatements = fromJson(combinedJsonStatements, "sqlite");
         | 
| 15537 | 
            +
                  const sqlStatements = fromJson(jsonStatements, "mysql");
         | 
| 16368 15538 | 
             
                  const uniqueSqlStatements = [];
         | 
| 16369 15539 | 
             
                  sqlStatements.forEach((ss) => {
         | 
| 16370 15540 | 
             
                    if (!uniqueSqlStatements.includes(ss)) {
         | 
| @@ -16376,12 +15546,12 @@ var init_snapshotsDiffer = __esm({ | |
| 16376 15546 | 
             
                  });
         | 
| 16377 15547 | 
             
                  const _meta = prepareMigrationMeta([], rTables, rColumns);
         | 
| 16378 15548 | 
             
                  return {
         | 
| 16379 | 
            -
                    statements:  | 
| 15549 | 
            +
                    statements: jsonStatements,
         | 
| 16380 15550 | 
             
                    sqlStatements: uniqueSqlStatements,
         | 
| 16381 15551 | 
             
                    _meta
         | 
| 16382 15552 | 
             
                  };
         | 
| 16383 15553 | 
             
                };
         | 
| 16384 | 
            -
                 | 
| 15554 | 
            +
                applySqliteSnapshotsDiff = async (json1, json2, tablesResolver2, columnsResolver2, prevFull, curFull, action) => {
         | 
| 16385 15555 | 
             
                  const tablesDiff = diffSchemasOrTables(json1.tables, json2.tables);
         | 
| 16386 15556 | 
             
                  const {
         | 
| 16387 15557 | 
             
                    created: createdTables,
         | 
| @@ -16483,18 +15653,6 @@ var init_snapshotsDiffer = __esm({ | |
| 16483 15653 | 
             
                      tablesMap[it.table] && tablesMap[it.table].addedForeignKeys ? Object.values(tablesMap[it.table].addedForeignKeys) : []
         | 
| 16484 15654 | 
             
                    );
         | 
| 16485 15655 | 
             
                  }).flat();
         | 
| 16486 | 
            -
                  const rColumns = jsonRenameColumnsStatements.map((it) => {
         | 
| 16487 | 
            -
                    const tableName = it.tableName;
         | 
| 16488 | 
            -
                    const schema4 = it.schema;
         | 
| 16489 | 
            -
                    return {
         | 
| 16490 | 
            -
                      from: { schema: schema4, table: tableName, column: it.oldColumnName },
         | 
| 16491 | 
            -
                      to: { schema: schema4, table: tableName, column: it.newColumnName }
         | 
| 16492 | 
            -
                    };
         | 
| 16493 | 
            -
                  });
         | 
| 16494 | 
            -
                  const rTables = renamedTables.map((it) => {
         | 
| 16495 | 
            -
                    return { from: it.from, to: it.to };
         | 
| 16496 | 
            -
                  });
         | 
| 16497 | 
            -
                  const _meta = prepareMigrationMeta([], rTables, rColumns);
         | 
| 16498 15656 | 
             
                  const allAltered = typedResult.alteredTablesWithColumns;
         | 
| 16499 15657 | 
             
                  const jsonAddedCompositePKs = [];
         | 
| 16500 15658 | 
             
                  const jsonDeletedCompositePKs = [];
         | 
| @@ -16565,6 +15723,14 @@ var init_snapshotsDiffer = __esm({ | |
| 16565 15723 | 
             
                    jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
         | 
| 16566 15724 | 
             
                    jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
         | 
| 16567 15725 | 
             
                  });
         | 
| 15726 | 
            +
                  const rColumns = jsonRenameColumnsStatements.map((it) => {
         | 
| 15727 | 
            +
                    const tableName = it.tableName;
         | 
| 15728 | 
            +
                    const schema4 = it.schema;
         | 
| 15729 | 
            +
                    return {
         | 
| 15730 | 
            +
                      from: { schema: schema4, table: tableName, column: it.oldColumnName },
         | 
| 15731 | 
            +
                      to: { schema: schema4, table: tableName, column: it.newColumnName }
         | 
| 15732 | 
            +
                    };
         | 
| 15733 | 
            +
                  });
         | 
| 16568 15734 | 
             
                  const jsonTableAlternations = allAltered.map((it) => {
         | 
| 16569 15735 | 
             
                    return prepareSqliteAlterColumns(it.name, it.schema, it.altered, json2);
         | 
| 16570 15736 | 
             
                  }).flat();
         | 
| @@ -16611,22 +15777,21 @@ var init_snapshotsDiffer = __esm({ | |
| 16611 15777 | 
             
                    );
         | 
| 16612 15778 | 
             
                  });
         | 
| 16613 15779 | 
             
                  const jsonReferencesForAllAlteredTables = allAltered.map((it) => {
         | 
| 16614 | 
            -
                    const forAdded =  | 
| 15780 | 
            +
                    const forAdded = prepareCreateReferencesJson(
         | 
| 16615 15781 | 
             
                      it.name,
         | 
| 16616 15782 | 
             
                      it.schema,
         | 
| 16617 | 
            -
                      it.addedForeignKeys | 
| 16618 | 
            -
                      json2,
         | 
| 16619 | 
            -
                      action
         | 
| 15783 | 
            +
                      it.addedForeignKeys
         | 
| 16620 15784 | 
             
                    );
         | 
| 16621 | 
            -
                    const forAltered =  | 
| 15785 | 
            +
                    const forAltered = prepareDropReferencesJson(
         | 
| 16622 15786 | 
             
                      it.name,
         | 
| 16623 15787 | 
             
                      it.schema,
         | 
| 16624 | 
            -
                      it.deletedForeignKeys | 
| 16625 | 
            -
             | 
| 16626 | 
            -
             | 
| 16627 | 
            -
                       | 
| 15788 | 
            +
                      it.deletedForeignKeys
         | 
| 15789 | 
            +
                    );
         | 
| 15790 | 
            +
                    const alteredFKs = prepareAlterReferencesJson(
         | 
| 15791 | 
            +
                      it.name,
         | 
| 15792 | 
            +
                      it.schema,
         | 
| 15793 | 
            +
                      it.alteredForeignKeys
         | 
| 16628 15794 | 
             
                    );
         | 
| 16629 | 
            -
                    const alteredFKs = prepareAlterReferencesJson(it.name, it.schema, it.alteredForeignKeys);
         | 
| 16630 15795 | 
             
                    return [...forAdded, ...forAltered, ...alteredFKs];
         | 
| 16631 15796 | 
             
                  }).flat();
         | 
| 16632 15797 | 
             
                  const jsonCreatedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
         | 
| @@ -16652,21 +15817,19 @@ var init_snapshotsDiffer = __esm({ | |
| 16652 15817 | 
             
                  jsonStatements.push(...jsonDropColumnsStatemets);
         | 
| 16653 15818 | 
             
                  jsonStatements.push(...jsonAlteredCompositePKs);
         | 
| 16654 15819 | 
             
                  jsonStatements.push(...jsonAlteredUniqueConstraints);
         | 
| 16655 | 
            -
                  const  | 
| 16656 | 
            -
                  const sqlStatements = fromJson(
         | 
| 16657 | 
            -
                    combinedJsonStatements,
         | 
| 16658 | 
            -
                    "turso",
         | 
| 16659 | 
            -
                    action,
         | 
| 16660 | 
            -
                    json2
         | 
| 16661 | 
            -
                  );
         | 
| 15820 | 
            +
                  const sqlStatements = fromJson(jsonStatements, "sqlite");
         | 
| 16662 15821 | 
             
                  const uniqueSqlStatements = [];
         | 
| 16663 15822 | 
             
                  sqlStatements.forEach((ss) => {
         | 
| 16664 15823 | 
             
                    if (!uniqueSqlStatements.includes(ss)) {
         | 
| 16665 15824 | 
             
                      uniqueSqlStatements.push(ss);
         | 
| 16666 15825 | 
             
                    }
         | 
| 16667 15826 | 
             
                  });
         | 
| 15827 | 
            +
                  const rTables = renamedTables.map((it) => {
         | 
| 15828 | 
            +
                    return { from: it.from, to: it.to };
         | 
| 15829 | 
            +
                  });
         | 
| 15830 | 
            +
                  const _meta = prepareMigrationMeta([], rTables, rColumns);
         | 
| 16668 15831 | 
             
                  return {
         | 
| 16669 | 
            -
                    statements:  | 
| 15832 | 
            +
                    statements: jsonStatements,
         | 
| 16670 15833 | 
             
                    sqlStatements: uniqueSqlStatements,
         | 
| 16671 15834 | 
             
                    _meta
         | 
| 16672 15835 | 
             
                  };
         | 
| @@ -16690,7 +15853,7 @@ var init_schemaValidator = __esm({ | |
| 16690 15853 | 
             
                init_mysqlSchema();
         | 
| 16691 15854 | 
             
                init_pgSchema();
         | 
| 16692 15855 | 
             
                init_sqliteSchema();
         | 
| 16693 | 
            -
                dialects = ["postgresql", "mysql", "sqlite" | 
| 15856 | 
            +
                dialects = ["postgresql", "mysql", "sqlite"];
         | 
| 16694 15857 | 
             
                dialect3 = enumType(dialects);
         | 
| 16695 15858 | 
             
                commonSquashedSchema = unionType([
         | 
| 16696 15859 | 
             
                  pgSchemaSquashed,
         | 
| @@ -16710,6 +15873,7 @@ var init_common = __esm({ | |
| 16710 15873 | 
             
                init_schemaValidator();
         | 
| 16711 15874 | 
             
                init_outputs();
         | 
| 16712 15875 | 
             
                sqliteDriversLiterals = [
         | 
| 15876 | 
            +
                  literalType("turso"),
         | 
| 16713 15877 | 
             
                  literalType("d1-http"),
         | 
| 16714 15878 | 
             
                  literalType("expo")
         | 
| 16715 15879 | 
             
                ];
         | 
| @@ -34763,8 +33927,7 @@ var init_cli = __esm({ | |
| 34763 33927 | 
             
                  schemaFilter: unionType([stringType(), stringType().array()]).optional().default(["public"]),
         | 
| 34764 33928 | 
             
                  extensionsFilters: literalType("postgis").array().optional(),
         | 
| 34765 33929 | 
             
                  verbose: booleanType().optional(),
         | 
| 34766 | 
            -
                  strict: booleanType().optional() | 
| 34767 | 
            -
                  driver: driver.optional()
         | 
| 33930 | 
            +
                  strict: booleanType().optional()
         | 
| 34768 33931 | 
             
                }).passthrough();
         | 
| 34769 33932 | 
             
                pullParams = objectType({
         | 
| 34770 33933 | 
             
                  config: stringType().optional(),
         | 
| @@ -34792,21 +33955,6 @@ var init_cli = __esm({ | |
| 34792 33955 | 
             
              }
         | 
| 34793 33956 | 
             
            });
         | 
| 34794 33957 |  | 
| 34795 | 
            -
            // src/cli/validations/libsql.ts
         | 
| 34796 | 
            -
            var libSQLCredentials;
         | 
| 34797 | 
            -
            var init_libsql = __esm({
         | 
| 34798 | 
            -
              "src/cli/validations/libsql.ts"() {
         | 
| 34799 | 
            -
                "use strict";
         | 
| 34800 | 
            -
                init_lib();
         | 
| 34801 | 
            -
                init_views();
         | 
| 34802 | 
            -
                init_common();
         | 
| 34803 | 
            -
                libSQLCredentials = objectType({
         | 
| 34804 | 
            -
                  url: stringType().min(1),
         | 
| 34805 | 
            -
                  authToken: stringType().min(1).optional()
         | 
| 34806 | 
            -
                });
         | 
| 34807 | 
            -
              }
         | 
| 34808 | 
            -
            });
         | 
| 34809 | 
            -
             | 
| 34810 33958 | 
             
            // src/cli/validations/mysql.ts
         | 
| 34811 33959 | 
             
            var mysqlCredentials;
         | 
| 34812 33960 | 
             
            var init_mysql = __esm({
         | 
| @@ -34978,8 +34126,6 @@ var init_utils8 = __esm({ | |
| 34978 34126 | 
             
                init_serializer();
         | 
| 34979 34127 | 
             
                init_cli();
         | 
| 34980 34128 | 
             
                init_common();
         | 
| 34981 | 
            -
                init_libsql();
         | 
| 34982 | 
            -
                init_libsql();
         | 
| 34983 34129 | 
             
                init_mysql();
         | 
| 34984 34130 | 
             
                init_outputs();
         | 
| 34985 34131 | 
             
                init_postgres();
         | 
| @@ -35951,8 +35097,284 @@ var sqlitePushIntrospect = async (db, filters) => { | |
| 35951 35097 | 
             
              return { schema: schema4 };
         | 
| 35952 35098 | 
             
            };
         | 
| 35953 35099 |  | 
| 35100 | 
            +
            // src/cli/commands/sqlitePushUtils.ts
         | 
| 35101 | 
            +
            init_source();
         | 
| 35102 | 
            +
            init_sqliteSchema();
         | 
| 35103 | 
            +
            init_sqlgenerator();
         | 
| 35104 | 
            +
            var _moveDataStatements = (tableName, json, dataLoss = false) => {
         | 
| 35105 | 
            +
              const statements = [];
         | 
| 35106 | 
            +
              statements.push(
         | 
| 35107 | 
            +
                new SqliteRenameTableConvertor().convert({
         | 
| 35108 | 
            +
                  type: "rename_table",
         | 
| 35109 | 
            +
                  tableNameFrom: tableName,
         | 
| 35110 | 
            +
                  tableNameTo: `__old_push_${tableName}`,
         | 
| 35111 | 
            +
                  fromSchema: "",
         | 
| 35112 | 
            +
                  toSchema: ""
         | 
| 35113 | 
            +
                })
         | 
| 35114 | 
            +
              );
         | 
| 35115 | 
            +
              const tableColumns = Object.values(json.tables[tableName].columns);
         | 
| 35116 | 
            +
              const referenceData = Object.values(json.tables[tableName].foreignKeys);
         | 
| 35117 | 
            +
              const compositePKs = Object.values(
         | 
| 35118 | 
            +
                json.tables[tableName].compositePrimaryKeys
         | 
| 35119 | 
            +
              ).map((it) => SQLiteSquasher.unsquashPK(it));
         | 
| 35120 | 
            +
              const fks = referenceData.map((it) => SQLiteSquasher.unsquashPushFK(it));
         | 
| 35121 | 
            +
              statements.push(
         | 
| 35122 | 
            +
                new SQLiteCreateTableConvertor().convert({
         | 
| 35123 | 
            +
                  type: "sqlite_create_table",
         | 
| 35124 | 
            +
                  tableName,
         | 
| 35125 | 
            +
                  columns: tableColumns,
         | 
| 35126 | 
            +
                  referenceData: fks,
         | 
| 35127 | 
            +
                  compositePKs
         | 
| 35128 | 
            +
                })
         | 
| 35129 | 
            +
              );
         | 
| 35130 | 
            +
              if (!dataLoss) {
         | 
| 35131 | 
            +
                statements.push(
         | 
| 35132 | 
            +
                  `INSERT INTO "${tableName}" SELECT * FROM "__old_push_${tableName}";`
         | 
| 35133 | 
            +
                );
         | 
| 35134 | 
            +
              }
         | 
| 35135 | 
            +
              statements.push(
         | 
| 35136 | 
            +
                new SQLiteDropTableConvertor().convert({
         | 
| 35137 | 
            +
                  type: "drop_table",
         | 
| 35138 | 
            +
                  tableName: `__old_push_${tableName}`,
         | 
| 35139 | 
            +
                  schema: ""
         | 
| 35140 | 
            +
                })
         | 
| 35141 | 
            +
              );
         | 
| 35142 | 
            +
              for (const idx of Object.values(json.tables[tableName].indexes)) {
         | 
| 35143 | 
            +
                statements.push(
         | 
| 35144 | 
            +
                  new CreateSqliteIndexConvertor().convert({
         | 
| 35145 | 
            +
                    type: "create_index",
         | 
| 35146 | 
            +
                    tableName,
         | 
| 35147 | 
            +
                    schema: "",
         | 
| 35148 | 
            +
                    data: idx
         | 
| 35149 | 
            +
                  })
         | 
| 35150 | 
            +
                );
         | 
| 35151 | 
            +
              }
         | 
| 35152 | 
            +
              return statements;
         | 
| 35153 | 
            +
            };
         | 
| 35154 | 
            +
            var getOldTableName = (tableName, meta) => {
         | 
| 35155 | 
            +
              for (const key of Object.keys(meta.tables)) {
         | 
| 35156 | 
            +
                const value = meta.tables[key];
         | 
| 35157 | 
            +
                if (`"${tableName}"` === value) {
         | 
| 35158 | 
            +
                  return key.substring(1, key.length - 1);
         | 
| 35159 | 
            +
                }
         | 
| 35160 | 
            +
              }
         | 
| 35161 | 
            +
              return tableName;
         | 
| 35162 | 
            +
            };
         | 
| 35163 | 
            +
            var getNewTableName = (tableName, meta) => {
         | 
| 35164 | 
            +
              if (typeof meta.tables[`"${tableName}"`] !== "undefined") {
         | 
| 35165 | 
            +
                return meta.tables[`"${tableName}"`].substring(
         | 
| 35166 | 
            +
                  1,
         | 
| 35167 | 
            +
                  meta.tables[`"${tableName}"`].length - 1
         | 
| 35168 | 
            +
                );
         | 
| 35169 | 
            +
              }
         | 
| 35170 | 
            +
              return tableName;
         | 
| 35171 | 
            +
            };
         | 
| 35172 | 
            +
            var logSuggestionsAndReturn = async (connection, statements, json1, json2, meta) => {
         | 
| 35173 | 
            +
              let shouldAskForApprove = false;
         | 
| 35174 | 
            +
              const statementsToExecute = [];
         | 
| 35175 | 
            +
              const infoToPrint = [];
         | 
| 35176 | 
            +
              const tablesToRemove = [];
         | 
| 35177 | 
            +
              const columnsToRemove = [];
         | 
| 35178 | 
            +
              const schemasToRemove = [];
         | 
| 35179 | 
            +
              const tablesToTruncate = [];
         | 
| 35180 | 
            +
              const tablesContext = {};
         | 
| 35181 | 
            +
              for (const statement of statements) {
         | 
| 35182 | 
            +
                if (statement.type === "drop_table") {
         | 
| 35183 | 
            +
                  const res = await connection.query(
         | 
| 35184 | 
            +
                    `select count(*) as count from \`${statement.tableName}\``
         | 
| 35185 | 
            +
                  );
         | 
| 35186 | 
            +
                  const count2 = Number(res[0].count);
         | 
| 35187 | 
            +
                  if (count2 > 0) {
         | 
| 35188 | 
            +
                    infoToPrint.push(
         | 
| 35189 | 
            +
                      `\xB7 You're about to delete ${source_default.underline(
         | 
| 35190 | 
            +
                        statement.tableName
         | 
| 35191 | 
            +
                      )} table with ${count2} items`
         | 
| 35192 | 
            +
                    );
         | 
| 35193 | 
            +
                    tablesToRemove.push(statement.tableName);
         | 
| 35194 | 
            +
                    shouldAskForApprove = true;
         | 
| 35195 | 
            +
                  }
         | 
| 35196 | 
            +
                  const stmnt = fromJson([statement], "sqlite")[0];
         | 
| 35197 | 
            +
                  statementsToExecute.push(stmnt);
         | 
| 35198 | 
            +
                } else if (statement.type === "alter_table_drop_column") {
         | 
| 35199 | 
            +
                  const newTableName = getOldTableName(statement.tableName, meta);
         | 
| 35200 | 
            +
                  const columnIsPartOfPk = Object.values(
         | 
| 35201 | 
            +
                    json1.tables[newTableName].compositePrimaryKeys
         | 
| 35202 | 
            +
                  ).find((c) => SQLiteSquasher.unsquashPK(c).includes(statement.columnName));
         | 
| 35203 | 
            +
                  const columnIsPartOfIndex = Object.values(
         | 
| 35204 | 
            +
                    json1.tables[newTableName].indexes
         | 
| 35205 | 
            +
                  ).find((c) => SQLiteSquasher.unsquashIdx(c).columns.includes(statement.columnName));
         | 
| 35206 | 
            +
                  const columnIsPk = json1.tables[newTableName].columns[statement.columnName].primaryKey;
         | 
| 35207 | 
            +
                  const columnIsPartOfFk = Object.values(
         | 
| 35208 | 
            +
                    json1.tables[newTableName].foreignKeys
         | 
| 35209 | 
            +
                  ).find(
         | 
| 35210 | 
            +
                    (t) => SQLiteSquasher.unsquashPushFK(t).columnsFrom.includes(
         | 
| 35211 | 
            +
                      statement.columnName
         | 
| 35212 | 
            +
                    )
         | 
| 35213 | 
            +
                  );
         | 
| 35214 | 
            +
                  const res = await connection.query(
         | 
| 35215 | 
            +
                    `select count(*) as count from \`${newTableName}\``
         | 
| 35216 | 
            +
                  );
         | 
| 35217 | 
            +
                  const count2 = Number(res[0].count);
         | 
| 35218 | 
            +
                  if (count2 > 0) {
         | 
| 35219 | 
            +
                    infoToPrint.push(
         | 
| 35220 | 
            +
                      `\xB7 You're about to delete ${source_default.underline(
         | 
| 35221 | 
            +
                        statement.columnName
         | 
| 35222 | 
            +
                      )} column in ${newTableName} table with ${count2} items`
         | 
| 35223 | 
            +
                    );
         | 
| 35224 | 
            +
                    columnsToRemove.push(`${newTableName}_${statement.columnName}`);
         | 
| 35225 | 
            +
                    shouldAskForApprove = true;
         | 
| 35226 | 
            +
                  }
         | 
| 35227 | 
            +
                  if (columnIsPk || columnIsPartOfPk || columnIsPartOfIndex || columnIsPartOfFk) {
         | 
| 35228 | 
            +
                    tablesContext[newTableName] = [
         | 
| 35229 | 
            +
                      ..._moveDataStatements(statement.tableName, json2, true)
         | 
| 35230 | 
            +
                    ];
         | 
| 35231 | 
            +
                    const tablesReferncingCurrent = [];
         | 
| 35232 | 
            +
                    for (const table4 of Object.values(json1.tables)) {
         | 
| 35233 | 
            +
                      const tablesRefs = Object.values(json1.tables[table4.name].foreignKeys).filter(
         | 
| 35234 | 
            +
                        (t) => SQLiteSquasher.unsquashPushFK(t).tableTo === newTableName
         | 
| 35235 | 
            +
                      ).map((t) => SQLiteSquasher.unsquashPushFK(t).tableFrom);
         | 
| 35236 | 
            +
                      tablesReferncingCurrent.push(...tablesRefs);
         | 
| 35237 | 
            +
                    }
         | 
| 35238 | 
            +
                    const uniqueTableRefs = [...new Set(tablesReferncingCurrent)];
         | 
| 35239 | 
            +
                    for (const table4 of uniqueTableRefs) {
         | 
| 35240 | 
            +
                      if (typeof tablesContext[table4] === "undefined") {
         | 
| 35241 | 
            +
                        tablesContext[table4] = [..._moveDataStatements(table4, json2)];
         | 
| 35242 | 
            +
                      }
         | 
| 35243 | 
            +
                    }
         | 
| 35244 | 
            +
                  } else {
         | 
| 35245 | 
            +
                    if (typeof tablesContext[newTableName] === "undefined") {
         | 
| 35246 | 
            +
                      const stmnt = fromJson([statement], "sqlite")[0];
         | 
| 35247 | 
            +
                      statementsToExecute.push(stmnt);
         | 
| 35248 | 
            +
                    }
         | 
| 35249 | 
            +
                  }
         | 
| 35250 | 
            +
                } else if (statement.type === "sqlite_alter_table_add_column") {
         | 
| 35251 | 
            +
                  const newTableName = getOldTableName(statement.tableName, meta);
         | 
| 35252 | 
            +
                  if (statement.column.notNull && !statement.column.default) {
         | 
| 35253 | 
            +
                    const res = await connection.query(
         | 
| 35254 | 
            +
                      `select count(*) as count from \`${newTableName}\``
         | 
| 35255 | 
            +
                    );
         | 
| 35256 | 
            +
                    const count2 = Number(res[0].count);
         | 
| 35257 | 
            +
                    if (count2 > 0) {
         | 
| 35258 | 
            +
                      infoToPrint.push(
         | 
| 35259 | 
            +
                        `\xB7 You're about to add not-null ${source_default.underline(
         | 
| 35260 | 
            +
                          statement.column.name
         | 
| 35261 | 
            +
                        )} column without default value, which contains ${count2} items`
         | 
| 35262 | 
            +
                      );
         | 
| 35263 | 
            +
                      tablesToTruncate.push(newTableName);
         | 
| 35264 | 
            +
                      statementsToExecute.push(`delete from ${newTableName};`);
         | 
| 35265 | 
            +
                      shouldAskForApprove = true;
         | 
| 35266 | 
            +
                    }
         | 
| 35267 | 
            +
                  }
         | 
| 35268 | 
            +
                  if (statement.column.primaryKey) {
         | 
| 35269 | 
            +
                    tablesContext[newTableName] = [
         | 
| 35270 | 
            +
                      ..._moveDataStatements(statement.tableName, json2, true)
         | 
| 35271 | 
            +
                    ];
         | 
| 35272 | 
            +
                    const tablesReferncingCurrent = [];
         | 
| 35273 | 
            +
                    for (const table4 of Object.values(json1.tables)) {
         | 
| 35274 | 
            +
                      const tablesRefs = Object.values(json1.tables[table4.name].foreignKeys).filter(
         | 
| 35275 | 
            +
                        (t) => SQLiteSquasher.unsquashPushFK(t).tableTo === newTableName
         | 
| 35276 | 
            +
                      ).map((t) => SQLiteSquasher.unsquashPushFK(t).tableFrom);
         | 
| 35277 | 
            +
                      tablesReferncingCurrent.push(...tablesRefs);
         | 
| 35278 | 
            +
                    }
         | 
| 35279 | 
            +
                    const uniqueTableRefs = [...new Set(tablesReferncingCurrent)];
         | 
| 35280 | 
            +
                    for (const table4 of uniqueTableRefs) {
         | 
| 35281 | 
            +
                      if (typeof tablesContext[table4] === "undefined") {
         | 
| 35282 | 
            +
                        tablesContext[table4] = [..._moveDataStatements(table4, json2)];
         | 
| 35283 | 
            +
                      }
         | 
| 35284 | 
            +
                    }
         | 
| 35285 | 
            +
                  } else {
         | 
| 35286 | 
            +
                    if (typeof tablesContext[newTableName] === "undefined") {
         | 
| 35287 | 
            +
                      const stmnt = fromJson([statement], "sqlite")[0];
         | 
| 35288 | 
            +
                      statementsToExecute.push(stmnt);
         | 
| 35289 | 
            +
                    }
         | 
| 35290 | 
            +
                  }
         | 
| 35291 | 
            +
                } 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") {
         | 
| 35292 | 
            +
                  if (!(statement.type === "alter_table_alter_column_set_notnull" && statement.columnPk)) {
         | 
| 35293 | 
            +
                    const newTableName = getOldTableName(statement.tableName, meta);
         | 
| 35294 | 
            +
                    if (statement.type === "alter_table_alter_column_set_notnull" && typeof statement.columnDefault === "undefined") {
         | 
| 35295 | 
            +
                      const res = await connection.query(
         | 
| 35296 | 
            +
                        `select count(*) as count from \`${newTableName}\``
         | 
| 35297 | 
            +
                      );
         | 
| 35298 | 
            +
                      const count2 = Number(res[0].count);
         | 
| 35299 | 
            +
                      if (count2 > 0) {
         | 
| 35300 | 
            +
                        infoToPrint.push(
         | 
| 35301 | 
            +
                          `\xB7 You're about to add not-null constraint to ${source_default.underline(
         | 
| 35302 | 
            +
                            statement.columnName
         | 
| 35303 | 
            +
                          )} column without default value, which contains ${count2} items`
         | 
| 35304 | 
            +
                        );
         | 
| 35305 | 
            +
                        tablesToTruncate.push(newTableName);
         | 
| 35306 | 
            +
                        shouldAskForApprove = true;
         | 
| 35307 | 
            +
                      }
         | 
| 35308 | 
            +
                      tablesContext[newTableName] = _moveDataStatements(
         | 
| 35309 | 
            +
                        statement.tableName,
         | 
| 35310 | 
            +
                        json1,
         | 
| 35311 | 
            +
                        true
         | 
| 35312 | 
            +
                      );
         | 
| 35313 | 
            +
                    } else {
         | 
| 35314 | 
            +
                      if (typeof tablesContext[newTableName] === "undefined") {
         | 
| 35315 | 
            +
                        tablesContext[newTableName] = _moveDataStatements(
         | 
| 35316 | 
            +
                          statement.tableName,
         | 
| 35317 | 
            +
                          json1
         | 
| 35318 | 
            +
                        );
         | 
| 35319 | 
            +
                      }
         | 
| 35320 | 
            +
                    }
         | 
| 35321 | 
            +
                    const tablesReferncingCurrent = [];
         | 
| 35322 | 
            +
                    for (const table4 of Object.values(json1.tables)) {
         | 
| 35323 | 
            +
                      const tablesRefs = Object.values(json1.tables[table4.name].foreignKeys).filter(
         | 
| 35324 | 
            +
                        (t) => SQLiteSquasher.unsquashPushFK(t).tableTo === newTableName
         | 
| 35325 | 
            +
                      ).map((t) => {
         | 
| 35326 | 
            +
                        return getNewTableName(
         | 
| 35327 | 
            +
                          SQLiteSquasher.unsquashPushFK(t).tableFrom,
         | 
| 35328 | 
            +
                          meta
         | 
| 35329 | 
            +
                        );
         | 
| 35330 | 
            +
                      });
         | 
| 35331 | 
            +
                      tablesReferncingCurrent.push(...tablesRefs);
         | 
| 35332 | 
            +
                    }
         | 
| 35333 | 
            +
                    const uniqueTableRefs = [...new Set(tablesReferncingCurrent)];
         | 
| 35334 | 
            +
                    for (const table4 of uniqueTableRefs) {
         | 
| 35335 | 
            +
                      if (typeof tablesContext[table4] === "undefined") {
         | 
| 35336 | 
            +
                        tablesContext[table4] = [..._moveDataStatements(table4, json1)];
         | 
| 35337 | 
            +
                      }
         | 
| 35338 | 
            +
                    }
         | 
| 35339 | 
            +
                  }
         | 
| 35340 | 
            +
                } else if (statement.type === "create_reference" || statement.type === "delete_reference" || statement.type === "alter_reference") {
         | 
| 35341 | 
            +
                  const fk4 = SQLiteSquasher.unsquashPushFK(statement.data);
         | 
| 35342 | 
            +
                  if (typeof tablesContext[statement.tableName] === "undefined") {
         | 
| 35343 | 
            +
                    tablesContext[statement.tableName] = _moveDataStatements(
         | 
| 35344 | 
            +
                      statement.tableName,
         | 
| 35345 | 
            +
                      json2
         | 
| 35346 | 
            +
                    );
         | 
| 35347 | 
            +
                  }
         | 
| 35348 | 
            +
                } 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") {
         | 
| 35349 | 
            +
                  const newTableName = getOldTableName(statement.tableName, meta);
         | 
| 35350 | 
            +
                  if (typeof tablesContext[newTableName] === "undefined") {
         | 
| 35351 | 
            +
                    tablesContext[newTableName] = _moveDataStatements(
         | 
| 35352 | 
            +
                      statement.tableName,
         | 
| 35353 | 
            +
                      json2
         | 
| 35354 | 
            +
                    );
         | 
| 35355 | 
            +
                  }
         | 
| 35356 | 
            +
                } else {
         | 
| 35357 | 
            +
                  const stmnt = fromJson([statement], "sqlite");
         | 
| 35358 | 
            +
                  if (typeof stmnt !== "undefined") {
         | 
| 35359 | 
            +
                    statementsToExecute.push(...stmnt);
         | 
| 35360 | 
            +
                  }
         | 
| 35361 | 
            +
                }
         | 
| 35362 | 
            +
              }
         | 
| 35363 | 
            +
              for (const context of Object.values(tablesContext)) {
         | 
| 35364 | 
            +
                statementsToExecute.push(...context);
         | 
| 35365 | 
            +
              }
         | 
| 35366 | 
            +
              return {
         | 
| 35367 | 
            +
                statementsToExecute,
         | 
| 35368 | 
            +
                shouldAskForApprove,
         | 
| 35369 | 
            +
                infoToPrint,
         | 
| 35370 | 
            +
                columnsToRemove: [...new Set(columnsToRemove)],
         | 
| 35371 | 
            +
                schemasToRemove: [...new Set(schemasToRemove)],
         | 
| 35372 | 
            +
                tablesToTruncate: [...new Set(tablesToTruncate)],
         | 
| 35373 | 
            +
                tablesToRemove: [...new Set(tablesToRemove)]
         | 
| 35374 | 
            +
              };
         | 
| 35375 | 
            +
            };
         | 
| 35376 | 
            +
             | 
| 35954 35377 | 
             
            // src/api.ts
         | 
| 35955 | 
            -
            init_sqlitePushUtils();
         | 
| 35956 35378 | 
             
            init_global();
         | 
| 35957 35379 | 
             
            init_migrationPreparator();
         | 
| 35958 35380 | 
             
            init_mysqlSchema();
         |