drizzle-kit 0.24.0-6386ea9 → 0.24.0-bb966f7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api.js +1219 -656
 - package/api.mjs +1219 -656
 - package/bin.cjs +1790 -1200
 - package/package.json +4 -4
 - package/utils.js +9 -0
 - package/utils.mjs +8 -0
 
    
        package/bin.cjs
    CHANGED
    
    | 
         @@ -6564,6 +6564,13 @@ var init_sqliteSchema = __esm({ 
     | 
|
| 
       6564 
6564 
     | 
    
         
             
            function isPgArrayType(sqlType) {
         
     | 
| 
       6565 
6565 
     | 
    
         
             
              return sqlType.match(/.*\[\d*\].*|.*\[\].*/g) !== null;
         
     | 
| 
       6566 
6566 
     | 
    
         
             
            }
         
     | 
| 
      
 6567 
     | 
    
         
            +
            function findAddedAndRemoved(columnNames1, columnNames2) {
         
     | 
| 
      
 6568 
     | 
    
         
            +
              const set1 = new Set(columnNames1);
         
     | 
| 
      
 6569 
     | 
    
         
            +
              const set2 = new Set(columnNames2);
         
     | 
| 
      
 6570 
     | 
    
         
            +
              const addedColumns = columnNames2.filter((it) => !set1.has(it));
         
     | 
| 
      
 6571 
     | 
    
         
            +
              const removedColumns = columnNames1.filter((it) => !set2.has(it));
         
     | 
| 
      
 6572 
     | 
    
         
            +
              return { addedColumns, removedColumns };
         
     | 
| 
      
 6573 
     | 
    
         
            +
            }
         
     | 
| 
       6567 
6574 
     | 
    
         
             
            var import_fs, import_path, import_url, copy, objectValues, assertV1OutFolder, dryJournal, prepareOutFolder, validatorForDialect, validateWithReport, prepareMigrationFolder, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey, normaliseSQLiteUrl;
         
     | 
| 
       6568 
6575 
     | 
    
         
             
            var init_utils = __esm({
         
     | 
| 
       6569 
6576 
     | 
    
         
             
              "src/utils.ts"() {
         
     | 
| 
         @@ -11361,7 +11368,8 @@ var init_cli = __esm({ 
     | 
|
| 
       11361 
11368 
     | 
    
         
             
                  schemaFilter: unionType([stringType(), stringType().array()]).optional().default(["public"]),
         
     | 
| 
       11362 
11369 
     | 
    
         
             
                  extensionsFilters: literalType("postgis").array().optional(),
         
     | 
| 
       11363 
11370 
     | 
    
         
             
                  verbose: booleanType().optional(),
         
     | 
| 
       11364 
     | 
    
         
            -
                  strict: booleanType().optional()
         
     | 
| 
      
 11371 
     | 
    
         
            +
                  strict: booleanType().optional(),
         
     | 
| 
      
 11372 
     | 
    
         
            +
                  driver: driver.optional()
         
     | 
| 
       11365 
11373 
     | 
    
         
             
                }).passthrough();
         
     | 
| 
       11366 
11374 
     | 
    
         
             
                pullParams = objectType({
         
     | 
| 
       11367 
11375 
     | 
    
         
             
                  config: stringType().optional(),
         
     | 
| 
         @@ -17365,7 +17373,8 @@ var init_utils4 = __esm({ 
     | 
|
| 
       17365 
17373 
     | 
    
         
             
                    breakpoints: breakpoints || true,
         
     | 
| 
       17366 
17374 
     | 
    
         
             
                    schema: schema5,
         
     | 
| 
       17367 
17375 
     | 
    
         
             
                    out: out || "drizzle",
         
     | 
| 
       17368 
     | 
    
         
            -
                    bundle: driver2 === "expo"
         
     | 
| 
      
 17376 
     | 
    
         
            +
                    bundle: driver2 === "expo",
         
     | 
| 
      
 17377 
     | 
    
         
            +
                    driver: driver2
         
     | 
| 
       17369 
17378 
     | 
    
         
             
                  };
         
     | 
| 
       17370 
17379 
     | 
    
         
             
                };
         
     | 
| 
       17371 
17380 
     | 
    
         
             
                flattenDatabaseCredentials = (config) => {
         
     | 
| 
         @@ -17393,6 +17402,7 @@ var init_utils4 = __esm({ 
     | 
|
| 
       17393 
17402 
     | 
    
         
             
                  const raw2 = flattenDatabaseCredentials(
         
     | 
| 
       17394 
17403 
     | 
    
         
             
                    from === "config" ? await drizzleConfigFromFile(options.config) : options
         
     | 
| 
       17395 
17404 
     | 
    
         
             
                  );
         
     | 
| 
      
 17405 
     | 
    
         
            +
                  raw2.driver ||= options.driver;
         
     | 
| 
       17396 
17406 
     | 
    
         
             
                  raw2.verbose ||= options.verbose;
         
     | 
| 
       17397 
17407 
     | 
    
         
             
                  raw2.strict ||= options.strict;
         
     | 
| 
       17398 
17408 
     | 
    
         
             
                  const parsed = pushParams.safeParse(raw2);
         
     | 
| 
         @@ -17467,7 +17477,8 @@ var init_utils4 = __esm({ 
     | 
|
| 
       17467 
17477 
     | 
    
         
             
                      force: options.force ?? false,
         
     | 
| 
       17468 
17478 
     | 
    
         
             
                      credentials: parsed2.data,
         
     | 
| 
       17469 
17479 
     | 
    
         
             
                      tablesFilter,
         
     | 
| 
       17470 
     | 
    
         
            -
                      schemasFilter
         
     | 
| 
      
 17480 
     | 
    
         
            +
                      schemasFilter,
         
     | 
| 
      
 17481 
     | 
    
         
            +
                      driver: config.driver
         
     | 
| 
       17471 
17482 
     | 
    
         
             
                    };
         
     | 
| 
       17472 
17483 
     | 
    
         
             
                  }
         
     | 
| 
       17473 
17484 
     | 
    
         
             
                  assertUnreachable(config.dialect);
         
     | 
| 
         @@ -22852,7 +22863,20 @@ var init_jsonDiffer = __esm({ 
     | 
|
| 
       22852 
22863 
     | 
    
         
             
            });
         
     | 
| 
       22853 
22864 
     | 
    
         | 
| 
       22854 
22865 
     | 
    
         
             
            // src/sqlgenerator.ts
         
     | 
| 
       22855 
     | 
    
         
            -
             
     | 
| 
      
 22866 
     | 
    
         
            +
            function fromJson(statements, dialect7, action, driver2, json2) {
         
     | 
| 
      
 22867 
     | 
    
         
            +
              const result = statements.flatMap((statement) => {
         
     | 
| 
      
 22868 
     | 
    
         
            +
                const filtered = convertors.filter((it) => {
         
     | 
| 
      
 22869 
     | 
    
         
            +
                  return it.can(statement, dialect7, driver2);
         
     | 
| 
      
 22870 
     | 
    
         
            +
                });
         
     | 
| 
      
 22871 
     | 
    
         
            +
                const convertor = filtered.length === 1 ? filtered[0] : void 0;
         
     | 
| 
      
 22872 
     | 
    
         
            +
                if (!convertor) {
         
     | 
| 
      
 22873 
     | 
    
         
            +
                  return "";
         
     | 
| 
      
 22874 
     | 
    
         
            +
                }
         
     | 
| 
      
 22875 
     | 
    
         
            +
                return convertor.convert(statement, json2, action);
         
     | 
| 
      
 22876 
     | 
    
         
            +
              }).filter((it) => it !== "");
         
     | 
| 
      
 22877 
     | 
    
         
            +
              return result;
         
     | 
| 
      
 22878 
     | 
    
         
            +
            }
         
     | 
| 
      
 22879 
     | 
    
         
            +
            var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, CreatePgSequenceConvertor, DropPgSequenceConvertor, RenamePgSequenceConvertor, MovePgSequenceConvertor, AlterPgSequenceConvertor, CreateTypeEnumConvertor, AlterTypeAddValueConvertor, PgDropTableConvertor, MySQLDropTableConvertor, SQLiteDropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, PgAlterTableAlterColumnDropGeneratedConvertor, PgAlterTableAlterColumnSetExpressionConvertor, PgAlterTableAlterColumnAlterrGeneratedConvertor, SqliteAlterTableAlterColumnDropGeneratedConvertor, SqliteAlterTableAlterColumnSetExpressionConvertor, SqliteAlterTableAlterColumnAlterGeneratedConvertor, MySqlAlterTableAlterColumnAlterrGeneratedConvertor, MySqlAlterTableAddPk, MySqlAlterTableDropPk, LibSQLModifyColumn, MySqlModifyColumn, PgAlterTableCreateCompositePrimaryKeyConvertor, PgAlterTableDeleteCompositePrimaryKeyConvertor, PgAlterTableAlterCompositePrimaryKeyConvertor, MySqlAlterTableCreateCompositePrimaryKeyConvertor, MySqlAlterTableDeleteCompositePrimaryKeyConvertor, MySqlAlterTableAlterCompositePrimaryKeyConvertor, PgAlterTableAlterColumnSetPrimaryKeyConvertor, PgAlterTableAlterColumnDropPrimaryKeyConvertor, PgAlterTableAlterColumnSetNotNullConvertor, PgAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, LibSQLCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, PgCreateSchemaConvertor, PgRenameSchemaConvertor, PgDropSchemaConvertor, PgAlterTableSetSchemaConvertor, PgAlterTableSetNewSchemaConvertor, PgAlterTableRemoveFromSchemaConvertor, SqliteDropIndexConvertor, MySqlDropIndexConvertor, SQLiteRecreateTableConvertor, LibSQLRecreateTableConvertor, convertors;
         
     | 
| 
       22856 
22880 
     | 
    
         
             
            var init_sqlgenerator = __esm({
         
     | 
| 
       22857 
22881 
     | 
    
         
             
              "src/sqlgenerator.ts"() {
         
     | 
| 
       22858 
22882 
     | 
    
         
             
                "use strict";
         
     | 
| 
         @@ -23177,32 +23201,6 @@ var init_sqlgenerator = __esm({ 
     | 
|
| 
       23177 
23201 
     | 
    
         
             
                    return `ALTER TABLE \`${statement.tableName}\` DROP INDEX \`${unsquashed.name}\`;`;
         
     | 
| 
       23178 
23202 
     | 
    
         
             
                  }
         
     | 
| 
       23179 
23203 
     | 
    
         
             
                };
         
     | 
| 
       23180 
     | 
    
         
            -
                SQLiteAlterTableAddUniqueConstraintConvertor = class extends Convertor {
         
     | 
| 
       23181 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       23182 
     | 
    
         
            -
                    return statement.type === "create_unique_constraint" && dialect7 === "sqlite";
         
     | 
| 
       23183 
     | 
    
         
            -
                  }
         
     | 
| 
       23184 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       23185 
     | 
    
         
            -
                    return `/*
         
     | 
| 
       23186 
     | 
    
         
            -
             SQLite does not support "Adding unique constraint to an existing table" out of the box, we do not generate automatic migration for that, so it has to be done manually
         
     | 
| 
       23187 
     | 
    
         
            -
             Please refer to: https://www.techonthenet.com/sqlite/unique.php
         
     | 
| 
       23188 
     | 
    
         
            -
             
     | 
| 
       23189 
     | 
    
         
            -
             Due to that we don't generate migration automatically and it has to be done manually
         
     | 
| 
       23190 
     | 
    
         
            -
            */`;
         
     | 
| 
       23191 
     | 
    
         
            -
                  }
         
     | 
| 
       23192 
     | 
    
         
            -
                };
         
     | 
| 
       23193 
     | 
    
         
            -
                SQLiteAlterTableDropUniqueConstraintConvertor = class extends Convertor {
         
     | 
| 
       23194 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       23195 
     | 
    
         
            -
                    return statement.type === "delete_unique_constraint" && dialect7 === "sqlite";
         
     | 
| 
       23196 
     | 
    
         
            -
                  }
         
     | 
| 
       23197 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       23198 
     | 
    
         
            -
                    return `/*
         
     | 
| 
       23199 
     | 
    
         
            -
             SQLite does not support "Dropping unique constraint from an existing table" out of the box, we do not generate automatic migration for that, so it has to be done manually
         
     | 
| 
       23200 
     | 
    
         
            -
             Please refer to: https://www.techonthenet.com/sqlite/unique.php
         
     | 
| 
       23201 
     | 
    
         
            -
             
     | 
| 
       23202 
     | 
    
         
            -
             Due to that we don't generate migration automatically and it has to be done manually
         
     | 
| 
       23203 
     | 
    
         
            -
            */`;
         
     | 
| 
       23204 
     | 
    
         
            -
                  }
         
     | 
| 
       23205 
     | 
    
         
            -
                };
         
     | 
| 
       23206 
23204 
     | 
    
         
             
                CreatePgSequenceConvertor = class extends Convertor {
         
     | 
| 
       23207 
23205 
     | 
    
         
             
                  can(statement, dialect7) {
         
     | 
| 
       23208 
23206 
     | 
    
         
             
                    return statement.type === "create_sequence" && dialect7 === "postgresql";
         
     | 
| 
         @@ -23371,7 +23369,7 @@ var init_sqlgenerator = __esm({ 
     | 
|
| 
       23371 
23369 
     | 
    
         
             
                  }
         
     | 
| 
       23372 
23370 
     | 
    
         
             
                  convert(statement) {
         
     | 
| 
       23373 
23371 
     | 
    
         
             
                    const { tableName, oldColumnName, newColumnName } = statement;
         
     | 
| 
       23374 
     | 
    
         
            -
                    return `ALTER TABLE \`${tableName}\` RENAME COLUMN  
     | 
| 
      
 23372 
     | 
    
         
            +
                    return `ALTER TABLE \`${tableName}\` RENAME COLUMN "${oldColumnName}" TO "${newColumnName}";`;
         
     | 
| 
       23375 
23373 
     | 
    
         
             
                  }
         
     | 
| 
       23376 
23374 
     | 
    
         
             
                };
         
     | 
| 
       23377 
23375 
     | 
    
         
             
                PgAlterTableDropColumnConvertor = class extends Convertor {
         
     | 
| 
         @@ -23472,21 +23470,6 @@ var init_sqlgenerator = __esm({ 
     | 
|
| 
       23472 
23470 
     | 
    
         
             
                    return `ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${columnName}" SET DATA TYPE ${newDataType};`;
         
     | 
| 
       23473 
23471 
     | 
    
         
             
                  }
         
     | 
| 
       23474 
23472 
     | 
    
         
             
                };
         
     | 
| 
       23475 
     | 
    
         
            -
                SQLiteAlterTableAlterColumnSetTypeConvertor = class extends Convertor {
         
     | 
| 
       23476 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       23477 
     | 
    
         
            -
                    return statement.type === "alter_table_alter_column_set_type" && dialect7 === "sqlite";
         
     | 
| 
       23478 
     | 
    
         
            -
                  }
         
     | 
| 
       23479 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       23480 
     | 
    
         
            -
                    return `/*
         
     | 
| 
       23481 
     | 
    
         
            -
             SQLite does not support "Changing existing column type" out of the box, we do not generate automatic migration for that, so it has to be done manually
         
     | 
| 
       23482 
     | 
    
         
            -
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         
     | 
| 
       23483 
     | 
    
         
            -
                              https://www.sqlite.org/lang_altertable.html
         
     | 
| 
       23484 
     | 
    
         
            -
                              https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
         
     | 
| 
       23485 
     | 
    
         
            -
             
     | 
| 
       23486 
     | 
    
         
            -
             Due to that we don't generate migration automatically and it has to be done manually
         
     | 
| 
       23487 
     | 
    
         
            -
            */`;
         
     | 
| 
       23488 
     | 
    
         
            -
                  }
         
     | 
| 
       23489 
     | 
    
         
            -
                };
         
     | 
| 
       23490 
23473 
     | 
    
         
             
                PgAlterTableAlterColumnSetDefaultConvertor = class extends Convertor {
         
     | 
| 
       23491 
23474 
     | 
    
         
             
                  can(statement, dialect7) {
         
     | 
| 
       23492 
23475 
     | 
    
         
             
                    return statement.type === "alter_table_alter_column_set_default" && dialect7 === "postgresql";
         
     | 
| 
         @@ -23497,21 +23480,6 @@ var init_sqlgenerator = __esm({ 
     | 
|
| 
       23497 
23480 
     | 
    
         
             
                    return `ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${columnName}" SET DEFAULT ${statement.newDefaultValue};`;
         
     | 
| 
       23498 
23481 
     | 
    
         
             
                  }
         
     | 
| 
       23499 
23482 
     | 
    
         
             
                };
         
     | 
| 
       23500 
     | 
    
         
            -
                SqliteAlterTableAlterColumnSetDefaultConvertor = class extends Convertor {
         
     | 
| 
       23501 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       23502 
     | 
    
         
            -
                    return statement.type === "alter_table_alter_column_set_default" && dialect7 === "sqlite";
         
     | 
| 
       23503 
     | 
    
         
            -
                  }
         
     | 
| 
       23504 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       23505 
     | 
    
         
            -
                    return `/*
         
     | 
| 
       23506 
     | 
    
         
            -
             SQLite does not support "Set default to column" out of the box, we do not generate automatic migration for that, so it has to be done manually
         
     | 
| 
       23507 
     | 
    
         
            -
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         
     | 
| 
       23508 
     | 
    
         
            -
                              https://www.sqlite.org/lang_altertable.html
         
     | 
| 
       23509 
     | 
    
         
            -
                              https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
         
     | 
| 
       23510 
     | 
    
         
            -
             
     | 
| 
       23511 
     | 
    
         
            -
             Due to that we don't generate migration automatically and it has to be done manually
         
     | 
| 
       23512 
     | 
    
         
            -
            */`;
         
     | 
| 
       23513 
     | 
    
         
            -
                  }
         
     | 
| 
       23514 
     | 
    
         
            -
                };
         
     | 
| 
       23515 
23483 
     | 
    
         
             
                PgAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
         
     | 
| 
       23516 
23484 
     | 
    
         
             
                  can(statement, dialect7) {
         
     | 
| 
       23517 
23485 
     | 
    
         
             
                    return statement.type === "alter_table_alter_column_drop_default" && dialect7 === "postgresql";
         
     | 
| 
         @@ -23785,6 +23753,67 @@ var init_sqlgenerator = __esm({ 
     | 
|
| 
       23785 
23753 
     | 
    
         
             
                    return `ALTER TABLE \`${statement.tableName}\` DROP PRIMARY KEY`;
         
     | 
| 
       23786 
23754 
     | 
    
         
             
                  }
         
     | 
| 
       23787 
23755 
     | 
    
         
             
                };
         
     | 
| 
      
 23756 
     | 
    
         
            +
                LibSQLModifyColumn = class extends Convertor {
         
     | 
| 
      
 23757 
     | 
    
         
            +
                  can(statement, dialect7, driver2) {
         
     | 
| 
      
 23758 
     | 
    
         
            +
                    return (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default") && dialect7 === "sqlite" && driver2 === "turso";
         
     | 
| 
      
 23759 
     | 
    
         
            +
                  }
         
     | 
| 
      
 23760 
     | 
    
         
            +
                  convert(statement, json2, action) {
         
     | 
| 
      
 23761 
     | 
    
         
            +
                    const { tableName, columnName } = statement;
         
     | 
| 
      
 23762 
     | 
    
         
            +
                    let columnType = ``;
         
     | 
| 
      
 23763 
     | 
    
         
            +
                    let columnDefault = "";
         
     | 
| 
      
 23764 
     | 
    
         
            +
                    let columnNotNull = "";
         
     | 
| 
      
 23765 
     | 
    
         
            +
                    const sqlStatements = [];
         
     | 
| 
      
 23766 
     | 
    
         
            +
                    const indexes = [];
         
     | 
| 
      
 23767 
     | 
    
         
            +
                    for (const table4 of Object.values(json2.tables)) {
         
     | 
| 
      
 23768 
     | 
    
         
            +
                      for (const index4 of Object.values(table4.indexes)) {
         
     | 
| 
      
 23769 
     | 
    
         
            +
                        const unsquashed = SQLiteSquasher.unsquashIdx(index4);
         
     | 
| 
      
 23770 
     | 
    
         
            +
                        sqlStatements.push(`DROP INDEX IF EXISTS "${unsquashed.name}";`);
         
     | 
| 
      
 23771 
     | 
    
         
            +
                        indexes.push({ ...unsquashed, tableName: table4.name });
         
     | 
| 
      
 23772 
     | 
    
         
            +
                      }
         
     | 
| 
      
 23773 
     | 
    
         
            +
                    }
         
     | 
| 
      
 23774 
     | 
    
         
            +
                    switch (statement.type) {
         
     | 
| 
      
 23775 
     | 
    
         
            +
                      case "alter_table_alter_column_set_type":
         
     | 
| 
      
 23776 
     | 
    
         
            +
                        columnType = ` ${statement.newDataType}`;
         
     | 
| 
      
 23777 
     | 
    
         
            +
                        columnDefault = statement.columnDefault ? ` DEFAULT ${statement.columnDefault}` : "";
         
     | 
| 
      
 23778 
     | 
    
         
            +
                        columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
         
     | 
| 
      
 23779 
     | 
    
         
            +
                        break;
         
     | 
| 
      
 23780 
     | 
    
         
            +
                      case "alter_table_alter_column_drop_notnull":
         
     | 
| 
      
 23781 
     | 
    
         
            +
                        columnType = ` ${statement.newDataType}`;
         
     | 
| 
      
 23782 
     | 
    
         
            +
                        columnDefault = statement.columnDefault ? ` DEFAULT ${statement.columnDefault}` : "";
         
     | 
| 
      
 23783 
     | 
    
         
            +
                        columnNotNull = "";
         
     | 
| 
      
 23784 
     | 
    
         
            +
                        break;
         
     | 
| 
      
 23785 
     | 
    
         
            +
                      case "alter_table_alter_column_set_notnull":
         
     | 
| 
      
 23786 
     | 
    
         
            +
                        columnType = ` ${statement.newDataType}`;
         
     | 
| 
      
 23787 
     | 
    
         
            +
                        columnDefault = statement.columnDefault ? ` DEFAULT ${statement.columnDefault}` : "";
         
     | 
| 
      
 23788 
     | 
    
         
            +
                        columnNotNull = ` NOT NULL`;
         
     | 
| 
      
 23789 
     | 
    
         
            +
                        break;
         
     | 
| 
      
 23790 
     | 
    
         
            +
                      case "alter_table_alter_column_set_default":
         
     | 
| 
      
 23791 
     | 
    
         
            +
                        columnType = ` ${statement.newDataType}`;
         
     | 
| 
      
 23792 
     | 
    
         
            +
                        columnDefault = ` DEFAULT ${statement.newDefaultValue}`;
         
     | 
| 
      
 23793 
     | 
    
         
            +
                        columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
         
     | 
| 
      
 23794 
     | 
    
         
            +
                        break;
         
     | 
| 
      
 23795 
     | 
    
         
            +
                      case "alter_table_alter_column_drop_default":
         
     | 
| 
      
 23796 
     | 
    
         
            +
                        columnType = ` ${statement.newDataType}`;
         
     | 
| 
      
 23797 
     | 
    
         
            +
                        columnDefault = "";
         
     | 
| 
      
 23798 
     | 
    
         
            +
                        columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
         
     | 
| 
      
 23799 
     | 
    
         
            +
                        break;
         
     | 
| 
      
 23800 
     | 
    
         
            +
                    }
         
     | 
| 
      
 23801 
     | 
    
         
            +
                    columnDefault = columnDefault instanceof Date ? columnDefault.toISOString() : columnDefault;
         
     | 
| 
      
 23802 
     | 
    
         
            +
                    sqlStatements.push(
         
     | 
| 
      
 23803 
     | 
    
         
            +
                      `ALTER TABLE \`${tableName}\` ALTER COLUMN "${columnName}" TO "${columnName}"${columnType}${columnNotNull}${columnDefault};`
         
     | 
| 
      
 23804 
     | 
    
         
            +
                    );
         
     | 
| 
      
 23805 
     | 
    
         
            +
                    for (const index4 of indexes) {
         
     | 
| 
      
 23806 
     | 
    
         
            +
                      const indexPart = index4.isUnique ? "UNIQUE INDEX" : "INDEX";
         
     | 
| 
      
 23807 
     | 
    
         
            +
                      const whereStatement = index4.where ? ` WHERE ${index4.where}` : "";
         
     | 
| 
      
 23808 
     | 
    
         
            +
                      const uniqueString = index4.columns.map((it) => `\`${it}\``).join(",");
         
     | 
| 
      
 23809 
     | 
    
         
            +
                      const tableName2 = index4.tableName;
         
     | 
| 
      
 23810 
     | 
    
         
            +
                      sqlStatements.push(
         
     | 
| 
      
 23811 
     | 
    
         
            +
                        `CREATE ${indexPart} \`${index4.name}\` ON \`${tableName2}\` (${uniqueString})${whereStatement};`
         
     | 
| 
      
 23812 
     | 
    
         
            +
                      );
         
     | 
| 
      
 23813 
     | 
    
         
            +
                    }
         
     | 
| 
      
 23814 
     | 
    
         
            +
                    return sqlStatements;
         
     | 
| 
      
 23815 
     | 
    
         
            +
                  }
         
     | 
| 
      
 23816 
     | 
    
         
            +
                };
         
     | 
| 
       23788 
23817 
     | 
    
         
             
                MySqlModifyColumn = class extends Convertor {
         
     | 
| 
       23789 
23818 
     | 
    
         
             
                  can(statement, dialect7) {
         
     | 
| 
       23790 
23819 
     | 
    
         
             
                    return (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_drop_on_update" || statement.type === "alter_table_alter_column_set_on_update" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default" || statement.type === "alter_table_alter_column_set_generated" || statement.type === "alter_table_alter_column_drop_generated") && dialect7 === "mysql";
         
     | 
| 
         @@ -23923,21 +23952,6 @@ var init_sqlgenerator = __esm({ 
     | 
|
| 
       23923 
23952 
     | 
    
         
             
                    return `ALTER TABLE \`${tableName}\` MODIFY COLUMN \`${columnName}\`${columnType}${columnAutoincrement}${columnNotNull}${columnDefault}${columnOnUpdate}${columnGenerated};`;
         
     | 
| 
       23924 
23953 
     | 
    
         
             
                  }
         
     | 
| 
       23925 
23954 
     | 
    
         
             
                };
         
     | 
| 
       23926 
     | 
    
         
            -
                SqliteAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
         
     | 
| 
       23927 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       23928 
     | 
    
         
            -
                    return statement.type === "alter_table_alter_column_drop_default" && dialect7 === "sqlite";
         
     | 
| 
       23929 
     | 
    
         
            -
                  }
         
     | 
| 
       23930 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       23931 
     | 
    
         
            -
                    return `/*
         
     | 
| 
       23932 
     | 
    
         
            -
             SQLite does not support "Drop default from column" out of the box, we do not generate automatic migration for that, so it has to be done manually
         
     | 
| 
       23933 
     | 
    
         
            -
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         
     | 
| 
       23934 
     | 
    
         
            -
                              https://www.sqlite.org/lang_altertable.html
         
     | 
| 
       23935 
     | 
    
         
            -
                              https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
         
     | 
| 
       23936 
     | 
    
         
            -
             
     | 
| 
       23937 
     | 
    
         
            -
             Due to that we don't generate migration automatically and it has to be done manually
         
     | 
| 
       23938 
     | 
    
         
            -
            */`;
         
     | 
| 
       23939 
     | 
    
         
            -
                  }
         
     | 
| 
       23940 
     | 
    
         
            -
                };
         
     | 
| 
       23941 
23955 
     | 
    
         
             
                PgAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
         
     | 
| 
       23942 
23956 
     | 
    
         
             
                  can(statement, dialect7) {
         
     | 
| 
       23943 
23957 
     | 
    
         
             
                    return statement.type === "create_composite_pk" && dialect7 === "postgresql";
         
     | 
| 
         @@ -24002,85 +24016,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo 
     | 
|
| 
       24002 
24016 
     | 
    
         
             
                    return `ALTER TABLE \`${statement.tableName}\` DROP PRIMARY KEY, ADD PRIMARY KEY(\`${newColumns.join("`,`")}\`);`;
         
     | 
| 
       24003 
24017 
     | 
    
         
             
                  }
         
     | 
| 
       24004 
24018 
     | 
    
         
             
                };
         
     | 
| 
       24005 
     | 
    
         
            -
                SqliteAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
         
     | 
| 
       24006 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       24007 
     | 
    
         
            -
                    return statement.type === "create_composite_pk" && dialect7 === "sqlite";
         
     | 
| 
       24008 
     | 
    
         
            -
                  }
         
     | 
| 
       24009 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       24010 
     | 
    
         
            -
                    let msg = "/*\n";
         
     | 
| 
       24011 
     | 
    
         
            -
                    msg += `You're trying to add PRIMARY KEY(${statement.data}) to '${statement.tableName}' table
         
     | 
| 
       24012 
     | 
    
         
            -
            `;
         
     | 
| 
       24013 
     | 
    
         
            -
                    msg += "SQLite does not support adding primary key to an already created table\n";
         
     | 
| 
       24014 
     | 
    
         
            -
                    msg += "You can do it in 3 steps with drizzle orm:\n";
         
     | 
| 
       24015 
     | 
    
         
            -
                    msg += " - create new mirror table with needed pk, rename current table to old_table, generate SQL\n";
         
     | 
| 
       24016 
     | 
    
         
            -
                    msg += " - migrate old data from one table to another\n";
         
     | 
| 
       24017 
     | 
    
         
            -
                    msg += " - delete old_table in schema, generate sql\n\n";
         
     | 
| 
       24018 
     | 
    
         
            -
                    msg += "or create manual migration like below:\n\n";
         
     | 
| 
       24019 
     | 
    
         
            -
                    msg += "ALTER TABLE table_name RENAME TO old_table;\n";
         
     | 
| 
       24020 
     | 
    
         
            -
                    msg += "CREATE TABLE table_name (\n";
         
     | 
| 
       24021 
     | 
    
         
            -
                    msg += "	column1 datatype [ NULL | NOT NULL ],\n";
         
     | 
| 
       24022 
     | 
    
         
            -
                    msg += "	column2 datatype [ NULL | NOT NULL ],\n";
         
     | 
| 
       24023 
     | 
    
         
            -
                    msg += "	...\n";
         
     | 
| 
       24024 
     | 
    
         
            -
                    msg += "	PRIMARY KEY (pk_col1, pk_col2, ... pk_col_n)\n";
         
     | 
| 
       24025 
     | 
    
         
            -
                    msg += " );\n";
         
     | 
| 
       24026 
     | 
    
         
            -
                    msg += "INSERT INTO table_name SELECT * FROM old_table;\n\n";
         
     | 
| 
       24027 
     | 
    
         
            -
                    msg += "Due to that we don't generate migration automatically and it has to be done manually\n";
         
     | 
| 
       24028 
     | 
    
         
            -
                    msg += "*/\n";
         
     | 
| 
       24029 
     | 
    
         
            -
                    return msg;
         
     | 
| 
       24030 
     | 
    
         
            -
                  }
         
     | 
| 
       24031 
     | 
    
         
            -
                };
         
     | 
| 
       24032 
     | 
    
         
            -
                SqliteAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
         
     | 
| 
       24033 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       24034 
     | 
    
         
            -
                    return statement.type === "delete_composite_pk" && dialect7 === "sqlite";
         
     | 
| 
       24035 
     | 
    
         
            -
                  }
         
     | 
| 
       24036 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       24037 
     | 
    
         
            -
                    let msg = "/*\n";
         
     | 
| 
       24038 
     | 
    
         
            -
                    msg += `You're trying to delete PRIMARY KEY(${statement.data}) from '${statement.tableName}' table
         
     | 
| 
       24039 
     | 
    
         
            -
            `;
         
     | 
| 
       24040 
     | 
    
         
            -
                    msg += "SQLite does not supportprimary key deletion from existing table\n";
         
     | 
| 
       24041 
     | 
    
         
            -
                    msg += "You can do it in 3 steps with drizzle orm:\n";
         
     | 
| 
       24042 
     | 
    
         
            -
                    msg += " - create new mirror table table without pk, rename current table to old_table, generate SQL\n";
         
     | 
| 
       24043 
     | 
    
         
            -
                    msg += " - migrate old data from one table to another\n";
         
     | 
| 
       24044 
     | 
    
         
            -
                    msg += " - delete old_table in schema, generate sql\n\n";
         
     | 
| 
       24045 
     | 
    
         
            -
                    msg += "or create manual migration like below:\n\n";
         
     | 
| 
       24046 
     | 
    
         
            -
                    msg += "ALTER TABLE table_name RENAME TO old_table;\n";
         
     | 
| 
       24047 
     | 
    
         
            -
                    msg += "CREATE TABLE table_name (\n";
         
     | 
| 
       24048 
     | 
    
         
            -
                    msg += "	column1 datatype [ NULL | NOT NULL ],\n";
         
     | 
| 
       24049 
     | 
    
         
            -
                    msg += "	column2 datatype [ NULL | NOT NULL ],\n";
         
     | 
| 
       24050 
     | 
    
         
            -
                    msg += "	...\n";
         
     | 
| 
       24051 
     | 
    
         
            -
                    msg += "	PRIMARY KEY (pk_col1, pk_col2, ... pk_col_n)\n";
         
     | 
| 
       24052 
     | 
    
         
            -
                    msg += " );\n";
         
     | 
| 
       24053 
     | 
    
         
            -
                    msg += "INSERT INTO table_name SELECT * FROM old_table;\n\n";
         
     | 
| 
       24054 
     | 
    
         
            -
                    msg += "Due to that we don't generate migration automatically and it has to be done manually\n";
         
     | 
| 
       24055 
     | 
    
         
            -
                    msg += "*/\n";
         
     | 
| 
       24056 
     | 
    
         
            -
                    return msg;
         
     | 
| 
       24057 
     | 
    
         
            -
                  }
         
     | 
| 
       24058 
     | 
    
         
            -
                };
         
     | 
| 
       24059 
     | 
    
         
            -
                SqliteAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
         
     | 
| 
       24060 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       24061 
     | 
    
         
            -
                    return statement.type === "alter_composite_pk" && dialect7 === "sqlite";
         
     | 
| 
       24062 
     | 
    
         
            -
                  }
         
     | 
| 
       24063 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       24064 
     | 
    
         
            -
                    let msg = "/*\n";
         
     | 
| 
       24065 
     | 
    
         
            -
                    msg += "SQLite does not support altering primary key\n";
         
     | 
| 
       24066 
     | 
    
         
            -
                    msg += "You can do it in 3 steps with drizzle orm:\n";
         
     | 
| 
       24067 
     | 
    
         
            -
                    msg += " - create new mirror table with needed pk, rename current table to old_table, generate SQL\n";
         
     | 
| 
       24068 
     | 
    
         
            -
                    msg += " - migrate old data from one table to another\n";
         
     | 
| 
       24069 
     | 
    
         
            -
                    msg += " - delete old_table in schema, generate sql\n\n";
         
     | 
| 
       24070 
     | 
    
         
            -
                    msg += "or create manual migration like below:\n\n";
         
     | 
| 
       24071 
     | 
    
         
            -
                    msg += "ALTER TABLE table_name RENAME TO old_table;\n";
         
     | 
| 
       24072 
     | 
    
         
            -
                    msg += "CREATE TABLE table_name (\n";
         
     | 
| 
       24073 
     | 
    
         
            -
                    msg += "	column1 datatype [ NULL | NOT NULL ],\n";
         
     | 
| 
       24074 
     | 
    
         
            -
                    msg += "	column2 datatype [ NULL | NOT NULL ],\n";
         
     | 
| 
       24075 
     | 
    
         
            -
                    msg += "	...\n";
         
     | 
| 
       24076 
     | 
    
         
            -
                    msg += "	PRIMARY KEY (pk_col1, pk_col2, ... pk_col_n)\n";
         
     | 
| 
       24077 
     | 
    
         
            -
                    msg += " );\n";
         
     | 
| 
       24078 
     | 
    
         
            -
                    msg += "INSERT INTO table_name SELECT * FROM old_table;\n\n";
         
     | 
| 
       24079 
     | 
    
         
            -
                    msg += "Due to that we don't generate migration automatically and it has to be done manually\n";
         
     | 
| 
       24080 
     | 
    
         
            -
                    msg += "*/\n";
         
     | 
| 
       24081 
     | 
    
         
            -
                    return msg;
         
     | 
| 
       24082 
     | 
    
         
            -
                  }
         
     | 
| 
       24083 
     | 
    
         
            -
                };
         
     | 
| 
       24084 
24019 
     | 
    
         
             
                PgAlterTableAlterColumnSetPrimaryKeyConvertor = class extends Convertor {
         
     | 
| 
       24085 
24020 
     | 
    
         
             
                  can(statement, dialect7) {
         
     | 
| 
       24086 
24021 
     | 
    
         
             
                    return statement.type === "alter_table_alter_column_set_pk" && dialect7 === "postgresql";
         
     | 
| 
         @@ -24125,51 +24060,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo 
     | 
|
| 
       24125 
24060 
     | 
    
         
             
                    return `ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${columnName}" SET NOT NULL;`;
         
     | 
| 
       24126 
24061 
     | 
    
         
             
                  }
         
     | 
| 
       24127 
24062 
     | 
    
         
             
                };
         
     | 
| 
       24128 
     | 
    
         
            -
                SqliteAlterTableAlterColumnSetNotNullConvertor = class extends Convertor {
         
     | 
| 
       24129 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       24130 
     | 
    
         
            -
                    return statement.type === "alter_table_alter_column_set_notnull" && dialect7 === "sqlite";
         
     | 
| 
       24131 
     | 
    
         
            -
                  }
         
     | 
| 
       24132 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       24133 
     | 
    
         
            -
                    return `/*
         
     | 
| 
       24134 
     | 
    
         
            -
             SQLite does not support "Set not null to column" out of the box, we do not generate automatic migration for that, so it has to be done manually
         
     | 
| 
       24135 
     | 
    
         
            -
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         
     | 
| 
       24136 
     | 
    
         
            -
                              https://www.sqlite.org/lang_altertable.html
         
     | 
| 
       24137 
     | 
    
         
            -
                              https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
         
     | 
| 
       24138 
     | 
    
         
            -
             
     | 
| 
       24139 
     | 
    
         
            -
             Due to that we don't generate migration automatically and it has to be done manually
         
     | 
| 
       24140 
     | 
    
         
            -
            */`;
         
     | 
| 
       24141 
     | 
    
         
            -
                  }
         
     | 
| 
       24142 
     | 
    
         
            -
                };
         
     | 
| 
       24143 
     | 
    
         
            -
                SqliteAlterTableAlterColumnSetAutoincrementConvertor = class extends Convertor {
         
     | 
| 
       24144 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       24145 
     | 
    
         
            -
                    return statement.type === "alter_table_alter_column_set_autoincrement" && dialect7 === "sqlite";
         
     | 
| 
       24146 
     | 
    
         
            -
                  }
         
     | 
| 
       24147 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       24148 
     | 
    
         
            -
                    return `/*
         
     | 
| 
       24149 
     | 
    
         
            -
             SQLite does not support "Set autoincrement to a column" out of the box, we do not generate automatic migration for that, so it has to be done manually
         
     | 
| 
       24150 
     | 
    
         
            -
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         
     | 
| 
       24151 
     | 
    
         
            -
                              https://www.sqlite.org/lang_altertable.html
         
     | 
| 
       24152 
     | 
    
         
            -
                              https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
         
     | 
| 
       24153 
     | 
    
         
            -
             
     | 
| 
       24154 
     | 
    
         
            -
             Due to that we don't generate migration automatically and it has to be done manually
         
     | 
| 
       24155 
     | 
    
         
            -
            */`;
         
     | 
| 
       24156 
     | 
    
         
            -
                  }
         
     | 
| 
       24157 
     | 
    
         
            -
                };
         
     | 
| 
       24158 
     | 
    
         
            -
                SqliteAlterTableAlterColumnDropAutoincrementConvertor = class extends Convertor {
         
     | 
| 
       24159 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       24160 
     | 
    
         
            -
                    return statement.type === "alter_table_alter_column_drop_autoincrement" && dialect7 === "sqlite";
         
     | 
| 
       24161 
     | 
    
         
            -
                  }
         
     | 
| 
       24162 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       24163 
     | 
    
         
            -
                    return `/*
         
     | 
| 
       24164 
     | 
    
         
            -
             SQLite does not support "Drop autoincrement from a column" out of the box, we do not generate automatic migration for that, so it has to be done manually
         
     | 
| 
       24165 
     | 
    
         
            -
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         
     | 
| 
       24166 
     | 
    
         
            -
                              https://www.sqlite.org/lang_altertable.html
         
     | 
| 
       24167 
     | 
    
         
            -
                              https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
         
     | 
| 
       24168 
     | 
    
         
            -
             
     | 
| 
       24169 
     | 
    
         
            -
             Due to that we don't generate migration automatically and it has to be done manually
         
     | 
| 
       24170 
     | 
    
         
            -
            */`;
         
     | 
| 
       24171 
     | 
    
         
            -
                  }
         
     | 
| 
       24172 
     | 
    
         
            -
                };
         
     | 
| 
       24173 
24063 
     | 
    
         
             
                PgAlterTableAlterColumnDropNotNullConvertor = class extends Convertor {
         
     | 
| 
       24174 
24064 
     | 
    
         
             
                  can(statement, dialect7) {
         
     | 
| 
       24175 
24065 
     | 
    
         
             
                    return statement.type === "alter_table_alter_column_drop_notnull" && dialect7 === "postgresql";
         
     | 
| 
         @@ -24180,21 +24070,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo 
     | 
|
| 
       24180 
24070 
     | 
    
         
             
                    return `ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${columnName}" DROP NOT NULL;`;
         
     | 
| 
       24181 
24071 
     | 
    
         
             
                  }
         
     | 
| 
       24182 
24072 
     | 
    
         
             
                };
         
     | 
| 
       24183 
     | 
    
         
            -
                SqliteAlterTableAlterColumnDropNotNullConvertor = class extends Convertor {
         
     | 
| 
       24184 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       24185 
     | 
    
         
            -
                    return statement.type === "alter_table_alter_column_drop_notnull" && dialect7 === "sqlite";
         
     | 
| 
       24186 
     | 
    
         
            -
                  }
         
     | 
| 
       24187 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       24188 
     | 
    
         
            -
                    return `/*
         
     | 
| 
       24189 
     | 
    
         
            -
             SQLite does not support "Drop not null from column" out of the box, we do not generate automatic migration for that, so it has to be done manually
         
     | 
| 
       24190 
     | 
    
         
            -
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         
     | 
| 
       24191 
     | 
    
         
            -
                              https://www.sqlite.org/lang_altertable.html
         
     | 
| 
       24192 
     | 
    
         
            -
                              https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
         
     | 
| 
       24193 
     | 
    
         
            -
             
     | 
| 
       24194 
     | 
    
         
            -
             Due to that we don't generate migration automatically and it has to be done manually
         
     | 
| 
       24195 
     | 
    
         
            -
            */`;
         
     | 
| 
       24196 
     | 
    
         
            -
                  }
         
     | 
| 
       24197 
     | 
    
         
            -
                };
         
     | 
| 
       24198 
24073 
     | 
    
         
             
                PgCreateForeignKeyConvertor = class extends Convertor {
         
     | 
| 
       24199 
24074 
     | 
    
         
             
                  can(statement, dialect7) {
         
     | 
| 
       24200 
24075 
     | 
    
         
             
                    return statement.type === "create_reference" && dialect7 === "postgresql";
         
     | 
| 
         @@ -24225,18 +24100,21 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo 
     | 
|
| 
       24225 
24100 
     | 
    
         
             
                    return sql;
         
     | 
| 
       24226 
24101 
     | 
    
         
             
                  }
         
     | 
| 
       24227 
24102 
     | 
    
         
             
                };
         
     | 
| 
       24228 
     | 
    
         
            -
                 
     | 
| 
       24229 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       24230 
     | 
    
         
            -
                    return statement.type === "create_reference" && dialect7 === "sqlite";
         
     | 
| 
      
 24103 
     | 
    
         
            +
                LibSQLCreateForeignKeyConvertor = class extends Convertor {
         
     | 
| 
      
 24104 
     | 
    
         
            +
                  can(statement, dialect7, driver2) {
         
     | 
| 
      
 24105 
     | 
    
         
            +
                    return statement.type === "create_reference" && dialect7 === "sqlite" && driver2 === "turso";
         
     | 
| 
       24231 
24106 
     | 
    
         
             
                  }
         
     | 
| 
       24232 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       24233 
     | 
    
         
            -
                     
     | 
| 
       24234 
     | 
    
         
            -
              
     | 
| 
       24235 
     | 
    
         
            -
              
     | 
| 
       24236 
     | 
    
         
            -
             
     | 
| 
       24237 
     | 
    
         
            -
             
     | 
| 
       24238 
     | 
    
         
            -
              
     | 
| 
       24239 
     | 
    
         
            -
             
     | 
| 
      
 24107 
     | 
    
         
            +
                  convert(statement, json2, action) {
         
     | 
| 
      
 24108 
     | 
    
         
            +
                    const { columnsFrom, columnsTo, tableFrom, onDelete, onUpdate, tableTo } = action === "push" ? SQLiteSquasher.unsquashPushFK(statement.data) : SQLiteSquasher.unsquashFK(statement.data);
         
     | 
| 
      
 24109 
     | 
    
         
            +
                    const { columnDefault, columnNotNull, columnType } = statement;
         
     | 
| 
      
 24110 
     | 
    
         
            +
                    const onDeleteStatement = onDelete ? ` ON DELETE ${onDelete}` : "";
         
     | 
| 
      
 24111 
     | 
    
         
            +
                    const onUpdateStatement = onUpdate ? ` ON UPDATE ${onUpdate}` : "";
         
     | 
| 
      
 24112 
     | 
    
         
            +
                    const columnsDefaultValue = columnDefault ? ` DEFAULT ${columnDefault}` : "";
         
     | 
| 
      
 24113 
     | 
    
         
            +
                    const columnNotNullValue = columnNotNull ? ` NOT NULL` : "";
         
     | 
| 
      
 24114 
     | 
    
         
            +
                    const columnTypeValue = columnType ? ` ${columnType}` : "";
         
     | 
| 
      
 24115 
     | 
    
         
            +
                    const columnFrom = columnsFrom[0];
         
     | 
| 
      
 24116 
     | 
    
         
            +
                    const columnTo = columnsTo[0];
         
     | 
| 
      
 24117 
     | 
    
         
            +
                    return `ALTER TABLE \`${tableFrom}\` ALTER COLUMN "${columnFrom}" TO "${columnFrom}"${columnTypeValue}${columnNotNullValue}${columnsDefaultValue} REFERENCES ${tableTo}(${columnTo})${onDeleteStatement}${onUpdateStatement};`;
         
     | 
| 
       24240 
24118 
     | 
    
         
             
                  }
         
     | 
| 
       24241 
24119 
     | 
    
         
             
                };
         
     | 
| 
       24242 
24120 
     | 
    
         
             
                MySqlCreateForeignKeyConvertor = class extends Convertor {
         
     | 
| 
         @@ -24285,20 +24163,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo 
     | 
|
| 
       24285 
24163 
     | 
    
         
             
                    return sql;
         
     | 
| 
       24286 
24164 
     | 
    
         
             
                  }
         
     | 
| 
       24287 
24165 
     | 
    
         
             
                };
         
     | 
| 
       24288 
     | 
    
         
            -
                SqliteAlterForeignKeyConvertor = class extends Convertor {
         
     | 
| 
       24289 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       24290 
     | 
    
         
            -
                    return statement.type === "alter_reference" && dialect7 === "sqlite";
         
     | 
| 
       24291 
     | 
    
         
            -
                  }
         
     | 
| 
       24292 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       24293 
     | 
    
         
            -
                    return `/*
         
     | 
| 
       24294 
     | 
    
         
            -
             SQLite does not support "Changing existing foreign key" out of the box, we do not generate automatic migration for that, so it has to be done manually
         
     | 
| 
       24295 
     | 
    
         
            -
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         
     | 
| 
       24296 
     | 
    
         
            -
                              https://www.sqlite.org/lang_altertable.html
         
     | 
| 
       24297 
     | 
    
         
            -
             
     | 
| 
       24298 
     | 
    
         
            -
             Due to that we don't generate migration automatically and it has to be done manually
         
     | 
| 
       24299 
     | 
    
         
            -
            */`;
         
     | 
| 
       24300 
     | 
    
         
            -
                  }
         
     | 
| 
       24301 
     | 
    
         
            -
                };
         
     | 
| 
       24302 
24166 
     | 
    
         
             
                PgDeleteForeignKeyConvertor = class extends Convertor {
         
     | 
| 
       24303 
24167 
     | 
    
         
             
                  can(statement, dialect7) {
         
     | 
| 
       24304 
24168 
     | 
    
         
             
                    return statement.type === "delete_reference" && dialect7 === "postgresql";
         
     | 
| 
         @@ -24311,20 +24175,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo 
     | 
|
| 
       24311 
24175 
     | 
    
         
             
            `;
         
     | 
| 
       24312 
24176 
     | 
    
         
             
                  }
         
     | 
| 
       24313 
24177 
     | 
    
         
             
                };
         
     | 
| 
       24314 
     | 
    
         
            -
                SqliteDeleteForeignKeyConvertor = class extends Convertor {
         
     | 
| 
       24315 
     | 
    
         
            -
                  can(statement, dialect7) {
         
     | 
| 
       24316 
     | 
    
         
            -
                    return statement.type === "delete_reference" && dialect7 === "sqlite";
         
     | 
| 
       24317 
     | 
    
         
            -
                  }
         
     | 
| 
       24318 
     | 
    
         
            -
                  convert(statement) {
         
     | 
| 
       24319 
     | 
    
         
            -
                    return `/*
         
     | 
| 
       24320 
     | 
    
         
            -
             SQLite does not support "Dropping foreign key" out of the box, we do not generate automatic migration for that, so it has to be done manually
         
     | 
| 
       24321 
     | 
    
         
            -
             Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
         
     | 
| 
       24322 
     | 
    
         
            -
                              https://www.sqlite.org/lang_altertable.html
         
     | 
| 
       24323 
     | 
    
         
            -
             
     | 
| 
       24324 
     | 
    
         
            -
             Due to that we don't generate migration automatically and it has to be done manually
         
     | 
| 
       24325 
     | 
    
         
            -
            */`;
         
     | 
| 
       24326 
     | 
    
         
            -
                  }
         
     | 
| 
       24327 
     | 
    
         
            -
                };
         
     | 
| 
       24328 
24178 
     | 
    
         
             
                MySqlDeleteForeignKeyConvertor = class extends Convertor {
         
     | 
| 
       24329 
24179 
     | 
    
         
             
                  can(statement, dialect7) {
         
     | 
| 
       24330 
24180 
     | 
    
         
             
                    return statement.type === "delete_reference" && dialect7 === "mysql";
         
     | 
| 
         @@ -24490,10 +24340,96 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo 
     | 
|
| 
       24490 
24340 
     | 
    
         
             
                    return `DROP INDEX \`${name}\` ON \`${statement.tableName}\`;`;
         
     | 
| 
       24491 
24341 
     | 
    
         
             
                  }
         
     | 
| 
       24492 
24342 
     | 
    
         
             
                };
         
     | 
| 
      
 24343 
     | 
    
         
            +
                SQLiteRecreateTableConvertor = class extends Convertor {
         
     | 
| 
      
 24344 
     | 
    
         
            +
                  can(statement, dialect7, driver2) {
         
     | 
| 
      
 24345 
     | 
    
         
            +
                    return statement.type === "recreate_table" && dialect7 === "sqlite" && !driver2;
         
     | 
| 
      
 24346 
     | 
    
         
            +
                  }
         
     | 
| 
      
 24347 
     | 
    
         
            +
                  convert(statement) {
         
     | 
| 
      
 24348 
     | 
    
         
            +
                    const { tableName, columns, compositePKs, referenceData } = statement;
         
     | 
| 
      
 24349 
     | 
    
         
            +
                    const columnNames = columns.map((it) => `"${it.name}"`).join(", ");
         
     | 
| 
      
 24350 
     | 
    
         
            +
                    const newTableName = `__new_${tableName}`;
         
     | 
| 
      
 24351 
     | 
    
         
            +
                    const sqlStatements = [];
         
     | 
| 
      
 24352 
     | 
    
         
            +
                    sqlStatements.push(`PRAGMA foreign_keys=OFF;`);
         
     | 
| 
      
 24353 
     | 
    
         
            +
                    sqlStatements.push(
         
     | 
| 
      
 24354 
     | 
    
         
            +
                      new SQLiteCreateTableConvertor().convert({
         
     | 
| 
      
 24355 
     | 
    
         
            +
                        type: "sqlite_create_table",
         
     | 
| 
      
 24356 
     | 
    
         
            +
                        tableName: newTableName,
         
     | 
| 
      
 24357 
     | 
    
         
            +
                        columns,
         
     | 
| 
      
 24358 
     | 
    
         
            +
                        referenceData,
         
     | 
| 
      
 24359 
     | 
    
         
            +
                        compositePKs
         
     | 
| 
      
 24360 
     | 
    
         
            +
                      })
         
     | 
| 
      
 24361 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24362 
     | 
    
         
            +
                    sqlStatements.push(
         
     | 
| 
      
 24363 
     | 
    
         
            +
                      `INSERT INTO \`${newTableName}\`(${columnNames}) SELECT ${columnNames} FROM \`${tableName}\`;`
         
     | 
| 
      
 24364 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24365 
     | 
    
         
            +
                    sqlStatements.push(
         
     | 
| 
      
 24366 
     | 
    
         
            +
                      new SQLiteDropTableConvertor().convert({
         
     | 
| 
      
 24367 
     | 
    
         
            +
                        type: "drop_table",
         
     | 
| 
      
 24368 
     | 
    
         
            +
                        tableName,
         
     | 
| 
      
 24369 
     | 
    
         
            +
                        schema: ""
         
     | 
| 
      
 24370 
     | 
    
         
            +
                      })
         
     | 
| 
      
 24371 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24372 
     | 
    
         
            +
                    sqlStatements.push(
         
     | 
| 
      
 24373 
     | 
    
         
            +
                      new SqliteRenameTableConvertor().convert({
         
     | 
| 
      
 24374 
     | 
    
         
            +
                        fromSchema: "",
         
     | 
| 
      
 24375 
     | 
    
         
            +
                        tableNameFrom: newTableName,
         
     | 
| 
      
 24376 
     | 
    
         
            +
                        tableNameTo: tableName,
         
     | 
| 
      
 24377 
     | 
    
         
            +
                        toSchema: "",
         
     | 
| 
      
 24378 
     | 
    
         
            +
                        type: "rename_table"
         
     | 
| 
      
 24379 
     | 
    
         
            +
                      })
         
     | 
| 
      
 24380 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24381 
     | 
    
         
            +
                    sqlStatements.push(`PRAGMA foreign_keys=ON;`);
         
     | 
| 
      
 24382 
     | 
    
         
            +
                    return sqlStatements;
         
     | 
| 
      
 24383 
     | 
    
         
            +
                  }
         
     | 
| 
      
 24384 
     | 
    
         
            +
                };
         
     | 
| 
      
 24385 
     | 
    
         
            +
                LibSQLRecreateTableConvertor = class extends Convertor {
         
     | 
| 
      
 24386 
     | 
    
         
            +
                  can(statement, dialect7, driver2) {
         
     | 
| 
      
 24387 
     | 
    
         
            +
                    return statement.type === "recreate_table" && dialect7 === "sqlite" && driver2 === "turso";
         
     | 
| 
      
 24388 
     | 
    
         
            +
                  }
         
     | 
| 
      
 24389 
     | 
    
         
            +
                  convert(statement) {
         
     | 
| 
      
 24390 
     | 
    
         
            +
                    const { tableName, columns, compositePKs, referenceData } = statement;
         
     | 
| 
      
 24391 
     | 
    
         
            +
                    const columnNames = columns.map((it) => `"${it.name}"`).join(", ");
         
     | 
| 
      
 24392 
     | 
    
         
            +
                    const newTableName = `__new_${tableName}`;
         
     | 
| 
      
 24393 
     | 
    
         
            +
                    const sqlStatements = [];
         
     | 
| 
      
 24394 
     | 
    
         
            +
                    sqlStatements.push(`PRAGMA foreign_keys=OFF;`);
         
     | 
| 
      
 24395 
     | 
    
         
            +
                    sqlStatements.push(
         
     | 
| 
      
 24396 
     | 
    
         
            +
                      new SQLiteCreateTableConvertor().convert({
         
     | 
| 
      
 24397 
     | 
    
         
            +
                        type: "sqlite_create_table",
         
     | 
| 
      
 24398 
     | 
    
         
            +
                        tableName: newTableName,
         
     | 
| 
      
 24399 
     | 
    
         
            +
                        columns,
         
     | 
| 
      
 24400 
     | 
    
         
            +
                        referenceData,
         
     | 
| 
      
 24401 
     | 
    
         
            +
                        compositePKs
         
     | 
| 
      
 24402 
     | 
    
         
            +
                      })
         
     | 
| 
      
 24403 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24404 
     | 
    
         
            +
                    sqlStatements.push(
         
     | 
| 
      
 24405 
     | 
    
         
            +
                      `INSERT INTO \`${newTableName}\`(${columnNames}) SELECT ${columnNames} FROM \`${tableName}\`;`
         
     | 
| 
      
 24406 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24407 
     | 
    
         
            +
                    sqlStatements.push(
         
     | 
| 
      
 24408 
     | 
    
         
            +
                      new SQLiteDropTableConvertor().convert({
         
     | 
| 
      
 24409 
     | 
    
         
            +
                        type: "drop_table",
         
     | 
| 
      
 24410 
     | 
    
         
            +
                        tableName,
         
     | 
| 
      
 24411 
     | 
    
         
            +
                        schema: ""
         
     | 
| 
      
 24412 
     | 
    
         
            +
                      })
         
     | 
| 
      
 24413 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24414 
     | 
    
         
            +
                    sqlStatements.push(
         
     | 
| 
      
 24415 
     | 
    
         
            +
                      new SqliteRenameTableConvertor().convert({
         
     | 
| 
      
 24416 
     | 
    
         
            +
                        fromSchema: "",
         
     | 
| 
      
 24417 
     | 
    
         
            +
                        tableNameFrom: newTableName,
         
     | 
| 
      
 24418 
     | 
    
         
            +
                        tableNameTo: tableName,
         
     | 
| 
      
 24419 
     | 
    
         
            +
                        toSchema: "",
         
     | 
| 
      
 24420 
     | 
    
         
            +
                        type: "rename_table"
         
     | 
| 
      
 24421 
     | 
    
         
            +
                      })
         
     | 
| 
      
 24422 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24423 
     | 
    
         
            +
                    sqlStatements.push(`PRAGMA foreign_keys=ON;`);
         
     | 
| 
      
 24424 
     | 
    
         
            +
                    return sqlStatements;
         
     | 
| 
      
 24425 
     | 
    
         
            +
                  }
         
     | 
| 
      
 24426 
     | 
    
         
            +
                };
         
     | 
| 
       24493 
24427 
     | 
    
         
             
                convertors = [];
         
     | 
| 
       24494 
24428 
     | 
    
         
             
                convertors.push(new PgCreateTableConvertor());
         
     | 
| 
       24495 
24429 
     | 
    
         
             
                convertors.push(new MySqlCreateTableConvertor());
         
     | 
| 
       24496 
24430 
     | 
    
         
             
                convertors.push(new SQLiteCreateTableConvertor());
         
     | 
| 
      
 24431 
     | 
    
         
            +
                convertors.push(new SQLiteRecreateTableConvertor());
         
     | 
| 
      
 24432 
     | 
    
         
            +
                convertors.push(new LibSQLRecreateTableConvertor());
         
     | 
| 
       24497 
24433 
     | 
    
         
             
                convertors.push(new CreateTypeEnumConvertor());
         
     | 
| 
       24498 
24434 
     | 
    
         
             
                convertors.push(new CreatePgSequenceConvertor());
         
     | 
| 
       24499 
24435 
     | 
    
         
             
                convertors.push(new DropPgSequenceConvertor());
         
     | 
| 
         @@ -24541,6 +24477,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo 
     | 
|
| 
       24541 
24477 
     | 
    
         
             
                convertors.push(new SqliteAlterTableAlterColumnAlterGeneratedConvertor());
         
     | 
| 
       24542 
24478 
     | 
    
         
             
                convertors.push(new SqliteAlterTableAlterColumnSetExpressionConvertor());
         
     | 
| 
       24543 
24479 
     | 
    
         
             
                convertors.push(new MySqlModifyColumn());
         
     | 
| 
      
 24480 
     | 
    
         
            +
                convertors.push(new LibSQLModifyColumn());
         
     | 
| 
       24544 
24481 
     | 
    
         
             
                convertors.push(new PgCreateForeignKeyConvertor());
         
     | 
| 
       24545 
24482 
     | 
    
         
             
                convertors.push(new MySqlCreateForeignKeyConvertor());
         
     | 
| 
       24546 
24483 
     | 
    
         
             
                convertors.push(new PgAlterForeignKeyConvertor());
         
     | 
| 
         @@ -24552,24 +24489,10 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo 
     | 
|
| 
       24552 
24489 
     | 
    
         
             
                convertors.push(new PgAlterTableSetSchemaConvertor());
         
     | 
| 
       24553 
24490 
     | 
    
         
             
                convertors.push(new PgAlterTableSetNewSchemaConvertor());
         
     | 
| 
       24554 
24491 
     | 
    
         
             
                convertors.push(new PgAlterTableRemoveFromSchemaConvertor());
         
     | 
| 
       24555 
     | 
    
         
            -
                convertors.push(new  
     | 
| 
       24556 
     | 
    
         
            -
                convertors.push(new SqliteAlterForeignKeyConvertor());
         
     | 
| 
       24557 
     | 
    
         
            -
                convertors.push(new SqliteDeleteForeignKeyConvertor());
         
     | 
| 
       24558 
     | 
    
         
            -
                convertors.push(new SqliteCreateForeignKeyConvertor());
         
     | 
| 
       24559 
     | 
    
         
            -
                convertors.push(new SQLiteAlterTableAddUniqueConstraintConvertor());
         
     | 
| 
       24560 
     | 
    
         
            -
                convertors.push(new SQLiteAlterTableDropUniqueConstraintConvertor());
         
     | 
| 
      
 24492 
     | 
    
         
            +
                convertors.push(new LibSQLCreateForeignKeyConvertor());
         
     | 
| 
       24561 
24493 
     | 
    
         
             
                convertors.push(new PgAlterTableAlterColumnDropGenerated());
         
     | 
| 
       24562 
24494 
     | 
    
         
             
                convertors.push(new PgAlterTableAlterColumnSetGenerated());
         
     | 
| 
       24563 
24495 
     | 
    
         
             
                convertors.push(new PgAlterTableAlterColumnAlterGenerated());
         
     | 
| 
       24564 
     | 
    
         
            -
                convertors.push(new SqliteAlterTableAlterColumnSetNotNullConvertor());
         
     | 
| 
       24565 
     | 
    
         
            -
                convertors.push(new SqliteAlterTableAlterColumnDropNotNullConvertor());
         
     | 
| 
       24566 
     | 
    
         
            -
                convertors.push(new SqliteAlterTableAlterColumnSetDefaultConvertor());
         
     | 
| 
       24567 
     | 
    
         
            -
                convertors.push(new SqliteAlterTableAlterColumnDropDefaultConvertor());
         
     | 
| 
       24568 
     | 
    
         
            -
                convertors.push(new SqliteAlterTableAlterColumnSetAutoincrementConvertor());
         
     | 
| 
       24569 
     | 
    
         
            -
                convertors.push(new SqliteAlterTableAlterColumnDropAutoincrementConvertor());
         
     | 
| 
       24570 
     | 
    
         
            -
                convertors.push(new SqliteAlterTableCreateCompositePrimaryKeyConvertor());
         
     | 
| 
       24571 
     | 
    
         
            -
                convertors.push(new SqliteAlterTableDeleteCompositePrimaryKeyConvertor());
         
     | 
| 
       24572 
     | 
    
         
            -
                convertors.push(new SqliteAlterTableAlterCompositePrimaryKeyConvertor());
         
     | 
| 
       24573 
24496 
     | 
    
         
             
                convertors.push(new PgAlterTableCreateCompositePrimaryKeyConvertor());
         
     | 
| 
       24574 
24497 
     | 
    
         
             
                convertors.push(new PgAlterTableDeleteCompositePrimaryKeyConvertor());
         
     | 
| 
       24575 
24498 
     | 
    
         
             
                convertors.push(new PgAlterTableAlterCompositePrimaryKeyConvertor());
         
     | 
| 
         @@ -24578,19 +24501,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo 
     | 
|
| 
       24578 
24501 
     | 
    
         
             
                convertors.push(new MySqlAlterTableCreateCompositePrimaryKeyConvertor());
         
     | 
| 
       24579 
24502 
     | 
    
         
             
                convertors.push(new MySqlAlterTableAddPk());
         
     | 
| 
       24580 
24503 
     | 
    
         
             
                convertors.push(new MySqlAlterTableAlterCompositePrimaryKeyConvertor());
         
     | 
| 
       24581 
     | 
    
         
            -
                fromJson = (statements, dialect7) => {
         
     | 
| 
       24582 
     | 
    
         
            -
                  const result = statements.flatMap((statement) => {
         
     | 
| 
       24583 
     | 
    
         
            -
                    const filtered = convertors.filter((it) => {
         
     | 
| 
       24584 
     | 
    
         
            -
                      return it.can(statement, dialect7);
         
     | 
| 
       24585 
     | 
    
         
            -
                    });
         
     | 
| 
       24586 
     | 
    
         
            -
                    const convertor = filtered.length === 1 ? filtered[0] : void 0;
         
     | 
| 
       24587 
     | 
    
         
            -
                    if (!convertor) {
         
     | 
| 
       24588 
     | 
    
         
            -
                      return "";
         
     | 
| 
       24589 
     | 
    
         
            -
                    }
         
     | 
| 
       24590 
     | 
    
         
            -
                    return convertor.convert(statement);
         
     | 
| 
       24591 
     | 
    
         
            -
                  }).filter((it) => it !== "");
         
     | 
| 
       24592 
     | 
    
         
            -
                  return result;
         
     | 
| 
       24593 
     | 
    
         
            -
                };
         
     | 
| 
       24594 
24504 
     | 
    
         
             
                https:
         
     | 
| 
       24595 
24505 
     | 
    
         
             
                  `
         
     | 
| 
       24596 
24506 
     | 
    
         
             
            create table users (
         
     | 
| 
         @@ -24618,12 +24528,248 @@ drop type __venum; 
     | 
|
| 
       24618 
24528 
     | 
    
         
             
              }
         
     | 
| 
       24619 
24529 
     | 
    
         
             
            });
         
     | 
| 
       24620 
24530 
     | 
    
         | 
| 
      
 24531 
     | 
    
         
            +
            // src/cli/commands/sqlitePushUtils.ts
         
     | 
| 
      
 24532 
     | 
    
         
            +
            var _moveDataStatements, getOldTableName, getNewTableName, logSuggestionsAndReturn;
         
     | 
| 
      
 24533 
     | 
    
         
            +
            var init_sqlitePushUtils = __esm({
         
     | 
| 
      
 24534 
     | 
    
         
            +
              "src/cli/commands/sqlitePushUtils.ts"() {
         
     | 
| 
      
 24535 
     | 
    
         
            +
                "use strict";
         
     | 
| 
      
 24536 
     | 
    
         
            +
                init_source();
         
     | 
| 
      
 24537 
     | 
    
         
            +
                init_sqliteSchema();
         
     | 
| 
      
 24538 
     | 
    
         
            +
                init_sqlgenerator();
         
     | 
| 
      
 24539 
     | 
    
         
            +
                init_utils();
         
     | 
| 
      
 24540 
     | 
    
         
            +
                _moveDataStatements = (tableName, json, dataLoss = false) => {
         
     | 
| 
      
 24541 
     | 
    
         
            +
                  const statements = [];
         
     | 
| 
      
 24542 
     | 
    
         
            +
                  const newTableName = `__new_${tableName}`;
         
     | 
| 
      
 24543 
     | 
    
         
            +
                  const tableColumns = Object.values(json.tables[tableName].columns);
         
     | 
| 
      
 24544 
     | 
    
         
            +
                  const referenceData = Object.values(json.tables[tableName].foreignKeys);
         
     | 
| 
      
 24545 
     | 
    
         
            +
                  const compositePKs = Object.values(
         
     | 
| 
      
 24546 
     | 
    
         
            +
                    json.tables[tableName].compositePrimaryKeys
         
     | 
| 
      
 24547 
     | 
    
         
            +
                  ).map((it) => SQLiteSquasher.unsquashPK(it));
         
     | 
| 
      
 24548 
     | 
    
         
            +
                  const fks = referenceData.map((it) => SQLiteSquasher.unsquashPushFK(it));
         
     | 
| 
      
 24549 
     | 
    
         
            +
                  statements.push(
         
     | 
| 
      
 24550 
     | 
    
         
            +
                    new SQLiteCreateTableConvertor().convert({
         
     | 
| 
      
 24551 
     | 
    
         
            +
                      type: "sqlite_create_table",
         
     | 
| 
      
 24552 
     | 
    
         
            +
                      tableName: newTableName,
         
     | 
| 
      
 24553 
     | 
    
         
            +
                      columns: tableColumns,
         
     | 
| 
      
 24554 
     | 
    
         
            +
                      referenceData: fks,
         
     | 
| 
      
 24555 
     | 
    
         
            +
                      compositePKs
         
     | 
| 
      
 24556 
     | 
    
         
            +
                    })
         
     | 
| 
      
 24557 
     | 
    
         
            +
                  );
         
     | 
| 
      
 24558 
     | 
    
         
            +
                  if (!dataLoss) {
         
     | 
| 
      
 24559 
     | 
    
         
            +
                    const columns = Object.keys(json.tables[tableName].columns).map(
         
     | 
| 
      
 24560 
     | 
    
         
            +
                      (c) => `"${c}"`
         
     | 
| 
      
 24561 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24562 
     | 
    
         
            +
                    statements.push(
         
     | 
| 
      
 24563 
     | 
    
         
            +
                      `INSERT INTO \`${newTableName}\`(${columns.join(
         
     | 
| 
      
 24564 
     | 
    
         
            +
                        ", "
         
     | 
| 
      
 24565 
     | 
    
         
            +
                      )}) SELECT ${columns.join(", ")} FROM \`${tableName}\`;`
         
     | 
| 
      
 24566 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24567 
     | 
    
         
            +
                  }
         
     | 
| 
      
 24568 
     | 
    
         
            +
                  statements.push(
         
     | 
| 
      
 24569 
     | 
    
         
            +
                    new SQLiteDropTableConvertor().convert({
         
     | 
| 
      
 24570 
     | 
    
         
            +
                      type: "drop_table",
         
     | 
| 
      
 24571 
     | 
    
         
            +
                      tableName,
         
     | 
| 
      
 24572 
     | 
    
         
            +
                      schema: ""
         
     | 
| 
      
 24573 
     | 
    
         
            +
                    })
         
     | 
| 
      
 24574 
     | 
    
         
            +
                  );
         
     | 
| 
      
 24575 
     | 
    
         
            +
                  statements.push(
         
     | 
| 
      
 24576 
     | 
    
         
            +
                    new SqliteRenameTableConvertor().convert({
         
     | 
| 
      
 24577 
     | 
    
         
            +
                      fromSchema: "",
         
     | 
| 
      
 24578 
     | 
    
         
            +
                      tableNameFrom: newTableName,
         
     | 
| 
      
 24579 
     | 
    
         
            +
                      tableNameTo: tableName,
         
     | 
| 
      
 24580 
     | 
    
         
            +
                      toSchema: "",
         
     | 
| 
      
 24581 
     | 
    
         
            +
                      type: "rename_table"
         
     | 
| 
      
 24582 
     | 
    
         
            +
                    })
         
     | 
| 
      
 24583 
     | 
    
         
            +
                  );
         
     | 
| 
      
 24584 
     | 
    
         
            +
                  for (const idx of Object.values(json.tables[tableName].indexes)) {
         
     | 
| 
      
 24585 
     | 
    
         
            +
                    statements.push(
         
     | 
| 
      
 24586 
     | 
    
         
            +
                      new CreateSqliteIndexConvertor().convert({
         
     | 
| 
      
 24587 
     | 
    
         
            +
                        type: "create_index",
         
     | 
| 
      
 24588 
     | 
    
         
            +
                        tableName,
         
     | 
| 
      
 24589 
     | 
    
         
            +
                        schema: "",
         
     | 
| 
      
 24590 
     | 
    
         
            +
                        data: idx
         
     | 
| 
      
 24591 
     | 
    
         
            +
                      })
         
     | 
| 
      
 24592 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24593 
     | 
    
         
            +
                  }
         
     | 
| 
      
 24594 
     | 
    
         
            +
                  return statements;
         
     | 
| 
      
 24595 
     | 
    
         
            +
                };
         
     | 
| 
      
 24596 
     | 
    
         
            +
                getOldTableName = (tableName, meta) => {
         
     | 
| 
      
 24597 
     | 
    
         
            +
                  for (const key of Object.keys(meta.tables)) {
         
     | 
| 
      
 24598 
     | 
    
         
            +
                    const value = meta.tables[key];
         
     | 
| 
      
 24599 
     | 
    
         
            +
                    if (`"${tableName}"` === value) {
         
     | 
| 
      
 24600 
     | 
    
         
            +
                      return key.substring(1, key.length - 1);
         
     | 
| 
      
 24601 
     | 
    
         
            +
                    }
         
     | 
| 
      
 24602 
     | 
    
         
            +
                  }
         
     | 
| 
      
 24603 
     | 
    
         
            +
                  return tableName;
         
     | 
| 
      
 24604 
     | 
    
         
            +
                };
         
     | 
| 
      
 24605 
     | 
    
         
            +
                getNewTableName = (tableName, meta) => {
         
     | 
| 
      
 24606 
     | 
    
         
            +
                  if (typeof meta.tables[`"${tableName}"`] !== "undefined") {
         
     | 
| 
      
 24607 
     | 
    
         
            +
                    return meta.tables[`"${tableName}"`].substring(
         
     | 
| 
      
 24608 
     | 
    
         
            +
                      1,
         
     | 
| 
      
 24609 
     | 
    
         
            +
                      meta.tables[`"${tableName}"`].length - 1
         
     | 
| 
      
 24610 
     | 
    
         
            +
                    );
         
     | 
| 
      
 24611 
     | 
    
         
            +
                  }
         
     | 
| 
      
 24612 
     | 
    
         
            +
                  return tableName;
         
     | 
| 
      
 24613 
     | 
    
         
            +
                };
         
     | 
| 
      
 24614 
     | 
    
         
            +
                logSuggestionsAndReturn = async (connection, statements, json1, json2, meta) => {
         
     | 
| 
      
 24615 
     | 
    
         
            +
                  let shouldAskForApprove = false;
         
     | 
| 
      
 24616 
     | 
    
         
            +
                  const statementsToExecute = [];
         
     | 
| 
      
 24617 
     | 
    
         
            +
                  const infoToPrint = [];
         
     | 
| 
      
 24618 
     | 
    
         
            +
                  const tablesToRemove = [];
         
     | 
| 
      
 24619 
     | 
    
         
            +
                  const columnsToRemove = [];
         
     | 
| 
      
 24620 
     | 
    
         
            +
                  const schemasToRemove = [];
         
     | 
| 
      
 24621 
     | 
    
         
            +
                  const tablesToTruncate = [];
         
     | 
| 
      
 24622 
     | 
    
         
            +
                  for (const statement of statements) {
         
     | 
| 
      
 24623 
     | 
    
         
            +
                    if (statement.type === "drop_table") {
         
     | 
| 
      
 24624 
     | 
    
         
            +
                      const res = await connection.query(
         
     | 
| 
      
 24625 
     | 
    
         
            +
                        `select count(*) as count from \`${statement.tableName}\``
         
     | 
| 
      
 24626 
     | 
    
         
            +
                      );
         
     | 
| 
      
 24627 
     | 
    
         
            +
                      const count = Number(res[0].count);
         
     | 
| 
      
 24628 
     | 
    
         
            +
                      if (count > 0) {
         
     | 
| 
      
 24629 
     | 
    
         
            +
                        infoToPrint.push(
         
     | 
| 
      
 24630 
     | 
    
         
            +
                          `\xB7 You're about to delete ${source_default.underline(
         
     | 
| 
      
 24631 
     | 
    
         
            +
                            statement.tableName
         
     | 
| 
      
 24632 
     | 
    
         
            +
                          )} table with ${count} items`
         
     | 
| 
      
 24633 
     | 
    
         
            +
                        );
         
     | 
| 
      
 24634 
     | 
    
         
            +
                        tablesToRemove.push(statement.tableName);
         
     | 
| 
      
 24635 
     | 
    
         
            +
                        shouldAskForApprove = true;
         
     | 
| 
      
 24636 
     | 
    
         
            +
                      }
         
     | 
| 
      
 24637 
     | 
    
         
            +
                      const fromJsonStatement = fromJson([statement], "sqlite", "push");
         
     | 
| 
      
 24638 
     | 
    
         
            +
                      statementsToExecute.push(
         
     | 
| 
      
 24639 
     | 
    
         
            +
                        ...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
         
     | 
| 
      
 24640 
     | 
    
         
            +
                      );
         
     | 
| 
      
 24641 
     | 
    
         
            +
                    } else if (statement.type === "alter_table_drop_column") {
         
     | 
| 
      
 24642 
     | 
    
         
            +
                      const tableName = statement.tableName;
         
     | 
| 
      
 24643 
     | 
    
         
            +
                      const columnName = statement.columnName;
         
     | 
| 
      
 24644 
     | 
    
         
            +
                      const res = await connection.query(
         
     | 
| 
      
 24645 
     | 
    
         
            +
                        `select count(\`${tableName}\`.\`${columnName}\`) as count from \`${tableName}\``
         
     | 
| 
      
 24646 
     | 
    
         
            +
                      );
         
     | 
| 
      
 24647 
     | 
    
         
            +
                      const count = Number(res[0].count);
         
     | 
| 
      
 24648 
     | 
    
         
            +
                      if (count > 0) {
         
     | 
| 
      
 24649 
     | 
    
         
            +
                        infoToPrint.push(
         
     | 
| 
      
 24650 
     | 
    
         
            +
                          `\xB7 You're about to delete ${source_default.underline(
         
     | 
| 
      
 24651 
     | 
    
         
            +
                            columnName
         
     | 
| 
      
 24652 
     | 
    
         
            +
                          )} column in ${tableName} table with ${count} items`
         
     | 
| 
      
 24653 
     | 
    
         
            +
                        );
         
     | 
| 
      
 24654 
     | 
    
         
            +
                        columnsToRemove.push(`${tableName}_${statement.columnName}`);
         
     | 
| 
      
 24655 
     | 
    
         
            +
                        shouldAskForApprove = true;
         
     | 
| 
      
 24656 
     | 
    
         
            +
                      }
         
     | 
| 
      
 24657 
     | 
    
         
            +
                      const fromJsonStatement = fromJson([statement], "sqlite", "push");
         
     | 
| 
      
 24658 
     | 
    
         
            +
                      statementsToExecute.push(
         
     | 
| 
      
 24659 
     | 
    
         
            +
                        ...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
         
     | 
| 
      
 24660 
     | 
    
         
            +
                      );
         
     | 
| 
      
 24661 
     | 
    
         
            +
                    } else if (statement.type === "sqlite_alter_table_add_column" && (statement.column.notNull && !statement.column.default)) {
         
     | 
| 
      
 24662 
     | 
    
         
            +
                      const tableName = statement.tableName;
         
     | 
| 
      
 24663 
     | 
    
         
            +
                      const columnName = statement.column.name;
         
     | 
| 
      
 24664 
     | 
    
         
            +
                      const res = await connection.query(
         
     | 
| 
      
 24665 
     | 
    
         
            +
                        `select count(*) as count from \`${tableName}\``
         
     | 
| 
      
 24666 
     | 
    
         
            +
                      );
         
     | 
| 
      
 24667 
     | 
    
         
            +
                      const count = Number(res[0].count);
         
     | 
| 
      
 24668 
     | 
    
         
            +
                      if (count > 0) {
         
     | 
| 
      
 24669 
     | 
    
         
            +
                        infoToPrint.push(
         
     | 
| 
      
 24670 
     | 
    
         
            +
                          `\xB7 You're about to add not-null ${source_default.underline(
         
     | 
| 
      
 24671 
     | 
    
         
            +
                            columnName
         
     | 
| 
      
 24672 
     | 
    
         
            +
                          )} column without default value, which contains ${count} items`
         
     | 
| 
      
 24673 
     | 
    
         
            +
                        );
         
     | 
| 
      
 24674 
     | 
    
         
            +
                        tablesToTruncate.push(tableName);
         
     | 
| 
      
 24675 
     | 
    
         
            +
                        statementsToExecute.push(`delete from ${tableName};`);
         
     | 
| 
      
 24676 
     | 
    
         
            +
                        shouldAskForApprove = true;
         
     | 
| 
      
 24677 
     | 
    
         
            +
                      }
         
     | 
| 
      
 24678 
     | 
    
         
            +
                      const fromJsonStatement = fromJson([statement], "sqlite", "push");
         
     | 
| 
      
 24679 
     | 
    
         
            +
                      statementsToExecute.push(
         
     | 
| 
      
 24680 
     | 
    
         
            +
                        ...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
         
     | 
| 
      
 24681 
     | 
    
         
            +
                      );
         
     | 
| 
      
 24682 
     | 
    
         
            +
                    } else if (statement.type === "recreate_table") {
         
     | 
| 
      
 24683 
     | 
    
         
            +
                      const tableName = statement.tableName;
         
     | 
| 
      
 24684 
     | 
    
         
            +
                      const oldTableName = getOldTableName(tableName, meta);
         
     | 
| 
      
 24685 
     | 
    
         
            +
                      let dataLoss = false;
         
     | 
| 
      
 24686 
     | 
    
         
            +
                      const prevColumnNames = Object.keys(json1.tables[oldTableName].columns);
         
     | 
| 
      
 24687 
     | 
    
         
            +
                      const currentColumnNames = Object.keys(json2.tables[tableName].columns);
         
     | 
| 
      
 24688 
     | 
    
         
            +
                      const { removedColumns, addedColumns } = findAddedAndRemoved(
         
     | 
| 
      
 24689 
     | 
    
         
            +
                        prevColumnNames,
         
     | 
| 
      
 24690 
     | 
    
         
            +
                        currentColumnNames
         
     | 
| 
      
 24691 
     | 
    
         
            +
                      );
         
     | 
| 
      
 24692 
     | 
    
         
            +
                      if (removedColumns.length) {
         
     | 
| 
      
 24693 
     | 
    
         
            +
                        for (const removedColumn of removedColumns) {
         
     | 
| 
      
 24694 
     | 
    
         
            +
                          const res = await connection.query(
         
     | 
| 
      
 24695 
     | 
    
         
            +
                            `select count(\`${tableName}\`.\`${removedColumn}\`) as count from \`${tableName}\``
         
     | 
| 
      
 24696 
     | 
    
         
            +
                          );
         
     | 
| 
      
 24697 
     | 
    
         
            +
                          const count = Number(res[0].count);
         
     | 
| 
      
 24698 
     | 
    
         
            +
                          if (count > 0) {
         
     | 
| 
      
 24699 
     | 
    
         
            +
                            infoToPrint.push(
         
     | 
| 
      
 24700 
     | 
    
         
            +
                              `\xB7 You're about to delete ${source_default.underline(
         
     | 
| 
      
 24701 
     | 
    
         
            +
                                removedColumn
         
     | 
| 
      
 24702 
     | 
    
         
            +
                              )} column in ${tableName} table with ${count} items`
         
     | 
| 
      
 24703 
     | 
    
         
            +
                            );
         
     | 
| 
      
 24704 
     | 
    
         
            +
                            columnsToRemove.push(removedColumn);
         
     | 
| 
      
 24705 
     | 
    
         
            +
                            shouldAskForApprove = true;
         
     | 
| 
      
 24706 
     | 
    
         
            +
                          }
         
     | 
| 
      
 24707 
     | 
    
         
            +
                        }
         
     | 
| 
      
 24708 
     | 
    
         
            +
                      }
         
     | 
| 
      
 24709 
     | 
    
         
            +
                      if (addedColumns.length) {
         
     | 
| 
      
 24710 
     | 
    
         
            +
                        for (const addedColumn of addedColumns) {
         
     | 
| 
      
 24711 
     | 
    
         
            +
                          const [res] = await connection.query(
         
     | 
| 
      
 24712 
     | 
    
         
            +
                            `select count(*) as count from \`${tableName}\``
         
     | 
| 
      
 24713 
     | 
    
         
            +
                          );
         
     | 
| 
      
 24714 
     | 
    
         
            +
                          const columnConf = json2.tables[tableName].columns[addedColumn];
         
     | 
| 
      
 24715 
     | 
    
         
            +
                          const count = Number(res.count);
         
     | 
| 
      
 24716 
     | 
    
         
            +
                          if (count > 0 && columnConf.notNull && !columnConf.default) {
         
     | 
| 
      
 24717 
     | 
    
         
            +
                            dataLoss = true;
         
     | 
| 
      
 24718 
     | 
    
         
            +
                            infoToPrint.push(
         
     | 
| 
      
 24719 
     | 
    
         
            +
                              `\xB7 You're about to add not-null ${source_default.underline(
         
     | 
| 
      
 24720 
     | 
    
         
            +
                                addedColumn
         
     | 
| 
      
 24721 
     | 
    
         
            +
                              )} column without default value to table, which contains ${count} items`
         
     | 
| 
      
 24722 
     | 
    
         
            +
                            );
         
     | 
| 
      
 24723 
     | 
    
         
            +
                            shouldAskForApprove = true;
         
     | 
| 
      
 24724 
     | 
    
         
            +
                            tablesToTruncate.push(tableName);
         
     | 
| 
      
 24725 
     | 
    
         
            +
                            statementsToExecute.push(`DELETE FROM \`${tableName}\`;`);
         
     | 
| 
      
 24726 
     | 
    
         
            +
                          }
         
     | 
| 
      
 24727 
     | 
    
         
            +
                        }
         
     | 
| 
      
 24728 
     | 
    
         
            +
                      }
         
     | 
| 
      
 24729 
     | 
    
         
            +
                      const tablesReferencingCurrent = [];
         
     | 
| 
      
 24730 
     | 
    
         
            +
                      for (const table4 of Object.values(json2.tables)) {
         
     | 
| 
      
 24731 
     | 
    
         
            +
                        const tablesRefs = Object.values(json2.tables[table4.name].foreignKeys).filter((t2) => SQLiteSquasher.unsquashPushFK(t2).tableTo === tableName).map((it) => SQLiteSquasher.unsquashPushFK(it).tableFrom);
         
     | 
| 
      
 24732 
     | 
    
         
            +
                        tablesReferencingCurrent.push(...tablesRefs);
         
     | 
| 
      
 24733 
     | 
    
         
            +
                      }
         
     | 
| 
      
 24734 
     | 
    
         
            +
                      if (!tablesReferencingCurrent.length) {
         
     | 
| 
      
 24735 
     | 
    
         
            +
                        statementsToExecute.push(..._moveDataStatements(tableName, json2, dataLoss));
         
     | 
| 
      
 24736 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 24737 
     | 
    
         
            +
                      }
         
     | 
| 
      
 24738 
     | 
    
         
            +
                      const [{ foreign_keys: pragmaState }] = await connection.query(`PRAGMA foreign_keys;`);
         
     | 
| 
      
 24739 
     | 
    
         
            +
                      if (pragmaState) {
         
     | 
| 
      
 24740 
     | 
    
         
            +
                        statementsToExecute.push(`PRAGMA foreign_keys=OFF;`);
         
     | 
| 
      
 24741 
     | 
    
         
            +
                      }
         
     | 
| 
      
 24742 
     | 
    
         
            +
                      statementsToExecute.push(..._moveDataStatements(tableName, json2, dataLoss));
         
     | 
| 
      
 24743 
     | 
    
         
            +
                      if (pragmaState) {
         
     | 
| 
      
 24744 
     | 
    
         
            +
                        statementsToExecute.push(`PRAGMA foreign_keys=ON;`);
         
     | 
| 
      
 24745 
     | 
    
         
            +
                      }
         
     | 
| 
      
 24746 
     | 
    
         
            +
                    } else {
         
     | 
| 
      
 24747 
     | 
    
         
            +
                      const fromJsonStatement = fromJson([statement], "sqlite", "push");
         
     | 
| 
      
 24748 
     | 
    
         
            +
                      statementsToExecute.push(
         
     | 
| 
      
 24749 
     | 
    
         
            +
                        ...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
         
     | 
| 
      
 24750 
     | 
    
         
            +
                      );
         
     | 
| 
      
 24751 
     | 
    
         
            +
                    }
         
     | 
| 
      
 24752 
     | 
    
         
            +
                  }
         
     | 
| 
      
 24753 
     | 
    
         
            +
                  return {
         
     | 
| 
      
 24754 
     | 
    
         
            +
                    statementsToExecute,
         
     | 
| 
      
 24755 
     | 
    
         
            +
                    shouldAskForApprove,
         
     | 
| 
      
 24756 
     | 
    
         
            +
                    infoToPrint,
         
     | 
| 
      
 24757 
     | 
    
         
            +
                    columnsToRemove: [...new Set(columnsToRemove)],
         
     | 
| 
      
 24758 
     | 
    
         
            +
                    schemasToRemove: [...new Set(schemasToRemove)],
         
     | 
| 
      
 24759 
     | 
    
         
            +
                    tablesToTruncate: [...new Set(tablesToTruncate)],
         
     | 
| 
      
 24760 
     | 
    
         
            +
                    tablesToRemove: [...new Set(tablesToRemove)]
         
     | 
| 
      
 24761 
     | 
    
         
            +
                  };
         
     | 
| 
      
 24762 
     | 
    
         
            +
                };
         
     | 
| 
      
 24763 
     | 
    
         
            +
              }
         
     | 
| 
      
 24764 
     | 
    
         
            +
            });
         
     | 
| 
      
 24765 
     | 
    
         
            +
             
     | 
| 
       24621 
24766 
     | 
    
         
             
            // src/jsonStatements.ts
         
     | 
| 
       24622 
     | 
    
         
            -
            var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql;
         
     | 
| 
      
 24767 
     | 
    
         
            +
            var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareLibSQLCreateReferencesJson, prepareDropReferencesJson, prepareLibSQLDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql;
         
     | 
| 
       24623 
24768 
     | 
    
         
             
            var init_jsonStatements = __esm({
         
     | 
| 
       24624 
24769 
     | 
    
         
             
              "src/jsonStatements.ts"() {
         
     | 
| 
       24625 
24770 
     | 
    
         
             
                "use strict";
         
     | 
| 
       24626 
24771 
     | 
    
         
             
                init_source();
         
     | 
| 
      
 24772 
     | 
    
         
            +
                init_sqlitePushUtils();
         
     | 
| 
       24627 
24773 
     | 
    
         
             
                init_views();
         
     | 
| 
       24628 
24774 
     | 
    
         
             
                init_mysqlSchema();
         
     | 
| 
       24629 
24775 
     | 
    
         
             
                init_pgSchema();
         
     | 
| 
         @@ -25397,7 +25543,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25397 
25543 
     | 
    
         
             
                  return [...dropPkStatements, ...setPkStatements, ...statements];
         
     | 
| 
       25398 
25544 
     | 
    
         
             
                };
         
     | 
| 
       25399 
25545 
     | 
    
         
             
                prepareSqliteAlterColumns = (tableName, schema5, columns, json2) => {
         
     | 
| 
       25400 
     | 
    
         
            -
                  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
         
     | 
| 
      
 25546 
     | 
    
         
            +
                  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
         
     | 
| 
       25401 
25547 
     | 
    
         
             
                  let statements = [];
         
     | 
| 
       25402 
25548 
     | 
    
         
             
                  let dropPkStatements = [];
         
     | 
| 
       25403 
25549 
     | 
    
         
             
                  let setPkStatements = [];
         
     | 
| 
         @@ -25411,6 +25557,49 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25411 
25557 
     | 
    
         
             
                    const columnPk = json2.tables[tableName].columns[columnName].primaryKey;
         
     | 
| 
       25412 
25558 
     | 
    
         
             
                    const columnGenerated = json2.tables[tableName].columns[columnName].generated;
         
     | 
| 
       25413 
25559 
     | 
    
         
             
                    const compositePk = json2.tables[tableName].compositePrimaryKeys[`${tableName}_${columnName}`];
         
     | 
| 
      
 25560 
     | 
    
         
            +
                    if (((_a = column7.autoincrement) == null ? void 0 : _a.type) === "added") {
         
     | 
| 
      
 25561 
     | 
    
         
            +
                      statements.push({
         
     | 
| 
      
 25562 
     | 
    
         
            +
                        type: "alter_table_alter_column_set_autoincrement",
         
     | 
| 
      
 25563 
     | 
    
         
            +
                        tableName,
         
     | 
| 
      
 25564 
     | 
    
         
            +
                        columnName,
         
     | 
| 
      
 25565 
     | 
    
         
            +
                        schema: schema5,
         
     | 
| 
      
 25566 
     | 
    
         
            +
                        newDataType: columnType,
         
     | 
| 
      
 25567 
     | 
    
         
            +
                        columnDefault,
         
     | 
| 
      
 25568 
     | 
    
         
            +
                        columnOnUpdate,
         
     | 
| 
      
 25569 
     | 
    
         
            +
                        columnNotNull,
         
     | 
| 
      
 25570 
     | 
    
         
            +
                        columnAutoIncrement,
         
     | 
| 
      
 25571 
     | 
    
         
            +
                        columnPk
         
     | 
| 
      
 25572 
     | 
    
         
            +
                      });
         
     | 
| 
      
 25573 
     | 
    
         
            +
                    }
         
     | 
| 
      
 25574 
     | 
    
         
            +
                    if (((_b = column7.autoincrement) == null ? void 0 : _b.type) === "changed") {
         
     | 
| 
      
 25575 
     | 
    
         
            +
                      const type = column7.autoincrement.new ? "alter_table_alter_column_set_autoincrement" : "alter_table_alter_column_drop_autoincrement";
         
     | 
| 
      
 25576 
     | 
    
         
            +
                      statements.push({
         
     | 
| 
      
 25577 
     | 
    
         
            +
                        type,
         
     | 
| 
      
 25578 
     | 
    
         
            +
                        tableName,
         
     | 
| 
      
 25579 
     | 
    
         
            +
                        columnName,
         
     | 
| 
      
 25580 
     | 
    
         
            +
                        schema: schema5,
         
     | 
| 
      
 25581 
     | 
    
         
            +
                        newDataType: columnType,
         
     | 
| 
      
 25582 
     | 
    
         
            +
                        columnDefault,
         
     | 
| 
      
 25583 
     | 
    
         
            +
                        columnOnUpdate,
         
     | 
| 
      
 25584 
     | 
    
         
            +
                        columnNotNull,
         
     | 
| 
      
 25585 
     | 
    
         
            +
                        columnAutoIncrement,
         
     | 
| 
      
 25586 
     | 
    
         
            +
                        columnPk
         
     | 
| 
      
 25587 
     | 
    
         
            +
                      });
         
     | 
| 
      
 25588 
     | 
    
         
            +
                    }
         
     | 
| 
      
 25589 
     | 
    
         
            +
                    if (((_c = column7.autoincrement) == null ? void 0 : _c.type) === "deleted") {
         
     | 
| 
      
 25590 
     | 
    
         
            +
                      statements.push({
         
     | 
| 
      
 25591 
     | 
    
         
            +
                        type: "alter_table_alter_column_drop_autoincrement",
         
     | 
| 
      
 25592 
     | 
    
         
            +
                        tableName,
         
     | 
| 
      
 25593 
     | 
    
         
            +
                        columnName,
         
     | 
| 
      
 25594 
     | 
    
         
            +
                        schema: schema5,
         
     | 
| 
      
 25595 
     | 
    
         
            +
                        newDataType: columnType,
         
     | 
| 
      
 25596 
     | 
    
         
            +
                        columnDefault,
         
     | 
| 
      
 25597 
     | 
    
         
            +
                        columnOnUpdate,
         
     | 
| 
      
 25598 
     | 
    
         
            +
                        columnNotNull,
         
     | 
| 
      
 25599 
     | 
    
         
            +
                        columnAutoIncrement,
         
     | 
| 
      
 25600 
     | 
    
         
            +
                        columnPk
         
     | 
| 
      
 25601 
     | 
    
         
            +
                      });
         
     | 
| 
      
 25602 
     | 
    
         
            +
                    }
         
     | 
| 
       25414 
25603 
     | 
    
         
             
                    if (typeof column7.name !== "string") {
         
     | 
| 
       25415 
25604 
     | 
    
         
             
                      statements.push({
         
     | 
| 
       25416 
25605 
     | 
    
         
             
                        type: "alter_table_rename_column",
         
     | 
| 
         @@ -25420,7 +25609,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25420 
25609 
     | 
    
         
             
                        schema: schema5
         
     | 
| 
       25421 
25610 
     | 
    
         
             
                      });
         
     | 
| 
       25422 
25611 
     | 
    
         
             
                    }
         
     | 
| 
       25423 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25612 
     | 
    
         
            +
                    if (((_d = column7.type) == null ? void 0 : _d.type) === "changed") {
         
     | 
| 
       25424 
25613 
     | 
    
         
             
                      statements.push({
         
     | 
| 
       25425 
25614 
     | 
    
         
             
                        type: "alter_table_alter_column_set_type",
         
     | 
| 
       25426 
25615 
     | 
    
         
             
                        tableName,
         
     | 
| 
         @@ -25435,7 +25624,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25435 
25624 
     | 
    
         
             
                        columnPk
         
     | 
| 
       25436 
25625 
     | 
    
         
             
                      });
         
     | 
| 
       25437 
25626 
     | 
    
         
             
                    }
         
     | 
| 
       25438 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25627 
     | 
    
         
            +
                    if (((_e = column7.primaryKey) == null ? void 0 : _e.type) === "deleted" || ((_f = column7.primaryKey) == null ? void 0 : _f.type) === "changed" && !column7.primaryKey.new && typeof compositePk === "undefined") {
         
     | 
| 
       25439 
25628 
     | 
    
         
             
                      dropPkStatements.push({
         
     | 
| 
       25440 
25629 
     | 
    
         
             
                        ////
         
     | 
| 
       25441 
25630 
     | 
    
         
             
                        type: "alter_table_alter_column_drop_pk",
         
     | 
| 
         @@ -25444,7 +25633,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25444 
25633 
     | 
    
         
             
                        schema: schema5
         
     | 
| 
       25445 
25634 
     | 
    
         
             
                      });
         
     | 
| 
       25446 
25635 
     | 
    
         
             
                    }
         
     | 
| 
       25447 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25636 
     | 
    
         
            +
                    if (((_g = column7.default) == null ? void 0 : _g.type) === "added") {
         
     | 
| 
       25448 
25637 
     | 
    
         
             
                      statements.push({
         
     | 
| 
       25449 
25638 
     | 
    
         
             
                        type: "alter_table_alter_column_set_default",
         
     | 
| 
       25450 
25639 
     | 
    
         
             
                        tableName,
         
     | 
| 
         @@ -25458,7 +25647,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25458 
25647 
     | 
    
         
             
                        columnPk
         
     | 
| 
       25459 
25648 
     | 
    
         
             
                      });
         
     | 
| 
       25460 
25649 
     | 
    
         
             
                    }
         
     | 
| 
       25461 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25650 
     | 
    
         
            +
                    if (((_h = column7.default) == null ? void 0 : _h.type) === "changed") {
         
     | 
| 
       25462 
25651 
     | 
    
         
             
                      statements.push({
         
     | 
| 
       25463 
25652 
     | 
    
         
             
                        type: "alter_table_alter_column_set_default",
         
     | 
| 
       25464 
25653 
     | 
    
         
             
                        tableName,
         
     | 
| 
         @@ -25473,7 +25662,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25473 
25662 
     | 
    
         
             
                        columnPk
         
     | 
| 
       25474 
25663 
     | 
    
         
             
                      });
         
     | 
| 
       25475 
25664 
     | 
    
         
             
                    }
         
     | 
| 
       25476 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25665 
     | 
    
         
            +
                    if (((_i = column7.default) == null ? void 0 : _i.type) === "deleted") {
         
     | 
| 
       25477 
25666 
     | 
    
         
             
                      statements.push({
         
     | 
| 
       25478 
25667 
     | 
    
         
             
                        type: "alter_table_alter_column_drop_default",
         
     | 
| 
       25479 
25668 
     | 
    
         
             
                        tableName,
         
     | 
| 
         @@ -25487,7 +25676,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25487 
25676 
     | 
    
         
             
                        columnPk
         
     | 
| 
       25488 
25677 
     | 
    
         
             
                      });
         
     | 
| 
       25489 
25678 
     | 
    
         
             
                    }
         
     | 
| 
       25490 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25679 
     | 
    
         
            +
                    if (((_j = column7.notNull) == null ? void 0 : _j.type) === "added") {
         
     | 
| 
       25491 
25680 
     | 
    
         
             
                      statements.push({
         
     | 
| 
       25492 
25681 
     | 
    
         
             
                        type: "alter_table_alter_column_set_notnull",
         
     | 
| 
       25493 
25682 
     | 
    
         
             
                        tableName,
         
     | 
| 
         @@ -25501,7 +25690,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25501 
25690 
     | 
    
         
             
                        columnPk
         
     | 
| 
       25502 
25691 
     | 
    
         
             
                      });
         
     | 
| 
       25503 
25692 
     | 
    
         
             
                    }
         
     | 
| 
       25504 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25693 
     | 
    
         
            +
                    if (((_k = column7.notNull) == null ? void 0 : _k.type) === "changed") {
         
     | 
| 
       25505 
25694 
     | 
    
         
             
                      const type = column7.notNull.new ? "alter_table_alter_column_set_notnull" : "alter_table_alter_column_drop_notnull";
         
     | 
| 
       25506 
25695 
     | 
    
         
             
                      statements.push({
         
     | 
| 
       25507 
25696 
     | 
    
         
             
                        type,
         
     | 
| 
         @@ -25516,7 +25705,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25516 
25705 
     | 
    
         
             
                        columnPk
         
     | 
| 
       25517 
25706 
     | 
    
         
             
                      });
         
     | 
| 
       25518 
25707 
     | 
    
         
             
                    }
         
     | 
| 
       25519 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25708 
     | 
    
         
            +
                    if (((_l = column7.notNull) == null ? void 0 : _l.type) === "deleted") {
         
     | 
| 
       25520 
25709 
     | 
    
         
             
                      statements.push({
         
     | 
| 
       25521 
25710 
     | 
    
         
             
                        type: "alter_table_alter_column_drop_notnull",
         
     | 
| 
       25522 
25711 
     | 
    
         
             
                        tableName,
         
     | 
| 
         @@ -25530,7 +25719,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25530 
25719 
     | 
    
         
             
                        columnPk
         
     | 
| 
       25531 
25720 
     | 
    
         
             
                      });
         
     | 
| 
       25532 
25721 
     | 
    
         
             
                    }
         
     | 
| 
       25533 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25722 
     | 
    
         
            +
                    if (((_m = column7.generated) == null ? void 0 : _m.type) === "added") {
         
     | 
| 
       25534 
25723 
     | 
    
         
             
                      if ((columnGenerated == null ? void 0 : columnGenerated.type) === "virtual") {
         
     | 
| 
       25535 
25724 
     | 
    
         
             
                        statements.push({
         
     | 
| 
       25536 
25725 
     | 
    
         
             
                          type: "alter_table_alter_column_set_generated",
         
     | 
| 
         @@ -25551,7 +25740,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25551 
25740 
     | 
    
         
             
                        );
         
     | 
| 
       25552 
25741 
     | 
    
         
             
                      }
         
     | 
| 
       25553 
25742 
     | 
    
         
             
                    }
         
     | 
| 
       25554 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25743 
     | 
    
         
            +
                    if (((_n = column7.generated) == null ? void 0 : _n.type) === "changed") {
         
     | 
| 
       25555 
25744 
     | 
    
         
             
                      if ((columnGenerated == null ? void 0 : columnGenerated.type) === "virtual") {
         
     | 
| 
       25556 
25745 
     | 
    
         
             
                        statements.push({
         
     | 
| 
       25557 
25746 
     | 
    
         
             
                          type: "alter_table_alter_column_alter_generated",
         
     | 
| 
         @@ -25572,7 +25761,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25572 
25761 
     | 
    
         
             
                        );
         
     | 
| 
       25573 
25762 
     | 
    
         
             
                      }
         
     | 
| 
       25574 
25763 
     | 
    
         
             
                    }
         
     | 
| 
       25575 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25764 
     | 
    
         
            +
                    if (((_o = column7.generated) == null ? void 0 : _o.type) === "deleted") {
         
     | 
| 
       25576 
25765 
     | 
    
         
             
                      statements.push({
         
     | 
| 
       25577 
25766 
     | 
    
         
             
                        type: "alter_table_alter_column_drop_generated",
         
     | 
| 
       25578 
25767 
     | 
    
         
             
                        tableName,
         
     | 
| 
         @@ -25587,7 +25776,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25587 
25776 
     | 
    
         
             
                        columnGenerated
         
     | 
| 
       25588 
25777 
     | 
    
         
             
                      });
         
     | 
| 
       25589 
25778 
     | 
    
         
             
                    }
         
     | 
| 
       25590 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25779 
     | 
    
         
            +
                    if (((_p = column7.primaryKey) == null ? void 0 : _p.type) === "added" || ((_q = column7.primaryKey) == null ? void 0 : _q.type) === "changed" && column7.primaryKey.new) {
         
     | 
| 
       25591 
25780 
     | 
    
         
             
                      const wasAutoincrement = statements.filter(
         
     | 
| 
       25592 
25781 
     | 
    
         
             
                        (it) => it.type === "alter_table_alter_column_set_autoincrement"
         
     | 
| 
       25593 
25782 
     | 
    
         
             
                      );
         
     | 
| 
         @@ -25600,7 +25789,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25600 
25789 
     | 
    
         
             
                        });
         
     | 
| 
       25601 
25790 
     | 
    
         
             
                      }
         
     | 
| 
       25602 
25791 
     | 
    
         
             
                    }
         
     | 
| 
       25603 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25792 
     | 
    
         
            +
                    if (((_r = column7.onUpdate) == null ? void 0 : _r.type) === "added") {
         
     | 
| 
       25604 
25793 
     | 
    
         
             
                      statements.push({
         
     | 
| 
       25605 
25794 
     | 
    
         
             
                        type: "alter_table_alter_column_set_on_update",
         
     | 
| 
       25606 
25795 
     | 
    
         
             
                        tableName,
         
     | 
| 
         @@ -25614,7 +25803,7 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25614 
25803 
     | 
    
         
             
                        columnPk
         
     | 
| 
       25615 
25804 
     | 
    
         
             
                      });
         
     | 
| 
       25616 
25805 
     | 
    
         
             
                    }
         
     | 
| 
       25617 
     | 
    
         
            -
                    if ((( 
     | 
| 
      
 25806 
     | 
    
         
            +
                    if (((_s = column7.onUpdate) == null ? void 0 : _s.type) === "deleted") {
         
     | 
| 
       25618 
25807 
     | 
    
         
             
                      statements.push({
         
     | 
| 
       25619 
25808 
     | 
    
         
             
                        type: "alter_table_alter_column_drop_on_update",
         
     | 
| 
       25620 
25809 
     | 
    
         
             
                        tableName,
         
     | 
| 
         @@ -25674,6 +25863,37 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25674 
25863 
     | 
    
         
             
                    };
         
     | 
| 
       25675 
25864 
     | 
    
         
             
                  });
         
     | 
| 
       25676 
25865 
     | 
    
         
             
                };
         
     | 
| 
      
 25866 
     | 
    
         
            +
                prepareLibSQLCreateReferencesJson = (tableName, schema5, foreignKeys, json2, action) => {
         
     | 
| 
      
 25867 
     | 
    
         
            +
                  return Object.values(foreignKeys).map((fkData) => {
         
     | 
| 
      
 25868 
     | 
    
         
            +
                    const { columnsFrom, tableFrom, columnsTo } = action === "push" ? SQLiteSquasher.unsquashPushFK(fkData) : SQLiteSquasher.unsquashFK(fkData);
         
     | 
| 
      
 25869 
     | 
    
         
            +
                    let isMulticolumn = false;
         
     | 
| 
      
 25870 
     | 
    
         
            +
                    if (columnsFrom.length > 1 || columnsTo.length > 1) {
         
     | 
| 
      
 25871 
     | 
    
         
            +
                      isMulticolumn = true;
         
     | 
| 
      
 25872 
     | 
    
         
            +
                      return {
         
     | 
| 
      
 25873 
     | 
    
         
            +
                        type: "create_reference",
         
     | 
| 
      
 25874 
     | 
    
         
            +
                        tableName,
         
     | 
| 
      
 25875 
     | 
    
         
            +
                        data: fkData,
         
     | 
| 
      
 25876 
     | 
    
         
            +
                        schema: schema5,
         
     | 
| 
      
 25877 
     | 
    
         
            +
                        isMulticolumn
         
     | 
| 
      
 25878 
     | 
    
         
            +
                      };
         
     | 
| 
      
 25879 
     | 
    
         
            +
                    }
         
     | 
| 
      
 25880 
     | 
    
         
            +
                    const columnFrom = columnsFrom[0];
         
     | 
| 
      
 25881 
     | 
    
         
            +
                    const {
         
     | 
| 
      
 25882 
     | 
    
         
            +
                      notNull: columnNotNull,
         
     | 
| 
      
 25883 
     | 
    
         
            +
                      default: columnDefault,
         
     | 
| 
      
 25884 
     | 
    
         
            +
                      type: columnType
         
     | 
| 
      
 25885 
     | 
    
         
            +
                    } = json2.tables[tableFrom].columns[columnFrom];
         
     | 
| 
      
 25886 
     | 
    
         
            +
                    return {
         
     | 
| 
      
 25887 
     | 
    
         
            +
                      type: "create_reference",
         
     | 
| 
      
 25888 
     | 
    
         
            +
                      tableName,
         
     | 
| 
      
 25889 
     | 
    
         
            +
                      data: fkData,
         
     | 
| 
      
 25890 
     | 
    
         
            +
                      schema: schema5,
         
     | 
| 
      
 25891 
     | 
    
         
            +
                      columnNotNull,
         
     | 
| 
      
 25892 
     | 
    
         
            +
                      columnDefault,
         
     | 
| 
      
 25893 
     | 
    
         
            +
                      columnType
         
     | 
| 
      
 25894 
     | 
    
         
            +
                    };
         
     | 
| 
      
 25895 
     | 
    
         
            +
                  });
         
     | 
| 
      
 25896 
     | 
    
         
            +
                };
         
     | 
| 
       25677 
25897 
     | 
    
         
             
                prepareDropReferencesJson = (tableName, schema5, foreignKeys) => {
         
     | 
| 
       25678 
25898 
     | 
    
         
             
                  return Object.values(foreignKeys).map((fkData) => {
         
     | 
| 
       25679 
25899 
     | 
    
         
             
                    return {
         
     | 
| 
         @@ -25684,6 +25904,54 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25684 
25904 
     | 
    
         
             
                    };
         
     | 
| 
       25685 
25905 
     | 
    
         
             
                  });
         
     | 
| 
       25686 
25906 
     | 
    
         
             
                };
         
     | 
| 
      
 25907 
     | 
    
         
            +
                prepareLibSQLDropReferencesJson = (tableName, schema5, foreignKeys, json2, meta, action) => {
         
     | 
| 
      
 25908 
     | 
    
         
            +
                  const statements = Object.values(foreignKeys).map((fkData) => {
         
     | 
| 
      
 25909 
     | 
    
         
            +
                    const { columnsFrom, tableFrom, columnsTo, name, tableTo, onDelete, onUpdate } = action === "push" ? SQLiteSquasher.unsquashPushFK(fkData) : SQLiteSquasher.unsquashFK(fkData);
         
     | 
| 
      
 25910 
     | 
    
         
            +
                    const keys = Object.keys(json2.tables[tableName].columns);
         
     | 
| 
      
 25911 
     | 
    
         
            +
                    const filtered = columnsFrom.filter((it) => keys.includes(it));
         
     | 
| 
      
 25912 
     | 
    
         
            +
                    const fullDrop = filtered.length === 0;
         
     | 
| 
      
 25913 
     | 
    
         
            +
                    if (fullDrop)
         
     | 
| 
      
 25914 
     | 
    
         
            +
                      return;
         
     | 
| 
      
 25915 
     | 
    
         
            +
                    let isMulticolumn = false;
         
     | 
| 
      
 25916 
     | 
    
         
            +
                    if (columnsFrom.length > 1 || columnsTo.length > 1) {
         
     | 
| 
      
 25917 
     | 
    
         
            +
                      isMulticolumn = true;
         
     | 
| 
      
 25918 
     | 
    
         
            +
                      return {
         
     | 
| 
      
 25919 
     | 
    
         
            +
                        type: "delete_reference",
         
     | 
| 
      
 25920 
     | 
    
         
            +
                        tableName,
         
     | 
| 
      
 25921 
     | 
    
         
            +
                        data: fkData,
         
     | 
| 
      
 25922 
     | 
    
         
            +
                        schema: schema5,
         
     | 
| 
      
 25923 
     | 
    
         
            +
                        isMulticolumn
         
     | 
| 
      
 25924 
     | 
    
         
            +
                      };
         
     | 
| 
      
 25925 
     | 
    
         
            +
                    }
         
     | 
| 
      
 25926 
     | 
    
         
            +
                    const columnFrom = columnsFrom[0];
         
     | 
| 
      
 25927 
     | 
    
         
            +
                    const newTableName = getNewTableName(tableFrom, meta);
         
     | 
| 
      
 25928 
     | 
    
         
            +
                    const {
         
     | 
| 
      
 25929 
     | 
    
         
            +
                      notNull: columnNotNull,
         
     | 
| 
      
 25930 
     | 
    
         
            +
                      default: columnDefault,
         
     | 
| 
      
 25931 
     | 
    
         
            +
                      type: columnType
         
     | 
| 
      
 25932 
     | 
    
         
            +
                    } = json2.tables[newTableName].columns[columnFrom];
         
     | 
| 
      
 25933 
     | 
    
         
            +
                    const fkToSquash = {
         
     | 
| 
      
 25934 
     | 
    
         
            +
                      columnsFrom,
         
     | 
| 
      
 25935 
     | 
    
         
            +
                      columnsTo,
         
     | 
| 
      
 25936 
     | 
    
         
            +
                      name,
         
     | 
| 
      
 25937 
     | 
    
         
            +
                      tableFrom: newTableName,
         
     | 
| 
      
 25938 
     | 
    
         
            +
                      tableTo,
         
     | 
| 
      
 25939 
     | 
    
         
            +
                      onDelete,
         
     | 
| 
      
 25940 
     | 
    
         
            +
                      onUpdate
         
     | 
| 
      
 25941 
     | 
    
         
            +
                    };
         
     | 
| 
      
 25942 
     | 
    
         
            +
                    const foreignKey = action === "push" ? SQLiteSquasher.squashPushFK(fkToSquash) : SQLiteSquasher.squashFK(fkToSquash);
         
     | 
| 
      
 25943 
     | 
    
         
            +
                    return {
         
     | 
| 
      
 25944 
     | 
    
         
            +
                      type: "delete_reference",
         
     | 
| 
      
 25945 
     | 
    
         
            +
                      tableName,
         
     | 
| 
      
 25946 
     | 
    
         
            +
                      data: foreignKey,
         
     | 
| 
      
 25947 
     | 
    
         
            +
                      schema: schema5,
         
     | 
| 
      
 25948 
     | 
    
         
            +
                      columnNotNull,
         
     | 
| 
      
 25949 
     | 
    
         
            +
                      columnDefault,
         
     | 
| 
      
 25950 
     | 
    
         
            +
                      columnType
         
     | 
| 
      
 25951 
     | 
    
         
            +
                    };
         
     | 
| 
      
 25952 
     | 
    
         
            +
                  });
         
     | 
| 
      
 25953 
     | 
    
         
            +
                  return statements.filter((it) => it);
         
     | 
| 
      
 25954 
     | 
    
         
            +
                };
         
     | 
| 
       25687 
25955 
     | 
    
         
             
                prepareAlterReferencesJson = (tableName, schema5, foreignKeys) => {
         
     | 
| 
       25688 
25956 
     | 
    
         
             
                  const stmts = [];
         
     | 
| 
       25689 
25957 
     | 
    
         
             
                  Object.values(foreignKeys).map((val2) => {
         
     | 
| 
         @@ -25838,8 +26106,289 @@ var init_jsonStatements = __esm({ 
     | 
|
| 
       25838 
26106 
     | 
    
         
             
              }
         
     | 
| 
       25839 
26107 
     | 
    
         
             
            });
         
     | 
| 
       25840 
26108 
     | 
    
         | 
| 
      
 26109 
     | 
    
         
            +
            // src/statementCombiner.ts
         
     | 
| 
      
 26110 
     | 
    
         
            +
            var prepareLibSQLRecreateTable, prepareSQLiteRecreateTable, libSQLCombineStatements, sqliteCombineStatements;
         
     | 
| 
      
 26111 
     | 
    
         
            +
            var init_statementCombiner = __esm({
         
     | 
| 
      
 26112 
     | 
    
         
            +
              "src/statementCombiner.ts"() {
         
     | 
| 
      
 26113 
     | 
    
         
            +
                "use strict";
         
     | 
| 
      
 26114 
     | 
    
         
            +
                init_jsonStatements();
         
     | 
| 
      
 26115 
     | 
    
         
            +
                init_sqliteSchema();
         
     | 
| 
      
 26116 
     | 
    
         
            +
                prepareLibSQLRecreateTable = (table4, action) => {
         
     | 
| 
      
 26117 
     | 
    
         
            +
                  const { name, columns, uniqueConstraints, indexes } = table4;
         
     | 
| 
      
 26118 
     | 
    
         
            +
                  const composites = Object.values(table4.compositePrimaryKeys).map(
         
     | 
| 
      
 26119 
     | 
    
         
            +
                    (it) => SQLiteSquasher.unsquashPK(it)
         
     | 
| 
      
 26120 
     | 
    
         
            +
                  );
         
     | 
| 
      
 26121 
     | 
    
         
            +
                  const references2 = Object.values(table4.foreignKeys);
         
     | 
| 
      
 26122 
     | 
    
         
            +
                  const fks = references2.map(
         
     | 
| 
      
 26123 
     | 
    
         
            +
                    (it) => action === "push" ? SQLiteSquasher.unsquashPushFK(it) : SQLiteSquasher.unsquashFK(it)
         
     | 
| 
      
 26124 
     | 
    
         
            +
                  );
         
     | 
| 
      
 26125 
     | 
    
         
            +
                  const statements = [
         
     | 
| 
      
 26126 
     | 
    
         
            +
                    {
         
     | 
| 
      
 26127 
     | 
    
         
            +
                      type: "recreate_table",
         
     | 
| 
      
 26128 
     | 
    
         
            +
                      tableName: name,
         
     | 
| 
      
 26129 
     | 
    
         
            +
                      columns: Object.values(columns),
         
     | 
| 
      
 26130 
     | 
    
         
            +
                      compositePKs: composites,
         
     | 
| 
      
 26131 
     | 
    
         
            +
                      referenceData: fks,
         
     | 
| 
      
 26132 
     | 
    
         
            +
                      uniqueConstraints: Object.values(uniqueConstraints)
         
     | 
| 
      
 26133 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26134 
     | 
    
         
            +
                  ];
         
     | 
| 
      
 26135 
     | 
    
         
            +
                  if (Object.keys(indexes).length) {
         
     | 
| 
      
 26136 
     | 
    
         
            +
                    statements.push(...prepareCreateIndexesJson(name, "", indexes));
         
     | 
| 
      
 26137 
     | 
    
         
            +
                  }
         
     | 
| 
      
 26138 
     | 
    
         
            +
                  return statements;
         
     | 
| 
      
 26139 
     | 
    
         
            +
                };
         
     | 
| 
      
 26140 
     | 
    
         
            +
                prepareSQLiteRecreateTable = (table4, action) => {
         
     | 
| 
      
 26141 
     | 
    
         
            +
                  const { name, columns, uniqueConstraints, indexes } = table4;
         
     | 
| 
      
 26142 
     | 
    
         
            +
                  const composites = Object.values(table4.compositePrimaryKeys).map(
         
     | 
| 
      
 26143 
     | 
    
         
            +
                    (it) => SQLiteSquasher.unsquashPK(it)
         
     | 
| 
      
 26144 
     | 
    
         
            +
                  );
         
     | 
| 
      
 26145 
     | 
    
         
            +
                  const references2 = Object.values(table4.foreignKeys);
         
     | 
| 
      
 26146 
     | 
    
         
            +
                  const fks = references2.map(
         
     | 
| 
      
 26147 
     | 
    
         
            +
                    (it) => action === "push" ? SQLiteSquasher.unsquashPushFK(it) : SQLiteSquasher.unsquashFK(it)
         
     | 
| 
      
 26148 
     | 
    
         
            +
                  );
         
     | 
| 
      
 26149 
     | 
    
         
            +
                  const statements = [
         
     | 
| 
      
 26150 
     | 
    
         
            +
                    {
         
     | 
| 
      
 26151 
     | 
    
         
            +
                      type: "recreate_table",
         
     | 
| 
      
 26152 
     | 
    
         
            +
                      tableName: name,
         
     | 
| 
      
 26153 
     | 
    
         
            +
                      columns: Object.values(columns),
         
     | 
| 
      
 26154 
     | 
    
         
            +
                      compositePKs: composites,
         
     | 
| 
      
 26155 
     | 
    
         
            +
                      referenceData: fks,
         
     | 
| 
      
 26156 
     | 
    
         
            +
                      uniqueConstraints: Object.values(uniqueConstraints)
         
     | 
| 
      
 26157 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26158 
     | 
    
         
            +
                  ];
         
     | 
| 
      
 26159 
     | 
    
         
            +
                  if (Object.keys(indexes).length) {
         
     | 
| 
      
 26160 
     | 
    
         
            +
                    statements.push(...prepareCreateIndexesJson(name, "", indexes));
         
     | 
| 
      
 26161 
     | 
    
         
            +
                  }
         
     | 
| 
      
 26162 
     | 
    
         
            +
                  return statements;
         
     | 
| 
      
 26163 
     | 
    
         
            +
                };
         
     | 
| 
      
 26164 
     | 
    
         
            +
                libSQLCombineStatements = (statements, json2, action) => {
         
     | 
| 
      
 26165 
     | 
    
         
            +
                  const newStatements = {};
         
     | 
| 
      
 26166 
     | 
    
         
            +
                  for (const statement of statements) {
         
     | 
| 
      
 26167 
     | 
    
         
            +
                    if (statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_pk" || statement.type === "alter_table_alter_column_set_pk" || statement.type === "create_composite_pk" || statement.type === "alter_composite_pk" || statement.type === "delete_composite_pk") {
         
     | 
| 
      
 26168 
     | 
    
         
            +
                      const tableName2 = statement.tableName;
         
     | 
| 
      
 26169 
     | 
    
         
            +
                      const statementsForTable2 = newStatements[tableName2];
         
     | 
| 
      
 26170 
     | 
    
         
            +
                      if (!statementsForTable2) {
         
     | 
| 
      
 26171 
     | 
    
         
            +
                        newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26172 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26173 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26174 
     | 
    
         
            +
                      if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26175 
     | 
    
         
            +
                        const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         
     | 
| 
      
 26176 
     | 
    
         
            +
                        const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26177 
     | 
    
         
            +
                        if (wasRename) {
         
     | 
| 
      
 26178 
     | 
    
         
            +
                          newStatements[tableName2].push(...preparedStatements);
         
     | 
| 
      
 26179 
     | 
    
         
            +
                        } else {
         
     | 
| 
      
 26180 
     | 
    
         
            +
                          newStatements[tableName2] = preparedStatements;
         
     | 
| 
      
 26181 
     | 
    
         
            +
                        }
         
     | 
| 
      
 26182 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26183 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26184 
     | 
    
         
            +
                      continue;
         
     | 
| 
      
 26185 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26186 
     | 
    
         
            +
                    if (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default") {
         
     | 
| 
      
 26187 
     | 
    
         
            +
                      const { tableName: tableName2, columnName, columnPk } = statement;
         
     | 
| 
      
 26188 
     | 
    
         
            +
                      const columnIsPartOfForeignKey = Object.values(
         
     | 
| 
      
 26189 
     | 
    
         
            +
                        json2.tables[tableName2].foreignKeys
         
     | 
| 
      
 26190 
     | 
    
         
            +
                      ).some((it) => {
         
     | 
| 
      
 26191 
     | 
    
         
            +
                        const unsquashFk = action === "push" ? SQLiteSquasher.unsquashPushFK(it) : SQLiteSquasher.unsquashFK(it);
         
     | 
| 
      
 26192 
     | 
    
         
            +
                        return unsquashFk.columnsFrom.includes(columnName);
         
     | 
| 
      
 26193 
     | 
    
         
            +
                      });
         
     | 
| 
      
 26194 
     | 
    
         
            +
                      const statementsForTable2 = newStatements[tableName2];
         
     | 
| 
      
 26195 
     | 
    
         
            +
                      if (!statementsForTable2 && (columnIsPartOfForeignKey || columnPk)) {
         
     | 
| 
      
 26196 
     | 
    
         
            +
                        newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26197 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26198 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26199 
     | 
    
         
            +
                      if (statementsForTable2 && (columnIsPartOfForeignKey || columnPk)) {
         
     | 
| 
      
 26200 
     | 
    
         
            +
                        if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26201 
     | 
    
         
            +
                          const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         
     | 
| 
      
 26202 
     | 
    
         
            +
                          const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26203 
     | 
    
         
            +
                          if (wasRename) {
         
     | 
| 
      
 26204 
     | 
    
         
            +
                            newStatements[tableName2].push(...preparedStatements);
         
     | 
| 
      
 26205 
     | 
    
         
            +
                          } else {
         
     | 
| 
      
 26206 
     | 
    
         
            +
                            newStatements[tableName2] = preparedStatements;
         
     | 
| 
      
 26207 
     | 
    
         
            +
                          }
         
     | 
| 
      
 26208 
     | 
    
         
            +
                        }
         
     | 
| 
      
 26209 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26210 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26211 
     | 
    
         
            +
                      if (statementsForTable2 && !(columnIsPartOfForeignKey || columnPk)) {
         
     | 
| 
      
 26212 
     | 
    
         
            +
                        if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26213 
     | 
    
         
            +
                          newStatements[tableName2].push(statement);
         
     | 
| 
      
 26214 
     | 
    
         
            +
                        }
         
     | 
| 
      
 26215 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26216 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26217 
     | 
    
         
            +
                      newStatements[tableName2] = [statement];
         
     | 
| 
      
 26218 
     | 
    
         
            +
                      continue;
         
     | 
| 
      
 26219 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26220 
     | 
    
         
            +
                    if (statement.type === "create_reference") {
         
     | 
| 
      
 26221 
     | 
    
         
            +
                      const tableName2 = statement.tableName;
         
     | 
| 
      
 26222 
     | 
    
         
            +
                      const data = action === "push" ? SQLiteSquasher.unsquashPushFK(statement.data) : SQLiteSquasher.unsquashFK(statement.data);
         
     | 
| 
      
 26223 
     | 
    
         
            +
                      const statementsForTable2 = newStatements[tableName2];
         
     | 
| 
      
 26224 
     | 
    
         
            +
                      if (!statementsForTable2) {
         
     | 
| 
      
 26225 
     | 
    
         
            +
                        newStatements[tableName2] = statement.isMulticolumn ? prepareLibSQLRecreateTable(json2.tables[tableName2], action) : [statement];
         
     | 
| 
      
 26226 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26227 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26228 
     | 
    
         
            +
                      if (!statement.isMulticolumn && statementsForTable2.some(
         
     | 
| 
      
 26229 
     | 
    
         
            +
                        (st) => st.type === "sqlite_alter_table_add_column" && st.column.name === data.columnsFrom[0]
         
     | 
| 
      
 26230 
     | 
    
         
            +
                      )) {
         
     | 
| 
      
 26231 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26232 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26233 
     | 
    
         
            +
                      if (statement.isMulticolumn) {
         
     | 
| 
      
 26234 
     | 
    
         
            +
                        if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26235 
     | 
    
         
            +
                          const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         
     | 
| 
      
 26236 
     | 
    
         
            +
                          const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26237 
     | 
    
         
            +
                          if (wasRename) {
         
     | 
| 
      
 26238 
     | 
    
         
            +
                            newStatements[tableName2].push(...preparedStatements);
         
     | 
| 
      
 26239 
     | 
    
         
            +
                          } else {
         
     | 
| 
      
 26240 
     | 
    
         
            +
                            newStatements[tableName2] = preparedStatements;
         
     | 
| 
      
 26241 
     | 
    
         
            +
                          }
         
     | 
| 
      
 26242 
     | 
    
         
            +
                          continue;
         
     | 
| 
      
 26243 
     | 
    
         
            +
                        }
         
     | 
| 
      
 26244 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26245 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26246 
     | 
    
         
            +
                      if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26247 
     | 
    
         
            +
                        newStatements[tableName2].push(statement);
         
     | 
| 
      
 26248 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26249 
     | 
    
         
            +
                      continue;
         
     | 
| 
      
 26250 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26251 
     | 
    
         
            +
                    if (statement.type === "delete_reference") {
         
     | 
| 
      
 26252 
     | 
    
         
            +
                      const tableName2 = statement.tableName;
         
     | 
| 
      
 26253 
     | 
    
         
            +
                      const statementsForTable2 = newStatements[tableName2];
         
     | 
| 
      
 26254 
     | 
    
         
            +
                      if (!statementsForTable2) {
         
     | 
| 
      
 26255 
     | 
    
         
            +
                        newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26256 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26257 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26258 
     | 
    
         
            +
                      if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26259 
     | 
    
         
            +
                        const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         
     | 
| 
      
 26260 
     | 
    
         
            +
                        const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26261 
     | 
    
         
            +
                        if (wasRename) {
         
     | 
| 
      
 26262 
     | 
    
         
            +
                          newStatements[tableName2].push(...preparedStatements);
         
     | 
| 
      
 26263 
     | 
    
         
            +
                        } else {
         
     | 
| 
      
 26264 
     | 
    
         
            +
                          newStatements[tableName2] = preparedStatements;
         
     | 
| 
      
 26265 
     | 
    
         
            +
                        }
         
     | 
| 
      
 26266 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26267 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26268 
     | 
    
         
            +
                      continue;
         
     | 
| 
      
 26269 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26270 
     | 
    
         
            +
                    if (statement.type === "sqlite_alter_table_add_column" && statement.column.primaryKey) {
         
     | 
| 
      
 26271 
     | 
    
         
            +
                      const tableName2 = statement.tableName;
         
     | 
| 
      
 26272 
     | 
    
         
            +
                      const statementsForTable2 = newStatements[tableName2];
         
     | 
| 
      
 26273 
     | 
    
         
            +
                      if (!statementsForTable2) {
         
     | 
| 
      
 26274 
     | 
    
         
            +
                        newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26275 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26276 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26277 
     | 
    
         
            +
                      if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26278 
     | 
    
         
            +
                        const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         
     | 
| 
      
 26279 
     | 
    
         
            +
                        const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26280 
     | 
    
         
            +
                        if (wasRename) {
         
     | 
| 
      
 26281 
     | 
    
         
            +
                          newStatements[tableName2].push(...preparedStatements);
         
     | 
| 
      
 26282 
     | 
    
         
            +
                        } else {
         
     | 
| 
      
 26283 
     | 
    
         
            +
                          newStatements[tableName2] = preparedStatements;
         
     | 
| 
      
 26284 
     | 
    
         
            +
                        }
         
     | 
| 
      
 26285 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26286 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26287 
     | 
    
         
            +
                      continue;
         
     | 
| 
      
 26288 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26289 
     | 
    
         
            +
                    const tableName = statement.type === "rename_table" ? statement.tableNameTo : statement.tableName;
         
     | 
| 
      
 26290 
     | 
    
         
            +
                    const statementsForTable = newStatements[tableName];
         
     | 
| 
      
 26291 
     | 
    
         
            +
                    if (!statementsForTable) {
         
     | 
| 
      
 26292 
     | 
    
         
            +
                      newStatements[tableName] = [statement];
         
     | 
| 
      
 26293 
     | 
    
         
            +
                      continue;
         
     | 
| 
      
 26294 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26295 
     | 
    
         
            +
                    if (!statementsForTable.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26296 
     | 
    
         
            +
                      newStatements[tableName].push(statement);
         
     | 
| 
      
 26297 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26298 
     | 
    
         
            +
                  }
         
     | 
| 
      
 26299 
     | 
    
         
            +
                  const combinedStatements = Object.values(newStatements).flat();
         
     | 
| 
      
 26300 
     | 
    
         
            +
                  const renamedTables = combinedStatements.filter((it) => it.type === "rename_table");
         
     | 
| 
      
 26301 
     | 
    
         
            +
                  const renamedColumns = combinedStatements.filter((it) => it.type === "alter_table_rename_column");
         
     | 
| 
      
 26302 
     | 
    
         
            +
                  const rest = combinedStatements.filter((it) => it.type !== "rename_table" && it.type !== "alter_table_rename_column");
         
     | 
| 
      
 26303 
     | 
    
         
            +
                  return [...renamedTables, ...renamedColumns, ...rest];
         
     | 
| 
      
 26304 
     | 
    
         
            +
                };
         
     | 
| 
      
 26305 
     | 
    
         
            +
                sqliteCombineStatements = (statements, json2, action) => {
         
     | 
| 
      
 26306 
     | 
    
         
            +
                  const newStatements = {};
         
     | 
| 
      
 26307 
     | 
    
         
            +
                  for (const statement of statements) {
         
     | 
| 
      
 26308 
     | 
    
         
            +
                    if (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_pk" || statement.type === "alter_table_alter_column_set_pk" || statement.type === "delete_reference" || statement.type === "alter_reference" || statement.type === "create_composite_pk" || statement.type === "alter_composite_pk" || statement.type === "delete_composite_pk" || statement.type === "create_unique_constraint" || statement.type === "delete_unique_constraint") {
         
     | 
| 
      
 26309 
     | 
    
         
            +
                      const tableName2 = statement.tableName;
         
     | 
| 
      
 26310 
     | 
    
         
            +
                      const statementsForTable2 = newStatements[tableName2];
         
     | 
| 
      
 26311 
     | 
    
         
            +
                      if (!statementsForTable2) {
         
     | 
| 
      
 26312 
     | 
    
         
            +
                        newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26313 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26314 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26315 
     | 
    
         
            +
                      if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26316 
     | 
    
         
            +
                        const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         
     | 
| 
      
 26317 
     | 
    
         
            +
                        const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26318 
     | 
    
         
            +
                        if (wasRename) {
         
     | 
| 
      
 26319 
     | 
    
         
            +
                          newStatements[tableName2].push(...preparedStatements);
         
     | 
| 
      
 26320 
     | 
    
         
            +
                        } else {
         
     | 
| 
      
 26321 
     | 
    
         
            +
                          newStatements[tableName2] = preparedStatements;
         
     | 
| 
      
 26322 
     | 
    
         
            +
                        }
         
     | 
| 
      
 26323 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26324 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26325 
     | 
    
         
            +
                      continue;
         
     | 
| 
      
 26326 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26327 
     | 
    
         
            +
                    if (statement.type === "sqlite_alter_table_add_column" && statement.column.primaryKey) {
         
     | 
| 
      
 26328 
     | 
    
         
            +
                      const tableName2 = statement.tableName;
         
     | 
| 
      
 26329 
     | 
    
         
            +
                      const statementsForTable2 = newStatements[tableName2];
         
     | 
| 
      
 26330 
     | 
    
         
            +
                      if (!statementsForTable2) {
         
     | 
| 
      
 26331 
     | 
    
         
            +
                        newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26332 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26333 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26334 
     | 
    
         
            +
                      if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26335 
     | 
    
         
            +
                        const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         
     | 
| 
      
 26336 
     | 
    
         
            +
                        const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26337 
     | 
    
         
            +
                        if (wasRename) {
         
     | 
| 
      
 26338 
     | 
    
         
            +
                          newStatements[tableName2].push(...preparedStatements);
         
     | 
| 
      
 26339 
     | 
    
         
            +
                        } else {
         
     | 
| 
      
 26340 
     | 
    
         
            +
                          newStatements[tableName2] = preparedStatements;
         
     | 
| 
      
 26341 
     | 
    
         
            +
                        }
         
     | 
| 
      
 26342 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26343 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26344 
     | 
    
         
            +
                      continue;
         
     | 
| 
      
 26345 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26346 
     | 
    
         
            +
                    if (statement.type === "create_reference") {
         
     | 
| 
      
 26347 
     | 
    
         
            +
                      const tableName2 = statement.tableName;
         
     | 
| 
      
 26348 
     | 
    
         
            +
                      const data = action === "push" ? SQLiteSquasher.unsquashPushFK(statement.data) : SQLiteSquasher.unsquashFK(statement.data);
         
     | 
| 
      
 26349 
     | 
    
         
            +
                      const statementsForTable2 = newStatements[tableName2];
         
     | 
| 
      
 26350 
     | 
    
         
            +
                      if (!statementsForTable2) {
         
     | 
| 
      
 26351 
     | 
    
         
            +
                        newStatements[tableName2] = prepareSQLiteRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26352 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26353 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26354 
     | 
    
         
            +
                      if (data.columnsFrom.length === 1 && statementsForTable2.some(
         
     | 
| 
      
 26355 
     | 
    
         
            +
                        (st) => st.type === "sqlite_alter_table_add_column" && st.column.name === data.columnsFrom[0]
         
     | 
| 
      
 26356 
     | 
    
         
            +
                      )) {
         
     | 
| 
      
 26357 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26358 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26359 
     | 
    
         
            +
                      if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26360 
     | 
    
         
            +
                        const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
         
     | 
| 
      
 26361 
     | 
    
         
            +
                        const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
         
     | 
| 
      
 26362 
     | 
    
         
            +
                        if (wasRename) {
         
     | 
| 
      
 26363 
     | 
    
         
            +
                          newStatements[tableName2].push(...preparedStatements);
         
     | 
| 
      
 26364 
     | 
    
         
            +
                        } else {
         
     | 
| 
      
 26365 
     | 
    
         
            +
                          newStatements[tableName2] = preparedStatements;
         
     | 
| 
      
 26366 
     | 
    
         
            +
                        }
         
     | 
| 
      
 26367 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 26368 
     | 
    
         
            +
                      }
         
     | 
| 
      
 26369 
     | 
    
         
            +
                      continue;
         
     | 
| 
      
 26370 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26371 
     | 
    
         
            +
                    const tableName = statement.type === "rename_table" ? statement.tableNameTo : statement.tableName;
         
     | 
| 
      
 26372 
     | 
    
         
            +
                    const statementsForTable = newStatements[tableName];
         
     | 
| 
      
 26373 
     | 
    
         
            +
                    if (!statementsForTable) {
         
     | 
| 
      
 26374 
     | 
    
         
            +
                      newStatements[tableName] = [statement];
         
     | 
| 
      
 26375 
     | 
    
         
            +
                      continue;
         
     | 
| 
      
 26376 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26377 
     | 
    
         
            +
                    if (!statementsForTable.some(({ type }) => type === "recreate_table")) {
         
     | 
| 
      
 26378 
     | 
    
         
            +
                      newStatements[tableName].push(statement);
         
     | 
| 
      
 26379 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26380 
     | 
    
         
            +
                  }
         
     | 
| 
      
 26381 
     | 
    
         
            +
                  const combinedStatements = Object.values(newStatements).flat();
         
     | 
| 
      
 26382 
     | 
    
         
            +
                  const renamedTables = combinedStatements.filter((it) => it.type === "rename_table");
         
     | 
| 
      
 26383 
     | 
    
         
            +
                  const renamedColumns = combinedStatements.filter((it) => it.type === "alter_table_rename_column");
         
     | 
| 
      
 26384 
     | 
    
         
            +
                  const rest = combinedStatements.filter((it) => it.type !== "rename_table" && it.type !== "alter_table_rename_column");
         
     | 
| 
      
 26385 
     | 
    
         
            +
                  return [...renamedTables, ...renamedColumns, ...rest];
         
     | 
| 
      
 26386 
     | 
    
         
            +
                };
         
     | 
| 
      
 26387 
     | 
    
         
            +
              }
         
     | 
| 
      
 26388 
     | 
    
         
            +
            });
         
     | 
| 
      
 26389 
     | 
    
         
            +
             
     | 
| 
       25841 
26390 
     | 
    
         
             
            // src/snapshotsDiffer.ts
         
     | 
| 
       25842 
     | 
    
         
            -
            var makeChanged, makeSelfOrChanged, makePatched, columnSchema, alteredColumnSchema, enumSchema2, changedEnumSchema, tableScheme, alteredTableScheme, diffResultScheme, diffResultSchemeMysql, diffResultSchemeSQLite, schemaChangeFor, nameChangeFor, nameSchemaChangeFor, columnChangeFor, applyPgSnapshotsDiff, applyMysqlSnapshotsDiff, applySqliteSnapshotsDiff;
         
     | 
| 
      
 26391 
     | 
    
         
            +
            var makeChanged, makeSelfOrChanged, makePatched, columnSchema, alteredColumnSchema, enumSchema2, changedEnumSchema, tableScheme, alteredTableScheme, diffResultScheme, diffResultSchemeMysql, diffResultSchemeSQLite, schemaChangeFor, nameChangeFor, nameSchemaChangeFor, columnChangeFor, applyPgSnapshotsDiff, applyMysqlSnapshotsDiff, applySqliteSnapshotsDiff, applyLibSQLSnapshotsDiff;
         
     | 
| 
       25843 
26392 
     | 
    
         
             
            var init_snapshotsDiffer = __esm({
         
     | 
| 
       25844 
26393 
     | 
    
         
             
              "src/snapshotsDiffer.ts"() {
         
     | 
| 
       25845 
26394 
     | 
    
         
             
                "use strict";
         
     | 
| 
         @@ -25851,6 +26400,7 @@ var init_snapshotsDiffer = __esm({ 
     | 
|
| 
       25851 
26400 
     | 
    
         
             
                init_mysqlSchema();
         
     | 
| 
       25852 
26401 
     | 
    
         
             
                init_pgSchema();
         
     | 
| 
       25853 
26402 
     | 
    
         
             
                init_sqliteSchema();
         
     | 
| 
      
 26403 
     | 
    
         
            +
                init_statementCombiner();
         
     | 
| 
       25854 
26404 
     | 
    
         
             
                init_utils();
         
     | 
| 
       25855 
26405 
     | 
    
         
             
                makeChanged = (schema5) => {
         
     | 
| 
       25856 
26406 
     | 
    
         
             
                  return objectType({
         
     | 
| 
         @@ -27178,7 +27728,8 @@ var init_snapshotsDiffer = __esm({ 
     | 
|
| 
       27178 
27728 
     | 
    
         
             
                  jsonStatements.push(...jsonDropColumnsStatemets);
         
     | 
| 
       27179 
27729 
     | 
    
         
             
                  jsonStatements.push(...jsonAlteredCompositePKs);
         
     | 
| 
       27180 
27730 
     | 
    
         
             
                  jsonStatements.push(...jsonAlteredUniqueConstraints);
         
     | 
| 
       27181 
     | 
    
         
            -
                  const  
     | 
| 
      
 27731 
     | 
    
         
            +
                  const combinedJsonStatements = sqliteCombineStatements(jsonStatements, json2, action);
         
     | 
| 
      
 27732 
     | 
    
         
            +
                  const sqlStatements = fromJson(combinedJsonStatements, "sqlite");
         
     | 
| 
       27182 
27733 
     | 
    
         
             
                  const uniqueSqlStatements = [];
         
     | 
| 
       27183 
27734 
     | 
    
         
             
                  sqlStatements.forEach((ss) => {
         
     | 
| 
       27184 
27735 
     | 
    
         
             
                    if (!uniqueSqlStatements.includes(ss)) {
         
     | 
| 
         @@ -27190,7 +27741,298 @@ var init_snapshotsDiffer = __esm({ 
     | 
|
| 
       27190 
27741 
     | 
    
         
             
                  });
         
     | 
| 
       27191 
27742 
     | 
    
         
             
                  const _meta = prepareMigrationMeta([], rTables, rColumns);
         
     | 
| 
       27192 
27743 
     | 
    
         
             
                  return {
         
     | 
| 
       27193 
     | 
    
         
            -
                    statements:  
     | 
| 
      
 27744 
     | 
    
         
            +
                    statements: combinedJsonStatements,
         
     | 
| 
      
 27745 
     | 
    
         
            +
                    sqlStatements: uniqueSqlStatements,
         
     | 
| 
      
 27746 
     | 
    
         
            +
                    _meta
         
     | 
| 
      
 27747 
     | 
    
         
            +
                  };
         
     | 
| 
      
 27748 
     | 
    
         
            +
                };
         
     | 
| 
      
 27749 
     | 
    
         
            +
                applyLibSQLSnapshotsDiff = async (json1, json2, tablesResolver2, columnsResolver2, prevFull, curFull, action) => {
         
     | 
| 
      
 27750 
     | 
    
         
            +
                  const tablesDiff = diffSchemasOrTables(json1.tables, json2.tables);
         
     | 
| 
      
 27751 
     | 
    
         
            +
                  const {
         
     | 
| 
      
 27752 
     | 
    
         
            +
                    created: createdTables,
         
     | 
| 
      
 27753 
     | 
    
         
            +
                    deleted: deletedTables,
         
     | 
| 
      
 27754 
     | 
    
         
            +
                    renamed: renamedTables
         
     | 
| 
      
 27755 
     | 
    
         
            +
                  } = await tablesResolver2({
         
     | 
| 
      
 27756 
     | 
    
         
            +
                    created: tablesDiff.added,
         
     | 
| 
      
 27757 
     | 
    
         
            +
                    deleted: tablesDiff.deleted
         
     | 
| 
      
 27758 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27759 
     | 
    
         
            +
                  const tablesPatchedSnap1 = copy(json1);
         
     | 
| 
      
 27760 
     | 
    
         
            +
                  tablesPatchedSnap1.tables = mapEntries(tablesPatchedSnap1.tables, (_2, it) => {
         
     | 
| 
      
 27761 
     | 
    
         
            +
                    const { name } = nameChangeFor(it, renamedTables);
         
     | 
| 
      
 27762 
     | 
    
         
            +
                    it.name = name;
         
     | 
| 
      
 27763 
     | 
    
         
            +
                    return [name, it];
         
     | 
| 
      
 27764 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27765 
     | 
    
         
            +
                  const res = diffColumns(tablesPatchedSnap1.tables, json2.tables);
         
     | 
| 
      
 27766 
     | 
    
         
            +
                  const columnRenames = [];
         
     | 
| 
      
 27767 
     | 
    
         
            +
                  const columnCreates = [];
         
     | 
| 
      
 27768 
     | 
    
         
            +
                  const columnDeletes = [];
         
     | 
| 
      
 27769 
     | 
    
         
            +
                  for (let entry of Object.values(res)) {
         
     | 
| 
      
 27770 
     | 
    
         
            +
                    const { renamed, created, deleted } = await columnsResolver2({
         
     | 
| 
      
 27771 
     | 
    
         
            +
                      tableName: entry.name,
         
     | 
| 
      
 27772 
     | 
    
         
            +
                      schema: entry.schema,
         
     | 
| 
      
 27773 
     | 
    
         
            +
                      deleted: entry.columns.deleted,
         
     | 
| 
      
 27774 
     | 
    
         
            +
                      created: entry.columns.added
         
     | 
| 
      
 27775 
     | 
    
         
            +
                    });
         
     | 
| 
      
 27776 
     | 
    
         
            +
                    if (created.length > 0) {
         
     | 
| 
      
 27777 
     | 
    
         
            +
                      columnCreates.push({
         
     | 
| 
      
 27778 
     | 
    
         
            +
                        table: entry.name,
         
     | 
| 
      
 27779 
     | 
    
         
            +
                        columns: created
         
     | 
| 
      
 27780 
     | 
    
         
            +
                      });
         
     | 
| 
      
 27781 
     | 
    
         
            +
                    }
         
     | 
| 
      
 27782 
     | 
    
         
            +
                    if (deleted.length > 0) {
         
     | 
| 
      
 27783 
     | 
    
         
            +
                      columnDeletes.push({
         
     | 
| 
      
 27784 
     | 
    
         
            +
                        table: entry.name,
         
     | 
| 
      
 27785 
     | 
    
         
            +
                        columns: deleted
         
     | 
| 
      
 27786 
     | 
    
         
            +
                      });
         
     | 
| 
      
 27787 
     | 
    
         
            +
                    }
         
     | 
| 
      
 27788 
     | 
    
         
            +
                    if (renamed.length > 0) {
         
     | 
| 
      
 27789 
     | 
    
         
            +
                      columnRenames.push({
         
     | 
| 
      
 27790 
     | 
    
         
            +
                        table: entry.name,
         
     | 
| 
      
 27791 
     | 
    
         
            +
                        renames: renamed
         
     | 
| 
      
 27792 
     | 
    
         
            +
                      });
         
     | 
| 
      
 27793 
     | 
    
         
            +
                    }
         
     | 
| 
      
 27794 
     | 
    
         
            +
                  }
         
     | 
| 
      
 27795 
     | 
    
         
            +
                  const columnRenamesDict = columnRenames.reduce(
         
     | 
| 
      
 27796 
     | 
    
         
            +
                    (acc, it) => {
         
     | 
| 
      
 27797 
     | 
    
         
            +
                      acc[it.table] = it.renames;
         
     | 
| 
      
 27798 
     | 
    
         
            +
                      return acc;
         
     | 
| 
      
 27799 
     | 
    
         
            +
                    },
         
     | 
| 
      
 27800 
     | 
    
         
            +
                    {}
         
     | 
| 
      
 27801 
     | 
    
         
            +
                  );
         
     | 
| 
      
 27802 
     | 
    
         
            +
                  const columnsPatchedSnap1 = copy(tablesPatchedSnap1);
         
     | 
| 
      
 27803 
     | 
    
         
            +
                  columnsPatchedSnap1.tables = mapEntries(
         
     | 
| 
      
 27804 
     | 
    
         
            +
                    columnsPatchedSnap1.tables,
         
     | 
| 
      
 27805 
     | 
    
         
            +
                    (tableKey2, tableValue) => {
         
     | 
| 
      
 27806 
     | 
    
         
            +
                      const patchedColumns = mapKeys(
         
     | 
| 
      
 27807 
     | 
    
         
            +
                        tableValue.columns,
         
     | 
| 
      
 27808 
     | 
    
         
            +
                        (columnKey, column7) => {
         
     | 
| 
      
 27809 
     | 
    
         
            +
                          const rens = columnRenamesDict[tableValue.name] || [];
         
     | 
| 
      
 27810 
     | 
    
         
            +
                          const newName = columnChangeFor(columnKey, rens);
         
     | 
| 
      
 27811 
     | 
    
         
            +
                          column7.name = newName;
         
     | 
| 
      
 27812 
     | 
    
         
            +
                          return newName;
         
     | 
| 
      
 27813 
     | 
    
         
            +
                        }
         
     | 
| 
      
 27814 
     | 
    
         
            +
                      );
         
     | 
| 
      
 27815 
     | 
    
         
            +
                      tableValue.columns = patchedColumns;
         
     | 
| 
      
 27816 
     | 
    
         
            +
                      return [tableKey2, tableValue];
         
     | 
| 
      
 27817 
     | 
    
         
            +
                    }
         
     | 
| 
      
 27818 
     | 
    
         
            +
                  );
         
     | 
| 
      
 27819 
     | 
    
         
            +
                  const diffResult = applyJsonDiff(columnsPatchedSnap1, json2);
         
     | 
| 
      
 27820 
     | 
    
         
            +
                  const typedResult = diffResultSchemeSQLite.parse(diffResult);
         
     | 
| 
      
 27821 
     | 
    
         
            +
                  const tablesMap = {};
         
     | 
| 
      
 27822 
     | 
    
         
            +
                  typedResult.alteredTablesWithColumns.forEach((obj) => {
         
     | 
| 
      
 27823 
     | 
    
         
            +
                    tablesMap[obj.name] = obj;
         
     | 
| 
      
 27824 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27825 
     | 
    
         
            +
                  const jsonCreateTables = createdTables.map((it) => {
         
     | 
| 
      
 27826 
     | 
    
         
            +
                    return prepareSQLiteCreateTable(it, action);
         
     | 
| 
      
 27827 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27828 
     | 
    
         
            +
                  const jsonCreateIndexesForCreatedTables = createdTables.map((it) => {
         
     | 
| 
      
 27829 
     | 
    
         
            +
                    return prepareCreateIndexesJson(
         
     | 
| 
      
 27830 
     | 
    
         
            +
                      it.name,
         
     | 
| 
      
 27831 
     | 
    
         
            +
                      it.schema,
         
     | 
| 
      
 27832 
     | 
    
         
            +
                      it.indexes,
         
     | 
| 
      
 27833 
     | 
    
         
            +
                      curFull.internal
         
     | 
| 
      
 27834 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27835 
     | 
    
         
            +
                  }).flat();
         
     | 
| 
      
 27836 
     | 
    
         
            +
                  const jsonDropTables = deletedTables.map((it) => {
         
     | 
| 
      
 27837 
     | 
    
         
            +
                    return prepareDropTableJson(it);
         
     | 
| 
      
 27838 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27839 
     | 
    
         
            +
                  const jsonRenameTables = renamedTables.map((it) => {
         
     | 
| 
      
 27840 
     | 
    
         
            +
                    return prepareRenameTableJson(it.from, it.to);
         
     | 
| 
      
 27841 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27842 
     | 
    
         
            +
                  const jsonRenameColumnsStatements = columnRenames.map((it) => prepareRenameColumns(it.table, "", it.renames)).flat();
         
     | 
| 
      
 27843 
     | 
    
         
            +
                  const jsonDropColumnsStatemets = columnDeletes.map((it) => _prepareDropColumns(it.table, "", it.columns)).flat();
         
     | 
| 
      
 27844 
     | 
    
         
            +
                  const jsonAddColumnsStatemets = columnCreates.map((it) => {
         
     | 
| 
      
 27845 
     | 
    
         
            +
                    return _prepareSqliteAddColumns(
         
     | 
| 
      
 27846 
     | 
    
         
            +
                      it.table,
         
     | 
| 
      
 27847 
     | 
    
         
            +
                      it.columns,
         
     | 
| 
      
 27848 
     | 
    
         
            +
                      tablesMap[it.table] && tablesMap[it.table].addedForeignKeys ? Object.values(tablesMap[it.table].addedForeignKeys) : []
         
     | 
| 
      
 27849 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27850 
     | 
    
         
            +
                  }).flat();
         
     | 
| 
      
 27851 
     | 
    
         
            +
                  const rColumns = jsonRenameColumnsStatements.map((it) => {
         
     | 
| 
      
 27852 
     | 
    
         
            +
                    const tableName = it.tableName;
         
     | 
| 
      
 27853 
     | 
    
         
            +
                    const schema5 = it.schema;
         
     | 
| 
      
 27854 
     | 
    
         
            +
                    return {
         
     | 
| 
      
 27855 
     | 
    
         
            +
                      from: { schema: schema5, table: tableName, column: it.oldColumnName },
         
     | 
| 
      
 27856 
     | 
    
         
            +
                      to: { schema: schema5, table: tableName, column: it.newColumnName }
         
     | 
| 
      
 27857 
     | 
    
         
            +
                    };
         
     | 
| 
      
 27858 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27859 
     | 
    
         
            +
                  const rTables = renamedTables.map((it) => {
         
     | 
| 
      
 27860 
     | 
    
         
            +
                    return { from: it.from, to: it.to };
         
     | 
| 
      
 27861 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27862 
     | 
    
         
            +
                  const _meta = prepareMigrationMeta([], rTables, rColumns);
         
     | 
| 
      
 27863 
     | 
    
         
            +
                  const allAltered = typedResult.alteredTablesWithColumns;
         
     | 
| 
      
 27864 
     | 
    
         
            +
                  const jsonAddedCompositePKs = [];
         
     | 
| 
      
 27865 
     | 
    
         
            +
                  const jsonDeletedCompositePKs = [];
         
     | 
| 
      
 27866 
     | 
    
         
            +
                  const jsonAlteredCompositePKs = [];
         
     | 
| 
      
 27867 
     | 
    
         
            +
                  const jsonAddedUniqueConstraints = [];
         
     | 
| 
      
 27868 
     | 
    
         
            +
                  const jsonDeletedUniqueConstraints = [];
         
     | 
| 
      
 27869 
     | 
    
         
            +
                  const jsonAlteredUniqueConstraints = [];
         
     | 
| 
      
 27870 
     | 
    
         
            +
                  allAltered.forEach((it) => {
         
     | 
| 
      
 27871 
     | 
    
         
            +
                    let addedColumns = [];
         
     | 
| 
      
 27872 
     | 
    
         
            +
                    for (const addedPkName of Object.keys(it.addedCompositePKs)) {
         
     | 
| 
      
 27873 
     | 
    
         
            +
                      const addedPkColumns = it.addedCompositePKs[addedPkName];
         
     | 
| 
      
 27874 
     | 
    
         
            +
                      addedColumns = SQLiteSquasher.unsquashPK(addedPkColumns);
         
     | 
| 
      
 27875 
     | 
    
         
            +
                    }
         
     | 
| 
      
 27876 
     | 
    
         
            +
                    let deletedColumns = [];
         
     | 
| 
      
 27877 
     | 
    
         
            +
                    for (const deletedPkName of Object.keys(it.deletedCompositePKs)) {
         
     | 
| 
      
 27878 
     | 
    
         
            +
                      const deletedPkColumns = it.deletedCompositePKs[deletedPkName];
         
     | 
| 
      
 27879 
     | 
    
         
            +
                      deletedColumns = SQLiteSquasher.unsquashPK(deletedPkColumns);
         
     | 
| 
      
 27880 
     | 
    
         
            +
                    }
         
     | 
| 
      
 27881 
     | 
    
         
            +
                    const doPerformDeleteAndCreate = JSON.stringify(addedColumns) !== JSON.stringify(deletedColumns);
         
     | 
| 
      
 27882 
     | 
    
         
            +
                    let addedCompositePKs = [];
         
     | 
| 
      
 27883 
     | 
    
         
            +
                    let deletedCompositePKs = [];
         
     | 
| 
      
 27884 
     | 
    
         
            +
                    let alteredCompositePKs = [];
         
     | 
| 
      
 27885 
     | 
    
         
            +
                    if (doPerformDeleteAndCreate) {
         
     | 
| 
      
 27886 
     | 
    
         
            +
                      addedCompositePKs = prepareAddCompositePrimaryKeySqlite(
         
     | 
| 
      
 27887 
     | 
    
         
            +
                        it.name,
         
     | 
| 
      
 27888 
     | 
    
         
            +
                        it.addedCompositePKs
         
     | 
| 
      
 27889 
     | 
    
         
            +
                      );
         
     | 
| 
      
 27890 
     | 
    
         
            +
                      deletedCompositePKs = prepareDeleteCompositePrimaryKeySqlite(
         
     | 
| 
      
 27891 
     | 
    
         
            +
                        it.name,
         
     | 
| 
      
 27892 
     | 
    
         
            +
                        it.deletedCompositePKs
         
     | 
| 
      
 27893 
     | 
    
         
            +
                      );
         
     | 
| 
      
 27894 
     | 
    
         
            +
                    }
         
     | 
| 
      
 27895 
     | 
    
         
            +
                    alteredCompositePKs = prepareAlterCompositePrimaryKeySqlite(
         
     | 
| 
      
 27896 
     | 
    
         
            +
                      it.name,
         
     | 
| 
      
 27897 
     | 
    
         
            +
                      it.alteredCompositePKs
         
     | 
| 
      
 27898 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27899 
     | 
    
         
            +
                    let addedUniqueConstraints = [];
         
     | 
| 
      
 27900 
     | 
    
         
            +
                    let deletedUniqueConstraints = [];
         
     | 
| 
      
 27901 
     | 
    
         
            +
                    let alteredUniqueConstraints = [];
         
     | 
| 
      
 27902 
     | 
    
         
            +
                    addedUniqueConstraints = prepareAddUniqueConstraintPg(
         
     | 
| 
      
 27903 
     | 
    
         
            +
                      it.name,
         
     | 
| 
      
 27904 
     | 
    
         
            +
                      it.schema,
         
     | 
| 
      
 27905 
     | 
    
         
            +
                      it.addedUniqueConstraints
         
     | 
| 
      
 27906 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27907 
     | 
    
         
            +
                    deletedUniqueConstraints = prepareDeleteUniqueConstraintPg(
         
     | 
| 
      
 27908 
     | 
    
         
            +
                      it.name,
         
     | 
| 
      
 27909 
     | 
    
         
            +
                      it.schema,
         
     | 
| 
      
 27910 
     | 
    
         
            +
                      it.deletedUniqueConstraints
         
     | 
| 
      
 27911 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27912 
     | 
    
         
            +
                    if (it.alteredUniqueConstraints) {
         
     | 
| 
      
 27913 
     | 
    
         
            +
                      const added = {};
         
     | 
| 
      
 27914 
     | 
    
         
            +
                      const deleted = {};
         
     | 
| 
      
 27915 
     | 
    
         
            +
                      for (const k of Object.keys(it.alteredUniqueConstraints)) {
         
     | 
| 
      
 27916 
     | 
    
         
            +
                        added[k] = it.alteredUniqueConstraints[k].__new;
         
     | 
| 
      
 27917 
     | 
    
         
            +
                        deleted[k] = it.alteredUniqueConstraints[k].__old;
         
     | 
| 
      
 27918 
     | 
    
         
            +
                      }
         
     | 
| 
      
 27919 
     | 
    
         
            +
                      addedUniqueConstraints.push(
         
     | 
| 
      
 27920 
     | 
    
         
            +
                        ...prepareAddUniqueConstraintPg(it.name, it.schema, added)
         
     | 
| 
      
 27921 
     | 
    
         
            +
                      );
         
     | 
| 
      
 27922 
     | 
    
         
            +
                      deletedUniqueConstraints.push(
         
     | 
| 
      
 27923 
     | 
    
         
            +
                        ...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
         
     | 
| 
      
 27924 
     | 
    
         
            +
                      );
         
     | 
| 
      
 27925 
     | 
    
         
            +
                    }
         
     | 
| 
      
 27926 
     | 
    
         
            +
                    jsonAddedCompositePKs.push(...addedCompositePKs);
         
     | 
| 
      
 27927 
     | 
    
         
            +
                    jsonDeletedCompositePKs.push(...deletedCompositePKs);
         
     | 
| 
      
 27928 
     | 
    
         
            +
                    jsonAlteredCompositePKs.push(...alteredCompositePKs);
         
     | 
| 
      
 27929 
     | 
    
         
            +
                    jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
         
     | 
| 
      
 27930 
     | 
    
         
            +
                    jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
         
     | 
| 
      
 27931 
     | 
    
         
            +
                    jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
         
     | 
| 
      
 27932 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27933 
     | 
    
         
            +
                  const jsonTableAlternations = allAltered.map((it) => {
         
     | 
| 
      
 27934 
     | 
    
         
            +
                    return prepareSqliteAlterColumns(it.name, it.schema, it.altered, json2);
         
     | 
| 
      
 27935 
     | 
    
         
            +
                  }).flat();
         
     | 
| 
      
 27936 
     | 
    
         
            +
                  const jsonCreateIndexesForAllAlteredTables = allAltered.map((it) => {
         
     | 
| 
      
 27937 
     | 
    
         
            +
                    return prepareCreateIndexesJson(
         
     | 
| 
      
 27938 
     | 
    
         
            +
                      it.name,
         
     | 
| 
      
 27939 
     | 
    
         
            +
                      it.schema,
         
     | 
| 
      
 27940 
     | 
    
         
            +
                      it.addedIndexes || {},
         
     | 
| 
      
 27941 
     | 
    
         
            +
                      curFull.internal
         
     | 
| 
      
 27942 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27943 
     | 
    
         
            +
                  }).flat();
         
     | 
| 
      
 27944 
     | 
    
         
            +
                  const jsonDropIndexesForAllAlteredTables = allAltered.map((it) => {
         
     | 
| 
      
 27945 
     | 
    
         
            +
                    return prepareDropIndexesJson(
         
     | 
| 
      
 27946 
     | 
    
         
            +
                      it.name,
         
     | 
| 
      
 27947 
     | 
    
         
            +
                      it.schema,
         
     | 
| 
      
 27948 
     | 
    
         
            +
                      it.deletedIndexes || {}
         
     | 
| 
      
 27949 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27950 
     | 
    
         
            +
                  }).flat();
         
     | 
| 
      
 27951 
     | 
    
         
            +
                  allAltered.forEach((it) => {
         
     | 
| 
      
 27952 
     | 
    
         
            +
                    const droppedIndexes = Object.keys(it.alteredIndexes).reduce(
         
     | 
| 
      
 27953 
     | 
    
         
            +
                      (current, item) => {
         
     | 
| 
      
 27954 
     | 
    
         
            +
                        current[item] = it.alteredIndexes[item].__old;
         
     | 
| 
      
 27955 
     | 
    
         
            +
                        return current;
         
     | 
| 
      
 27956 
     | 
    
         
            +
                      },
         
     | 
| 
      
 27957 
     | 
    
         
            +
                      {}
         
     | 
| 
      
 27958 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27959 
     | 
    
         
            +
                    const createdIndexes = Object.keys(it.alteredIndexes).reduce(
         
     | 
| 
      
 27960 
     | 
    
         
            +
                      (current, item) => {
         
     | 
| 
      
 27961 
     | 
    
         
            +
                        current[item] = it.alteredIndexes[item].__new;
         
     | 
| 
      
 27962 
     | 
    
         
            +
                        return current;
         
     | 
| 
      
 27963 
     | 
    
         
            +
                      },
         
     | 
| 
      
 27964 
     | 
    
         
            +
                      {}
         
     | 
| 
      
 27965 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27966 
     | 
    
         
            +
                    jsonCreateIndexesForAllAlteredTables.push(
         
     | 
| 
      
 27967 
     | 
    
         
            +
                      ...prepareCreateIndexesJson(
         
     | 
| 
      
 27968 
     | 
    
         
            +
                        it.name,
         
     | 
| 
      
 27969 
     | 
    
         
            +
                        it.schema,
         
     | 
| 
      
 27970 
     | 
    
         
            +
                        createdIndexes || {},
         
     | 
| 
      
 27971 
     | 
    
         
            +
                        curFull.internal
         
     | 
| 
      
 27972 
     | 
    
         
            +
                      )
         
     | 
| 
      
 27973 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27974 
     | 
    
         
            +
                    jsonDropIndexesForAllAlteredTables.push(
         
     | 
| 
      
 27975 
     | 
    
         
            +
                      ...prepareDropIndexesJson(it.name, it.schema, droppedIndexes || {})
         
     | 
| 
      
 27976 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27977 
     | 
    
         
            +
                  });
         
     | 
| 
      
 27978 
     | 
    
         
            +
                  const jsonReferencesForAllAlteredTables = allAltered.map((it) => {
         
     | 
| 
      
 27979 
     | 
    
         
            +
                    const forAdded = prepareLibSQLCreateReferencesJson(
         
     | 
| 
      
 27980 
     | 
    
         
            +
                      it.name,
         
     | 
| 
      
 27981 
     | 
    
         
            +
                      it.schema,
         
     | 
| 
      
 27982 
     | 
    
         
            +
                      it.addedForeignKeys,
         
     | 
| 
      
 27983 
     | 
    
         
            +
                      json2,
         
     | 
| 
      
 27984 
     | 
    
         
            +
                      action
         
     | 
| 
      
 27985 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27986 
     | 
    
         
            +
                    const forAltered = prepareLibSQLDropReferencesJson(
         
     | 
| 
      
 27987 
     | 
    
         
            +
                      it.name,
         
     | 
| 
      
 27988 
     | 
    
         
            +
                      it.schema,
         
     | 
| 
      
 27989 
     | 
    
         
            +
                      it.deletedForeignKeys,
         
     | 
| 
      
 27990 
     | 
    
         
            +
                      json2,
         
     | 
| 
      
 27991 
     | 
    
         
            +
                      _meta,
         
     | 
| 
      
 27992 
     | 
    
         
            +
                      action
         
     | 
| 
      
 27993 
     | 
    
         
            +
                    );
         
     | 
| 
      
 27994 
     | 
    
         
            +
                    const alteredFKs = prepareAlterReferencesJson(it.name, it.schema, it.alteredForeignKeys);
         
     | 
| 
      
 27995 
     | 
    
         
            +
                    return [...forAdded, ...forAltered, ...alteredFKs];
         
     | 
| 
      
 27996 
     | 
    
         
            +
                  }).flat();
         
     | 
| 
      
 27997 
     | 
    
         
            +
                  const jsonCreatedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
         
     | 
| 
      
 27998 
     | 
    
         
            +
                    (t2) => t2.type === "create_reference"
         
     | 
| 
      
 27999 
     | 
    
         
            +
                  );
         
     | 
| 
      
 28000 
     | 
    
         
            +
                  const jsonDroppedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
         
     | 
| 
      
 28001 
     | 
    
         
            +
                    (t2) => t2.type === "delete_reference"
         
     | 
| 
      
 28002 
     | 
    
         
            +
                  );
         
     | 
| 
      
 28003 
     | 
    
         
            +
                  const jsonStatements = [];
         
     | 
| 
      
 28004 
     | 
    
         
            +
                  jsonStatements.push(...jsonCreateTables);
         
     | 
| 
      
 28005 
     | 
    
         
            +
                  jsonStatements.push(...jsonDropTables);
         
     | 
| 
      
 28006 
     | 
    
         
            +
                  jsonStatements.push(...jsonRenameTables);
         
     | 
| 
      
 28007 
     | 
    
         
            +
                  jsonStatements.push(...jsonRenameColumnsStatements);
         
     | 
| 
      
 28008 
     | 
    
         
            +
                  jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
         
     | 
| 
      
 28009 
     | 
    
         
            +
                  jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
         
     | 
| 
      
 28010 
     | 
    
         
            +
                  jsonStatements.push(...jsonDeletedCompositePKs);
         
     | 
| 
      
 28011 
     | 
    
         
            +
                  jsonStatements.push(...jsonTableAlternations);
         
     | 
| 
      
 28012 
     | 
    
         
            +
                  jsonStatements.push(...jsonAddedCompositePKs);
         
     | 
| 
      
 28013 
     | 
    
         
            +
                  jsonStatements.push(...jsonAddColumnsStatemets);
         
     | 
| 
      
 28014 
     | 
    
         
            +
                  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
         
     | 
| 
      
 28015 
     | 
    
         
            +
                  jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
         
     | 
| 
      
 28016 
     | 
    
         
            +
                  jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
         
     | 
| 
      
 28017 
     | 
    
         
            +
                  jsonStatements.push(...jsonDropColumnsStatemets);
         
     | 
| 
      
 28018 
     | 
    
         
            +
                  jsonStatements.push(...jsonAlteredCompositePKs);
         
     | 
| 
      
 28019 
     | 
    
         
            +
                  jsonStatements.push(...jsonAlteredUniqueConstraints);
         
     | 
| 
      
 28020 
     | 
    
         
            +
                  const combinedJsonStatements = libSQLCombineStatements(jsonStatements, json2, action);
         
     | 
| 
      
 28021 
     | 
    
         
            +
                  const sqlStatements = fromJson(
         
     | 
| 
      
 28022 
     | 
    
         
            +
                    combinedJsonStatements,
         
     | 
| 
      
 28023 
     | 
    
         
            +
                    "sqlite",
         
     | 
| 
      
 28024 
     | 
    
         
            +
                    action,
         
     | 
| 
      
 28025 
     | 
    
         
            +
                    "turso",
         
     | 
| 
      
 28026 
     | 
    
         
            +
                    json2
         
     | 
| 
      
 28027 
     | 
    
         
            +
                  );
         
     | 
| 
      
 28028 
     | 
    
         
            +
                  const uniqueSqlStatements = [];
         
     | 
| 
      
 28029 
     | 
    
         
            +
                  sqlStatements.forEach((ss) => {
         
     | 
| 
      
 28030 
     | 
    
         
            +
                    if (!uniqueSqlStatements.includes(ss)) {
         
     | 
| 
      
 28031 
     | 
    
         
            +
                      uniqueSqlStatements.push(ss);
         
     | 
| 
      
 28032 
     | 
    
         
            +
                    }
         
     | 
| 
      
 28033 
     | 
    
         
            +
                  });
         
     | 
| 
      
 28034 
     | 
    
         
            +
                  return {
         
     | 
| 
      
 28035 
     | 
    
         
            +
                    statements: combinedJsonStatements,
         
     | 
| 
       27194 
28036 
     | 
    
         
             
                    sqlStatements: uniqueSqlStatements,
         
     | 
| 
       27195 
28037 
     | 
    
         
             
                    _meta
         
     | 
| 
       27196 
28038 
     | 
    
         
             
                  };
         
     | 
| 
         @@ -28529,6 +29371,7 @@ __export(migrate_exports, { 
     | 
|
| 
       28529 
29371 
     | 
    
         
             
              prepareAndMigrateMysql: () => prepareAndMigrateMysql,
         
     | 
| 
       28530 
29372 
     | 
    
         
             
              prepareAndMigratePg: () => prepareAndMigratePg,
         
     | 
| 
       28531 
29373 
     | 
    
         
             
              prepareAndMigrateSqlite: () => prepareAndMigrateSqlite,
         
     | 
| 
      
 29374 
     | 
    
         
            +
              prepareLibSQLPush: () => prepareLibSQLPush,
         
     | 
| 
       28532 
29375 
     | 
    
         
             
              prepareMySQLPush: () => prepareMySQLPush,
         
     | 
| 
       28533 
29376 
     | 
    
         
             
              preparePgPush: () => preparePgPush,
         
     | 
| 
       28534 
29377 
     | 
    
         
             
              prepareSQLitePush: () => prepareSQLitePush,
         
     | 
| 
         @@ -28541,7 +29384,7 @@ __export(migrate_exports, { 
     | 
|
| 
       28541 
29384 
     | 
    
         
             
              tablesResolver: () => tablesResolver,
         
     | 
| 
       28542 
29385 
     | 
    
         
             
              writeResult: () => writeResult
         
     | 
| 
       28543 
29386 
     | 
    
         
             
            });
         
     | 
| 
       28544 
     | 
    
         
            -
            var import_fs5, import_hanji3, import_path4, schemasResolver, tablesResolver, sequencesResolver, enumsResolver, columnsResolver, prepareAndMigratePg, preparePgPush, prepareMySQLPush, prepareAndMigrateMysql, prepareAndMigrateSqlite, prepareSQLitePush, promptColumnsConflicts, promptNamedWithSchemasConflict, promptSchemasConflict, BREAKPOINT, writeResult, embeddedMigrations, prepareSnapshotFolderName, two;
         
     | 
| 
      
 29387 
     | 
    
         
            +
            var import_fs5, import_hanji3, import_path4, schemasResolver, tablesResolver, sequencesResolver, enumsResolver, columnsResolver, prepareAndMigratePg, preparePgPush, prepareMySQLPush, prepareAndMigrateMysql, prepareAndMigrateSqlite, prepareSQLitePush, prepareLibSQLPush, promptColumnsConflicts, promptNamedWithSchemasConflict, promptSchemasConflict, BREAKPOINT, writeResult, embeddedMigrations, prepareSnapshotFolderName, two;
         
     | 
| 
       28545 
29388 
     | 
    
         
             
            var init_migrate = __esm({
         
     | 
| 
       28546 
29389 
     | 
    
         
             
              "src/cli/commands/migrate.ts"() {
         
     | 
| 
       28547 
29390 
     | 
    
         
             
                "use strict";
         
     | 
| 
         @@ -28793,6 +29636,7 @@ var init_migrate = __esm({ 
     | 
|
| 
       28793 
29636 
     | 
    
         
             
                prepareAndMigrateSqlite = async (config) => {
         
     | 
| 
       28794 
29637 
     | 
    
         
             
                  const outFolder = config.out;
         
     | 
| 
       28795 
29638 
     | 
    
         
             
                  const schemaPath = config.schema;
         
     | 
| 
      
 29639 
     | 
    
         
            +
                  const driver2 = config.driver;
         
     | 
| 
       28796 
29640 
     | 
    
         
             
                  try {
         
     | 
| 
       28797 
29641 
     | 
    
         
             
                    assertV1OutFolder(outFolder);
         
     | 
| 
       28798 
29642 
     | 
    
         
             
                    const { snapshots, journal } = prepareMigrationFolder(outFolder, "sqlite");
         
     | 
| 
         @@ -28818,14 +29662,27 @@ var init_migrate = __esm({ 
     | 
|
| 
       28818 
29662 
     | 
    
         
             
                    }
         
     | 
| 
       28819 
29663 
     | 
    
         
             
                    const squashedPrev = squashSqliteScheme(validatedPrev);
         
     | 
| 
       28820 
29664 
     | 
    
         
             
                    const squashedCur = squashSqliteScheme(validatedCur);
         
     | 
| 
       28821 
     | 
    
         
            -
                     
     | 
| 
       28822 
     | 
    
         
            -
             
     | 
| 
       28823 
     | 
    
         
            -
             
     | 
| 
       28824 
     | 
    
         
            -
                       
     | 
| 
       28825 
     | 
    
         
            -
             
     | 
| 
       28826 
     | 
    
         
            -
             
     | 
| 
       28827 
     | 
    
         
            -
             
     | 
| 
       28828 
     | 
    
         
            -
             
     | 
| 
      
 29665 
     | 
    
         
            +
                    let sqlStatements;
         
     | 
| 
      
 29666 
     | 
    
         
            +
                    let _meta;
         
     | 
| 
      
 29667 
     | 
    
         
            +
                    if (driver2 === "turso") {
         
     | 
| 
      
 29668 
     | 
    
         
            +
                      ({ sqlStatements, _meta } = await applyLibSQLSnapshotsDiff(
         
     | 
| 
      
 29669 
     | 
    
         
            +
                        squashedPrev,
         
     | 
| 
      
 29670 
     | 
    
         
            +
                        squashedCur,
         
     | 
| 
      
 29671 
     | 
    
         
            +
                        tablesResolver,
         
     | 
| 
      
 29672 
     | 
    
         
            +
                        columnsResolver,
         
     | 
| 
      
 29673 
     | 
    
         
            +
                        validatedPrev,
         
     | 
| 
      
 29674 
     | 
    
         
            +
                        validatedCur
         
     | 
| 
      
 29675 
     | 
    
         
            +
                      ));
         
     | 
| 
      
 29676 
     | 
    
         
            +
                    } else {
         
     | 
| 
      
 29677 
     | 
    
         
            +
                      ({ sqlStatements, _meta } = await applySqliteSnapshotsDiff(
         
     | 
| 
      
 29678 
     | 
    
         
            +
                        squashedPrev,
         
     | 
| 
      
 29679 
     | 
    
         
            +
                        squashedCur,
         
     | 
| 
      
 29680 
     | 
    
         
            +
                        tablesResolver,
         
     | 
| 
      
 29681 
     | 
    
         
            +
                        columnsResolver,
         
     | 
| 
      
 29682 
     | 
    
         
            +
                        validatedPrev,
         
     | 
| 
      
 29683 
     | 
    
         
            +
                        validatedCur
         
     | 
| 
      
 29684 
     | 
    
         
            +
                      ));
         
     | 
| 
      
 29685 
     | 
    
         
            +
                    }
         
     | 
| 
       28829 
29686 
     | 
    
         
             
                    writeResult({
         
     | 
| 
       28830 
29687 
     | 
    
         
             
                      cur,
         
     | 
| 
       28831 
29688 
     | 
    
         
             
                      sqlStatements,
         
     | 
| 
         @@ -28841,13 +29698,51 @@ var init_migrate = __esm({ 
     | 
|
| 
       28841 
29698 
     | 
    
         
             
                    console.error(e2);
         
     | 
| 
       28842 
29699 
     | 
    
         
             
                  }
         
     | 
| 
       28843 
29700 
     | 
    
         
             
                };
         
     | 
| 
       28844 
     | 
    
         
            -
                prepareSQLitePush = async (schemaPath, snapshot) => {
         
     | 
| 
      
 29701 
     | 
    
         
            +
                prepareSQLitePush = async (schemaPath, snapshot, driver2) => {
         
     | 
| 
      
 29702 
     | 
    
         
            +
                  const { prev, cur } = await prepareSQLiteDbPushSnapshot(snapshot, schemaPath);
         
     | 
| 
      
 29703 
     | 
    
         
            +
                  const validatedPrev = sqliteSchema.parse(prev);
         
     | 
| 
      
 29704 
     | 
    
         
            +
                  const validatedCur = sqliteSchema.parse(cur);
         
     | 
| 
      
 29705 
     | 
    
         
            +
                  const squashedPrev = squashSqliteScheme(validatedPrev, "push");
         
     | 
| 
      
 29706 
     | 
    
         
            +
                  const squashedCur = squashSqliteScheme(validatedCur, "push");
         
     | 
| 
      
 29707 
     | 
    
         
            +
                  let sqlStatements;
         
     | 
| 
      
 29708 
     | 
    
         
            +
                  let statements;
         
     | 
| 
      
 29709 
     | 
    
         
            +
                  let _meta;
         
     | 
| 
      
 29710 
     | 
    
         
            +
                  if (driver2 === "turso") {
         
     | 
| 
      
 29711 
     | 
    
         
            +
                    ({ sqlStatements, statements, _meta } = await applyLibSQLSnapshotsDiff(
         
     | 
| 
      
 29712 
     | 
    
         
            +
                      squashedPrev,
         
     | 
| 
      
 29713 
     | 
    
         
            +
                      squashedCur,
         
     | 
| 
      
 29714 
     | 
    
         
            +
                      tablesResolver,
         
     | 
| 
      
 29715 
     | 
    
         
            +
                      columnsResolver,
         
     | 
| 
      
 29716 
     | 
    
         
            +
                      validatedPrev,
         
     | 
| 
      
 29717 
     | 
    
         
            +
                      validatedCur,
         
     | 
| 
      
 29718 
     | 
    
         
            +
                      "push"
         
     | 
| 
      
 29719 
     | 
    
         
            +
                    ));
         
     | 
| 
      
 29720 
     | 
    
         
            +
                  } else {
         
     | 
| 
      
 29721 
     | 
    
         
            +
                    ({ sqlStatements, statements, _meta } = await applySqliteSnapshotsDiff(
         
     | 
| 
      
 29722 
     | 
    
         
            +
                      squashedPrev,
         
     | 
| 
      
 29723 
     | 
    
         
            +
                      squashedCur,
         
     | 
| 
      
 29724 
     | 
    
         
            +
                      tablesResolver,
         
     | 
| 
      
 29725 
     | 
    
         
            +
                      columnsResolver,
         
     | 
| 
      
 29726 
     | 
    
         
            +
                      validatedPrev,
         
     | 
| 
      
 29727 
     | 
    
         
            +
                      validatedCur,
         
     | 
| 
      
 29728 
     | 
    
         
            +
                      "push"
         
     | 
| 
      
 29729 
     | 
    
         
            +
                    ));
         
     | 
| 
      
 29730 
     | 
    
         
            +
                  }
         
     | 
| 
      
 29731 
     | 
    
         
            +
                  return {
         
     | 
| 
      
 29732 
     | 
    
         
            +
                    sqlStatements,
         
     | 
| 
      
 29733 
     | 
    
         
            +
                    statements,
         
     | 
| 
      
 29734 
     | 
    
         
            +
                    squashedPrev,
         
     | 
| 
      
 29735 
     | 
    
         
            +
                    squashedCur,
         
     | 
| 
      
 29736 
     | 
    
         
            +
                    meta: _meta
         
     | 
| 
      
 29737 
     | 
    
         
            +
                  };
         
     | 
| 
      
 29738 
     | 
    
         
            +
                };
         
     | 
| 
      
 29739 
     | 
    
         
            +
                prepareLibSQLPush = async (schemaPath, snapshot) => {
         
     | 
| 
       28845 
29740 
     | 
    
         
             
                  const { prev, cur } = await prepareSQLiteDbPushSnapshot(snapshot, schemaPath);
         
     | 
| 
       28846 
29741 
     | 
    
         
             
                  const validatedPrev = sqliteSchema.parse(prev);
         
     | 
| 
       28847 
29742 
     | 
    
         
             
                  const validatedCur = sqliteSchema.parse(cur);
         
     | 
| 
       28848 
29743 
     | 
    
         
             
                  const squashedPrev = squashSqliteScheme(validatedPrev, "push");
         
     | 
| 
       28849 
29744 
     | 
    
         
             
                  const squashedCur = squashSqliteScheme(validatedCur, "push");
         
     | 
| 
       28850 
     | 
    
         
            -
                  const { sqlStatements, statements, _meta } = await  
     | 
| 
      
 29745 
     | 
    
         
            +
                  const { sqlStatements, statements, _meta } = await applyLibSQLSnapshotsDiff(
         
     | 
| 
       28851 
29746 
     | 
    
         
             
                    squashedPrev,
         
     | 
| 
       28852 
29747 
     | 
    
         
             
                    squashedCur,
         
     | 
| 
       28853 
29748 
     | 
    
         
             
                    tablesResolver,
         
     | 
| 
         @@ -72205,8 +73100,271 @@ var init_selector_ui = __esm({ 
     | 
|
| 
       72205 
73100 
     | 
    
         
             
              }
         
     | 
| 
       72206 
73101 
     | 
    
         
             
            });
         
     | 
| 
       72207 
73102 
     | 
    
         | 
| 
      
 73103 
     | 
    
         
            +
            // src/cli/commands/libSqlPushUtils.ts
         
     | 
| 
      
 73104 
     | 
    
         
            +
            var getOldTableName3, _moveDataStatements2, libSqlLogSuggestionsAndReturn;
         
     | 
| 
      
 73105 
     | 
    
         
            +
            var init_libSqlPushUtils = __esm({
         
     | 
| 
      
 73106 
     | 
    
         
            +
              "src/cli/commands/libSqlPushUtils.ts"() {
         
     | 
| 
      
 73107 
     | 
    
         
            +
                "use strict";
         
     | 
| 
      
 73108 
     | 
    
         
            +
                init_source();
         
     | 
| 
      
 73109 
     | 
    
         
            +
                init_utils();
         
     | 
| 
      
 73110 
     | 
    
         
            +
                init_sqliteSchema();
         
     | 
| 
      
 73111 
     | 
    
         
            +
                init_sqlgenerator();
         
     | 
| 
      
 73112 
     | 
    
         
            +
                getOldTableName3 = (tableName, meta) => {
         
     | 
| 
      
 73113 
     | 
    
         
            +
                  for (const key of Object.keys(meta.tables)) {
         
     | 
| 
      
 73114 
     | 
    
         
            +
                    const value = meta.tables[key];
         
     | 
| 
      
 73115 
     | 
    
         
            +
                    if (`"${tableName}"` === value) {
         
     | 
| 
      
 73116 
     | 
    
         
            +
                      return key.substring(1, key.length - 1);
         
     | 
| 
      
 73117 
     | 
    
         
            +
                    }
         
     | 
| 
      
 73118 
     | 
    
         
            +
                  }
         
     | 
| 
      
 73119 
     | 
    
         
            +
                  return tableName;
         
     | 
| 
      
 73120 
     | 
    
         
            +
                };
         
     | 
| 
      
 73121 
     | 
    
         
            +
                _moveDataStatements2 = (tableName, json, dataLoss = false) => {
         
     | 
| 
      
 73122 
     | 
    
         
            +
                  const statements = [];
         
     | 
| 
      
 73123 
     | 
    
         
            +
                  const newTableName = `__new_${tableName}`;
         
     | 
| 
      
 73124 
     | 
    
         
            +
                  const tableColumns = Object.values(json.tables[tableName].columns);
         
     | 
| 
      
 73125 
     | 
    
         
            +
                  const referenceData = Object.values(json.tables[tableName].foreignKeys);
         
     | 
| 
      
 73126 
     | 
    
         
            +
                  const compositePKs = Object.values(
         
     | 
| 
      
 73127 
     | 
    
         
            +
                    json.tables[tableName].compositePrimaryKeys
         
     | 
| 
      
 73128 
     | 
    
         
            +
                  ).map((it) => SQLiteSquasher.unsquashPK(it));
         
     | 
| 
      
 73129 
     | 
    
         
            +
                  const fks = referenceData.map((it) => SQLiteSquasher.unsquashPushFK(it));
         
     | 
| 
      
 73130 
     | 
    
         
            +
                  statements.push(
         
     | 
| 
      
 73131 
     | 
    
         
            +
                    new SQLiteCreateTableConvertor().convert({
         
     | 
| 
      
 73132 
     | 
    
         
            +
                      type: "sqlite_create_table",
         
     | 
| 
      
 73133 
     | 
    
         
            +
                      tableName: newTableName,
         
     | 
| 
      
 73134 
     | 
    
         
            +
                      columns: tableColumns,
         
     | 
| 
      
 73135 
     | 
    
         
            +
                      referenceData: fks,
         
     | 
| 
      
 73136 
     | 
    
         
            +
                      compositePKs
         
     | 
| 
      
 73137 
     | 
    
         
            +
                    })
         
     | 
| 
      
 73138 
     | 
    
         
            +
                  );
         
     | 
| 
      
 73139 
     | 
    
         
            +
                  if (!dataLoss) {
         
     | 
| 
      
 73140 
     | 
    
         
            +
                    const columns = Object.keys(json.tables[tableName].columns).map(
         
     | 
| 
      
 73141 
     | 
    
         
            +
                      (c) => `"${c}"`
         
     | 
| 
      
 73142 
     | 
    
         
            +
                    );
         
     | 
| 
      
 73143 
     | 
    
         
            +
                    statements.push(
         
     | 
| 
      
 73144 
     | 
    
         
            +
                      `INSERT INTO \`${newTableName}\`(${columns.join(
         
     | 
| 
      
 73145 
     | 
    
         
            +
                        ", "
         
     | 
| 
      
 73146 
     | 
    
         
            +
                      )}) SELECT ${columns.join(", ")} FROM \`${tableName}\`;`
         
     | 
| 
      
 73147 
     | 
    
         
            +
                    );
         
     | 
| 
      
 73148 
     | 
    
         
            +
                  }
         
     | 
| 
      
 73149 
     | 
    
         
            +
                  statements.push(
         
     | 
| 
      
 73150 
     | 
    
         
            +
                    new SQLiteDropTableConvertor().convert({
         
     | 
| 
      
 73151 
     | 
    
         
            +
                      type: "drop_table",
         
     | 
| 
      
 73152 
     | 
    
         
            +
                      tableName,
         
     | 
| 
      
 73153 
     | 
    
         
            +
                      schema: ""
         
     | 
| 
      
 73154 
     | 
    
         
            +
                    })
         
     | 
| 
      
 73155 
     | 
    
         
            +
                  );
         
     | 
| 
      
 73156 
     | 
    
         
            +
                  statements.push(
         
     | 
| 
      
 73157 
     | 
    
         
            +
                    new SqliteRenameTableConvertor().convert({
         
     | 
| 
      
 73158 
     | 
    
         
            +
                      fromSchema: "",
         
     | 
| 
      
 73159 
     | 
    
         
            +
                      tableNameFrom: newTableName,
         
     | 
| 
      
 73160 
     | 
    
         
            +
                      tableNameTo: tableName,
         
     | 
| 
      
 73161 
     | 
    
         
            +
                      toSchema: "",
         
     | 
| 
      
 73162 
     | 
    
         
            +
                      type: "rename_table"
         
     | 
| 
      
 73163 
     | 
    
         
            +
                    })
         
     | 
| 
      
 73164 
     | 
    
         
            +
                  );
         
     | 
| 
      
 73165 
     | 
    
         
            +
                  for (const idx of Object.values(json.tables[tableName].indexes)) {
         
     | 
| 
      
 73166 
     | 
    
         
            +
                    statements.push(
         
     | 
| 
      
 73167 
     | 
    
         
            +
                      new CreateSqliteIndexConvertor().convert({
         
     | 
| 
      
 73168 
     | 
    
         
            +
                        type: "create_index",
         
     | 
| 
      
 73169 
     | 
    
         
            +
                        tableName,
         
     | 
| 
      
 73170 
     | 
    
         
            +
                        schema: "",
         
     | 
| 
      
 73171 
     | 
    
         
            +
                        data: idx
         
     | 
| 
      
 73172 
     | 
    
         
            +
                      })
         
     | 
| 
      
 73173 
     | 
    
         
            +
                    );
         
     | 
| 
      
 73174 
     | 
    
         
            +
                  }
         
     | 
| 
      
 73175 
     | 
    
         
            +
                  return statements;
         
     | 
| 
      
 73176 
     | 
    
         
            +
                };
         
     | 
| 
      
 73177 
     | 
    
         
            +
                libSqlLogSuggestionsAndReturn = async (connection, statements, json1, json2, meta) => {
         
     | 
| 
      
 73178 
     | 
    
         
            +
                  let shouldAskForApprove = false;
         
     | 
| 
      
 73179 
     | 
    
         
            +
                  const statementsToExecute = [];
         
     | 
| 
      
 73180 
     | 
    
         
            +
                  const infoToPrint = [];
         
     | 
| 
      
 73181 
     | 
    
         
            +
                  const tablesToRemove = [];
         
     | 
| 
      
 73182 
     | 
    
         
            +
                  const columnsToRemove = [];
         
     | 
| 
      
 73183 
     | 
    
         
            +
                  const tablesToTruncate = [];
         
     | 
| 
      
 73184 
     | 
    
         
            +
                  for (const statement of statements) {
         
     | 
| 
      
 73185 
     | 
    
         
            +
                    if (statement.type === "drop_table") {
         
     | 
| 
      
 73186 
     | 
    
         
            +
                      const res = await connection.query(
         
     | 
| 
      
 73187 
     | 
    
         
            +
                        `select count(*) as count from \`${statement.tableName}\``
         
     | 
| 
      
 73188 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73189 
     | 
    
         
            +
                      const count = Number(res[0].count);
         
     | 
| 
      
 73190 
     | 
    
         
            +
                      if (count > 0) {
         
     | 
| 
      
 73191 
     | 
    
         
            +
                        infoToPrint.push(
         
     | 
| 
      
 73192 
     | 
    
         
            +
                          `\xB7 You're about to delete ${source_default.underline(
         
     | 
| 
      
 73193 
     | 
    
         
            +
                            statement.tableName
         
     | 
| 
      
 73194 
     | 
    
         
            +
                          )} table with ${count} items`
         
     | 
| 
      
 73195 
     | 
    
         
            +
                        );
         
     | 
| 
      
 73196 
     | 
    
         
            +
                        tablesToRemove.push(statement.tableName);
         
     | 
| 
      
 73197 
     | 
    
         
            +
                        shouldAskForApprove = true;
         
     | 
| 
      
 73198 
     | 
    
         
            +
                      }
         
     | 
| 
      
 73199 
     | 
    
         
            +
                      const fromJsonStatement = fromJson([statement], "sqlite", "push", "turso", json2);
         
     | 
| 
      
 73200 
     | 
    
         
            +
                      statementsToExecute.push(
         
     | 
| 
      
 73201 
     | 
    
         
            +
                        ...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
         
     | 
| 
      
 73202 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73203 
     | 
    
         
            +
                    } else if (statement.type === "alter_table_drop_column") {
         
     | 
| 
      
 73204 
     | 
    
         
            +
                      const tableName = statement.tableName;
         
     | 
| 
      
 73205 
     | 
    
         
            +
                      const res = await connection.query(
         
     | 
| 
      
 73206 
     | 
    
         
            +
                        `select count(*) as count from \`${tableName}\``
         
     | 
| 
      
 73207 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73208 
     | 
    
         
            +
                      const count = Number(res[0].count);
         
     | 
| 
      
 73209 
     | 
    
         
            +
                      if (count > 0) {
         
     | 
| 
      
 73210 
     | 
    
         
            +
                        infoToPrint.push(
         
     | 
| 
      
 73211 
     | 
    
         
            +
                          `\xB7 You're about to delete ${source_default.underline(
         
     | 
| 
      
 73212 
     | 
    
         
            +
                            statement.columnName
         
     | 
| 
      
 73213 
     | 
    
         
            +
                          )} column in ${tableName} table with ${count} items`
         
     | 
| 
      
 73214 
     | 
    
         
            +
                        );
         
     | 
| 
      
 73215 
     | 
    
         
            +
                        columnsToRemove.push(`${tableName}_${statement.columnName}`);
         
     | 
| 
      
 73216 
     | 
    
         
            +
                        shouldAskForApprove = true;
         
     | 
| 
      
 73217 
     | 
    
         
            +
                      }
         
     | 
| 
      
 73218 
     | 
    
         
            +
                      const fromJsonStatement = fromJson([statement], "sqlite", "push", "turso", json2);
         
     | 
| 
      
 73219 
     | 
    
         
            +
                      statementsToExecute.push(
         
     | 
| 
      
 73220 
     | 
    
         
            +
                        ...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
         
     | 
| 
      
 73221 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73222 
     | 
    
         
            +
                    } else if (statement.type === "sqlite_alter_table_add_column" && statement.column.notNull && !statement.column.default) {
         
     | 
| 
      
 73223 
     | 
    
         
            +
                      const newTableName = statement.tableName;
         
     | 
| 
      
 73224 
     | 
    
         
            +
                      const res = await connection.query(
         
     | 
| 
      
 73225 
     | 
    
         
            +
                        `select count(*) as count from \`${newTableName}\``
         
     | 
| 
      
 73226 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73227 
     | 
    
         
            +
                      const count = Number(res[0].count);
         
     | 
| 
      
 73228 
     | 
    
         
            +
                      if (count > 0) {
         
     | 
| 
      
 73229 
     | 
    
         
            +
                        infoToPrint.push(
         
     | 
| 
      
 73230 
     | 
    
         
            +
                          `\xB7 You're about to add not-null ${source_default.underline(
         
     | 
| 
      
 73231 
     | 
    
         
            +
                            statement.column.name
         
     | 
| 
      
 73232 
     | 
    
         
            +
                          )} column without default value, which contains ${count} items`
         
     | 
| 
      
 73233 
     | 
    
         
            +
                        );
         
     | 
| 
      
 73234 
     | 
    
         
            +
                        tablesToTruncate.push(newTableName);
         
     | 
| 
      
 73235 
     | 
    
         
            +
                        statementsToExecute.push(`delete from ${newTableName};`);
         
     | 
| 
      
 73236 
     | 
    
         
            +
                        shouldAskForApprove = true;
         
     | 
| 
      
 73237 
     | 
    
         
            +
                      }
         
     | 
| 
      
 73238 
     | 
    
         
            +
                      const fromJsonStatement = fromJson([statement], "sqlite", "push", "turso", json2);
         
     | 
| 
      
 73239 
     | 
    
         
            +
                      statementsToExecute.push(
         
     | 
| 
      
 73240 
     | 
    
         
            +
                        ...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
         
     | 
| 
      
 73241 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73242 
     | 
    
         
            +
                    } else if (statement.type === "alter_table_alter_column_set_notnull") {
         
     | 
| 
      
 73243 
     | 
    
         
            +
                      const tableName = statement.tableName;
         
     | 
| 
      
 73244 
     | 
    
         
            +
                      if (statement.type === "alter_table_alter_column_set_notnull" && typeof statement.columnDefault === "undefined") {
         
     | 
| 
      
 73245 
     | 
    
         
            +
                        const res = await connection.query(
         
     | 
| 
      
 73246 
     | 
    
         
            +
                          `select count(*) as count from \`${tableName}\``
         
     | 
| 
      
 73247 
     | 
    
         
            +
                        );
         
     | 
| 
      
 73248 
     | 
    
         
            +
                        const count = Number(res[0].count);
         
     | 
| 
      
 73249 
     | 
    
         
            +
                        if (count > 0) {
         
     | 
| 
      
 73250 
     | 
    
         
            +
                          infoToPrint.push(
         
     | 
| 
      
 73251 
     | 
    
         
            +
                            `\xB7 You're about to add not-null constraint to ${source_default.underline(
         
     | 
| 
      
 73252 
     | 
    
         
            +
                              statement.columnName
         
     | 
| 
      
 73253 
     | 
    
         
            +
                            )} column without default value, which contains ${count} items`
         
     | 
| 
      
 73254 
     | 
    
         
            +
                          );
         
     | 
| 
      
 73255 
     | 
    
         
            +
                          tablesToTruncate.push(tableName);
         
     | 
| 
      
 73256 
     | 
    
         
            +
                          statementsToExecute.push(`delete from \`${tableName}\``);
         
     | 
| 
      
 73257 
     | 
    
         
            +
                          shouldAskForApprove = true;
         
     | 
| 
      
 73258 
     | 
    
         
            +
                        }
         
     | 
| 
      
 73259 
     | 
    
         
            +
                      }
         
     | 
| 
      
 73260 
     | 
    
         
            +
                      const modifyStatements = new LibSQLModifyColumn().convert(statement, json2);
         
     | 
| 
      
 73261 
     | 
    
         
            +
                      statementsToExecute.push(
         
     | 
| 
      
 73262 
     | 
    
         
            +
                        ...Array.isArray(modifyStatements) ? modifyStatements : [modifyStatements]
         
     | 
| 
      
 73263 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73264 
     | 
    
         
            +
                    } else if (statement.type === "recreate_table") {
         
     | 
| 
      
 73265 
     | 
    
         
            +
                      const tableName = statement.tableName;
         
     | 
| 
      
 73266 
     | 
    
         
            +
                      let dataLoss = false;
         
     | 
| 
      
 73267 
     | 
    
         
            +
                      const oldTableName = getOldTableName3(tableName, meta);
         
     | 
| 
      
 73268 
     | 
    
         
            +
                      const prevColumnNames = Object.keys(json1.tables[oldTableName].columns);
         
     | 
| 
      
 73269 
     | 
    
         
            +
                      const currentColumnNames = Object.keys(json2.tables[tableName].columns);
         
     | 
| 
      
 73270 
     | 
    
         
            +
                      const { removedColumns, addedColumns } = findAddedAndRemoved(
         
     | 
| 
      
 73271 
     | 
    
         
            +
                        prevColumnNames,
         
     | 
| 
      
 73272 
     | 
    
         
            +
                        currentColumnNames
         
     | 
| 
      
 73273 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73274 
     | 
    
         
            +
                      if (removedColumns.length) {
         
     | 
| 
      
 73275 
     | 
    
         
            +
                        for (const removedColumn of removedColumns) {
         
     | 
| 
      
 73276 
     | 
    
         
            +
                          const res = await connection.query(
         
     | 
| 
      
 73277 
     | 
    
         
            +
                            `select count(\`${tableName}\`.\`${removedColumn}\`) as count from \`${tableName}\``
         
     | 
| 
      
 73278 
     | 
    
         
            +
                          );
         
     | 
| 
      
 73279 
     | 
    
         
            +
                          const count = Number(res[0].count);
         
     | 
| 
      
 73280 
     | 
    
         
            +
                          if (count > 0) {
         
     | 
| 
      
 73281 
     | 
    
         
            +
                            infoToPrint.push(
         
     | 
| 
      
 73282 
     | 
    
         
            +
                              `\xB7 You're about to delete ${source_default.underline(
         
     | 
| 
      
 73283 
     | 
    
         
            +
                                removedColumn
         
     | 
| 
      
 73284 
     | 
    
         
            +
                              )} column in ${tableName} table with ${count} items`
         
     | 
| 
      
 73285 
     | 
    
         
            +
                            );
         
     | 
| 
      
 73286 
     | 
    
         
            +
                            columnsToRemove.push(removedColumn);
         
     | 
| 
      
 73287 
     | 
    
         
            +
                            shouldAskForApprove = true;
         
     | 
| 
      
 73288 
     | 
    
         
            +
                          }
         
     | 
| 
      
 73289 
     | 
    
         
            +
                        }
         
     | 
| 
      
 73290 
     | 
    
         
            +
                      }
         
     | 
| 
      
 73291 
     | 
    
         
            +
                      if (addedColumns.length) {
         
     | 
| 
      
 73292 
     | 
    
         
            +
                        for (const addedColumn of addedColumns) {
         
     | 
| 
      
 73293 
     | 
    
         
            +
                          const [res] = await connection.query(
         
     | 
| 
      
 73294 
     | 
    
         
            +
                            `select count(*) as count from \`${tableName}\``
         
     | 
| 
      
 73295 
     | 
    
         
            +
                          );
         
     | 
| 
      
 73296 
     | 
    
         
            +
                          const columnConf = json2.tables[tableName].columns[addedColumn];
         
     | 
| 
      
 73297 
     | 
    
         
            +
                          const count = Number(res.count);
         
     | 
| 
      
 73298 
     | 
    
         
            +
                          if (count > 0 && columnConf.notNull && !columnConf.default) {
         
     | 
| 
      
 73299 
     | 
    
         
            +
                            dataLoss = true;
         
     | 
| 
      
 73300 
     | 
    
         
            +
                            infoToPrint.push(
         
     | 
| 
      
 73301 
     | 
    
         
            +
                              `\xB7 You're about to add not-null ${source_default.underline(
         
     | 
| 
      
 73302 
     | 
    
         
            +
                                addedColumn
         
     | 
| 
      
 73303 
     | 
    
         
            +
                              )} column without default value to table, which contains ${count} items`
         
     | 
| 
      
 73304 
     | 
    
         
            +
                            );
         
     | 
| 
      
 73305 
     | 
    
         
            +
                            shouldAskForApprove = true;
         
     | 
| 
      
 73306 
     | 
    
         
            +
                            tablesToTruncate.push(tableName);
         
     | 
| 
      
 73307 
     | 
    
         
            +
                            statementsToExecute.push(`DELETE FROM \`${tableName}\`;`);
         
     | 
| 
      
 73308 
     | 
    
         
            +
                          }
         
     | 
| 
      
 73309 
     | 
    
         
            +
                        }
         
     | 
| 
      
 73310 
     | 
    
         
            +
                      }
         
     | 
| 
      
 73311 
     | 
    
         
            +
                      const tablesReferencingCurrent = [];
         
     | 
| 
      
 73312 
     | 
    
         
            +
                      for (const table4 of Object.values(json2.tables)) {
         
     | 
| 
      
 73313 
     | 
    
         
            +
                        const tablesRefs = Object.values(json2.tables[table4.name].foreignKeys).filter((t2) => SQLiteSquasher.unsquashPushFK(t2).tableTo === tableName).map((it) => SQLiteSquasher.unsquashPushFK(it).tableFrom);
         
     | 
| 
      
 73314 
     | 
    
         
            +
                        tablesReferencingCurrent.push(...tablesRefs);
         
     | 
| 
      
 73315 
     | 
    
         
            +
                      }
         
     | 
| 
      
 73316 
     | 
    
         
            +
                      if (!tablesReferencingCurrent.length) {
         
     | 
| 
      
 73317 
     | 
    
         
            +
                        statementsToExecute.push(..._moveDataStatements2(tableName, json2, dataLoss));
         
     | 
| 
      
 73318 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 73319 
     | 
    
         
            +
                      }
         
     | 
| 
      
 73320 
     | 
    
         
            +
                      const [{ foreign_keys: pragmaState }] = await connection.query(`PRAGMA foreign_keys;`);
         
     | 
| 
      
 73321 
     | 
    
         
            +
                      if (pragmaState)
         
     | 
| 
      
 73322 
     | 
    
         
            +
                        statementsToExecute.push(`PRAGMA foreign_keys=OFF;`);
         
     | 
| 
      
 73323 
     | 
    
         
            +
                      statementsToExecute.push(
         
     | 
| 
      
 73324 
     | 
    
         
            +
                        ..._moveDataStatements2(tableName, json2, dataLoss)
         
     | 
| 
      
 73325 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73326 
     | 
    
         
            +
                      if (pragmaState)
         
     | 
| 
      
 73327 
     | 
    
         
            +
                        statementsToExecute.push(`PRAGMA foreign_keys=ON;`);
         
     | 
| 
      
 73328 
     | 
    
         
            +
                    } else if (statement.type === "alter_table_alter_column_set_generated" || statement.type === "alter_table_alter_column_drop_generated") {
         
     | 
| 
      
 73329 
     | 
    
         
            +
                      const tableName = statement.tableName;
         
     | 
| 
      
 73330 
     | 
    
         
            +
                      const res = await connection.query(
         
     | 
| 
      
 73331 
     | 
    
         
            +
                        `select count("${statement.columnName}") as count from \`${tableName}\``
         
     | 
| 
      
 73332 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73333 
     | 
    
         
            +
                      const count = Number(res[0].count);
         
     | 
| 
      
 73334 
     | 
    
         
            +
                      if (count > 0) {
         
     | 
| 
      
 73335 
     | 
    
         
            +
                        infoToPrint.push(
         
     | 
| 
      
 73336 
     | 
    
         
            +
                          `\xB7 You're about to delete ${source_default.underline(
         
     | 
| 
      
 73337 
     | 
    
         
            +
                            statement.columnName
         
     | 
| 
      
 73338 
     | 
    
         
            +
                          )} column in ${tableName} table with ${count} items`
         
     | 
| 
      
 73339 
     | 
    
         
            +
                        );
         
     | 
| 
      
 73340 
     | 
    
         
            +
                        columnsToRemove.push(`${tableName}_${statement.columnName}`);
         
     | 
| 
      
 73341 
     | 
    
         
            +
                        shouldAskForApprove = true;
         
     | 
| 
      
 73342 
     | 
    
         
            +
                      }
         
     | 
| 
      
 73343 
     | 
    
         
            +
                      const fromJsonStatement = fromJson([statement], "sqlite", "push", "turso", json2);
         
     | 
| 
      
 73344 
     | 
    
         
            +
                      statementsToExecute.push(
         
     | 
| 
      
 73345 
     | 
    
         
            +
                        ...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
         
     | 
| 
      
 73346 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73347 
     | 
    
         
            +
                    } else {
         
     | 
| 
      
 73348 
     | 
    
         
            +
                      const fromJsonStatement = fromJson([statement], "sqlite", "push", "turso", json2);
         
     | 
| 
      
 73349 
     | 
    
         
            +
                      statementsToExecute.push(
         
     | 
| 
      
 73350 
     | 
    
         
            +
                        ...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
         
     | 
| 
      
 73351 
     | 
    
         
            +
                      );
         
     | 
| 
      
 73352 
     | 
    
         
            +
                    }
         
     | 
| 
      
 73353 
     | 
    
         
            +
                  }
         
     | 
| 
      
 73354 
     | 
    
         
            +
                  return {
         
     | 
| 
      
 73355 
     | 
    
         
            +
                    statementsToExecute: [...new Set(statementsToExecute)],
         
     | 
| 
      
 73356 
     | 
    
         
            +
                    shouldAskForApprove,
         
     | 
| 
      
 73357 
     | 
    
         
            +
                    infoToPrint,
         
     | 
| 
      
 73358 
     | 
    
         
            +
                    columnsToRemove: [...new Set(columnsToRemove)],
         
     | 
| 
      
 73359 
     | 
    
         
            +
                    tablesToTruncate: [...new Set(tablesToTruncate)],
         
     | 
| 
      
 73360 
     | 
    
         
            +
                    tablesToRemove: [...new Set(tablesToRemove)]
         
     | 
| 
      
 73361 
     | 
    
         
            +
                  };
         
     | 
| 
      
 73362 
     | 
    
         
            +
                };
         
     | 
| 
      
 73363 
     | 
    
         
            +
              }
         
     | 
| 
      
 73364 
     | 
    
         
            +
            });
         
     | 
| 
      
 73365 
     | 
    
         
            +
             
     | 
| 
       72208 
73366 
     | 
    
         
             
            // src/cli/commands/mysqlPushUtils.ts
         
     | 
| 
       72209 
     | 
    
         
            -
            var import_hanji6, filterStatements,  
     | 
| 
      
 73367 
     | 
    
         
            +
            var import_hanji6, filterStatements, logSuggestionsAndReturn2;
         
     | 
| 
       72210 
73368 
     | 
    
         
             
            var init_mysqlPushUtils = __esm({
         
     | 
| 
       72211 
73369 
     | 
    
         
             
              "src/cli/commands/mysqlPushUtils.ts"() {
         
     | 
| 
       72212 
73370 
     | 
    
         
             
                "use strict";
         
     | 
| 
         @@ -72256,7 +73414,7 @@ var init_mysqlPushUtils = __esm({ 
     | 
|
| 
       72256 
73414 
     | 
    
         
             
                    return true;
         
     | 
| 
       72257 
73415 
     | 
    
         
             
                  });
         
     | 
| 
       72258 
73416 
     | 
    
         
             
                };
         
     | 
| 
       72259 
     | 
    
         
            -
                 
     | 
| 
      
 73417 
     | 
    
         
            +
                logSuggestionsAndReturn2 = async (db, statements, json2) => {
         
     | 
| 
       72260 
73418 
     | 
    
         
             
                  let shouldAskForApprove = false;
         
     | 
| 
       72261 
73419 
     | 
    
         
             
                  const statementsToExecute = [];
         
     | 
| 
       72262 
73420 
     | 
    
         
             
                  const infoToPrint = [];
         
     | 
| 
         @@ -72697,289 +73855,6 @@ var init_pgPushUtils = __esm({ 
     | 
|
| 
       72697 
73855 
     | 
    
         
             
              }
         
     | 
| 
       72698 
73856 
     | 
    
         
             
            });
         
     | 
| 
       72699 
73857 
     | 
    
         | 
| 
       72700 
     | 
    
         
            -
            // src/cli/commands/sqlitePushUtils.ts
         
     | 
| 
       72701 
     | 
    
         
            -
            var _moveDataStatements, getOldTableName, getNewTableName, logSuggestionsAndReturn2;
         
     | 
| 
       72702 
     | 
    
         
            -
            var init_sqlitePushUtils = __esm({
         
     | 
| 
       72703 
     | 
    
         
            -
              "src/cli/commands/sqlitePushUtils.ts"() {
         
     | 
| 
       72704 
     | 
    
         
            -
                "use strict";
         
     | 
| 
       72705 
     | 
    
         
            -
                init_source();
         
     | 
| 
       72706 
     | 
    
         
            -
                init_sqliteSchema();
         
     | 
| 
       72707 
     | 
    
         
            -
                init_sqlgenerator();
         
     | 
| 
       72708 
     | 
    
         
            -
                _moveDataStatements = (tableName, json, dataLoss = false) => {
         
     | 
| 
       72709 
     | 
    
         
            -
                  const statements = [];
         
     | 
| 
       72710 
     | 
    
         
            -
                  statements.push(
         
     | 
| 
       72711 
     | 
    
         
            -
                    new SqliteRenameTableConvertor().convert({
         
     | 
| 
       72712 
     | 
    
         
            -
                      type: "rename_table",
         
     | 
| 
       72713 
     | 
    
         
            -
                      tableNameFrom: tableName,
         
     | 
| 
       72714 
     | 
    
         
            -
                      tableNameTo: `__old_push_${tableName}`,
         
     | 
| 
       72715 
     | 
    
         
            -
                      fromSchema: "",
         
     | 
| 
       72716 
     | 
    
         
            -
                      toSchema: ""
         
     | 
| 
       72717 
     | 
    
         
            -
                    })
         
     | 
| 
       72718 
     | 
    
         
            -
                  );
         
     | 
| 
       72719 
     | 
    
         
            -
                  const tableColumns = Object.values(json.tables[tableName].columns);
         
     | 
| 
       72720 
     | 
    
         
            -
                  const referenceData = Object.values(json.tables[tableName].foreignKeys);
         
     | 
| 
       72721 
     | 
    
         
            -
                  const compositePKs = Object.values(
         
     | 
| 
       72722 
     | 
    
         
            -
                    json.tables[tableName].compositePrimaryKeys
         
     | 
| 
       72723 
     | 
    
         
            -
                  ).map((it) => SQLiteSquasher.unsquashPK(it));
         
     | 
| 
       72724 
     | 
    
         
            -
                  const fks = referenceData.map((it) => SQLiteSquasher.unsquashPushFK(it));
         
     | 
| 
       72725 
     | 
    
         
            -
                  statements.push(
         
     | 
| 
       72726 
     | 
    
         
            -
                    new SQLiteCreateTableConvertor().convert({
         
     | 
| 
       72727 
     | 
    
         
            -
                      type: "sqlite_create_table",
         
     | 
| 
       72728 
     | 
    
         
            -
                      tableName,
         
     | 
| 
       72729 
     | 
    
         
            -
                      columns: tableColumns,
         
     | 
| 
       72730 
     | 
    
         
            -
                      referenceData: fks,
         
     | 
| 
       72731 
     | 
    
         
            -
                      compositePKs
         
     | 
| 
       72732 
     | 
    
         
            -
                    })
         
     | 
| 
       72733 
     | 
    
         
            -
                  );
         
     | 
| 
       72734 
     | 
    
         
            -
                  if (!dataLoss) {
         
     | 
| 
       72735 
     | 
    
         
            -
                    statements.push(
         
     | 
| 
       72736 
     | 
    
         
            -
                      `INSERT INTO "${tableName}" SELECT * FROM "__old_push_${tableName}";`
         
     | 
| 
       72737 
     | 
    
         
            -
                    );
         
     | 
| 
       72738 
     | 
    
         
            -
                  }
         
     | 
| 
       72739 
     | 
    
         
            -
                  statements.push(
         
     | 
| 
       72740 
     | 
    
         
            -
                    new SQLiteDropTableConvertor().convert({
         
     | 
| 
       72741 
     | 
    
         
            -
                      type: "drop_table",
         
     | 
| 
       72742 
     | 
    
         
            -
                      tableName: `__old_push_${tableName}`,
         
     | 
| 
       72743 
     | 
    
         
            -
                      schema: ""
         
     | 
| 
       72744 
     | 
    
         
            -
                    })
         
     | 
| 
       72745 
     | 
    
         
            -
                  );
         
     | 
| 
       72746 
     | 
    
         
            -
                  for (const idx of Object.values(json.tables[tableName].indexes)) {
         
     | 
| 
       72747 
     | 
    
         
            -
                    statements.push(
         
     | 
| 
       72748 
     | 
    
         
            -
                      new CreateSqliteIndexConvertor().convert({
         
     | 
| 
       72749 
     | 
    
         
            -
                        type: "create_index",
         
     | 
| 
       72750 
     | 
    
         
            -
                        tableName,
         
     | 
| 
       72751 
     | 
    
         
            -
                        schema: "",
         
     | 
| 
       72752 
     | 
    
         
            -
                        data: idx
         
     | 
| 
       72753 
     | 
    
         
            -
                      })
         
     | 
| 
       72754 
     | 
    
         
            -
                    );
         
     | 
| 
       72755 
     | 
    
         
            -
                  }
         
     | 
| 
       72756 
     | 
    
         
            -
                  return statements;
         
     | 
| 
       72757 
     | 
    
         
            -
                };
         
     | 
| 
       72758 
     | 
    
         
            -
                getOldTableName = (tableName, meta) => {
         
     | 
| 
       72759 
     | 
    
         
            -
                  for (const key of Object.keys(meta.tables)) {
         
     | 
| 
       72760 
     | 
    
         
            -
                    const value = meta.tables[key];
         
     | 
| 
       72761 
     | 
    
         
            -
                    if (`"${tableName}"` === value) {
         
     | 
| 
       72762 
     | 
    
         
            -
                      return key.substring(1, key.length - 1);
         
     | 
| 
       72763 
     | 
    
         
            -
                    }
         
     | 
| 
       72764 
     | 
    
         
            -
                  }
         
     | 
| 
       72765 
     | 
    
         
            -
                  return tableName;
         
     | 
| 
       72766 
     | 
    
         
            -
                };
         
     | 
| 
       72767 
     | 
    
         
            -
                getNewTableName = (tableName, meta) => {
         
     | 
| 
       72768 
     | 
    
         
            -
                  if (typeof meta.tables[`"${tableName}"`] !== "undefined") {
         
     | 
| 
       72769 
     | 
    
         
            -
                    return meta.tables[`"${tableName}"`].substring(
         
     | 
| 
       72770 
     | 
    
         
            -
                      1,
         
     | 
| 
       72771 
     | 
    
         
            -
                      meta.tables[`"${tableName}"`].length - 1
         
     | 
| 
       72772 
     | 
    
         
            -
                    );
         
     | 
| 
       72773 
     | 
    
         
            -
                  }
         
     | 
| 
       72774 
     | 
    
         
            -
                  return tableName;
         
     | 
| 
       72775 
     | 
    
         
            -
                };
         
     | 
| 
       72776 
     | 
    
         
            -
                logSuggestionsAndReturn2 = async (connection, statements, json1, json2, meta) => {
         
     | 
| 
       72777 
     | 
    
         
            -
                  let shouldAskForApprove = false;
         
     | 
| 
       72778 
     | 
    
         
            -
                  const statementsToExecute = [];
         
     | 
| 
       72779 
     | 
    
         
            -
                  const infoToPrint = [];
         
     | 
| 
       72780 
     | 
    
         
            -
                  const tablesToRemove = [];
         
     | 
| 
       72781 
     | 
    
         
            -
                  const columnsToRemove = [];
         
     | 
| 
       72782 
     | 
    
         
            -
                  const schemasToRemove = [];
         
     | 
| 
       72783 
     | 
    
         
            -
                  const tablesToTruncate = [];
         
     | 
| 
       72784 
     | 
    
         
            -
                  const tablesContext = {};
         
     | 
| 
       72785 
     | 
    
         
            -
                  for (const statement of statements) {
         
     | 
| 
       72786 
     | 
    
         
            -
                    if (statement.type === "drop_table") {
         
     | 
| 
       72787 
     | 
    
         
            -
                      const res = await connection.query(
         
     | 
| 
       72788 
     | 
    
         
            -
                        `select count(*) as count from \`${statement.tableName}\``
         
     | 
| 
       72789 
     | 
    
         
            -
                      );
         
     | 
| 
       72790 
     | 
    
         
            -
                      const count = Number(res[0].count);
         
     | 
| 
       72791 
     | 
    
         
            -
                      if (count > 0) {
         
     | 
| 
       72792 
     | 
    
         
            -
                        infoToPrint.push(
         
     | 
| 
       72793 
     | 
    
         
            -
                          `\xB7 You're about to delete ${source_default.underline(
         
     | 
| 
       72794 
     | 
    
         
            -
                            statement.tableName
         
     | 
| 
       72795 
     | 
    
         
            -
                          )} table with ${count} items`
         
     | 
| 
       72796 
     | 
    
         
            -
                        );
         
     | 
| 
       72797 
     | 
    
         
            -
                        tablesToRemove.push(statement.tableName);
         
     | 
| 
       72798 
     | 
    
         
            -
                        shouldAskForApprove = true;
         
     | 
| 
       72799 
     | 
    
         
            -
                      }
         
     | 
| 
       72800 
     | 
    
         
            -
                      const stmnt = fromJson([statement], "sqlite")[0];
         
     | 
| 
       72801 
     | 
    
         
            -
                      statementsToExecute.push(stmnt);
         
     | 
| 
       72802 
     | 
    
         
            -
                    } else if (statement.type === "alter_table_drop_column") {
         
     | 
| 
       72803 
     | 
    
         
            -
                      const newTableName = getOldTableName(statement.tableName, meta);
         
     | 
| 
       72804 
     | 
    
         
            -
                      const columnIsPartOfPk = Object.values(
         
     | 
| 
       72805 
     | 
    
         
            -
                        json1.tables[newTableName].compositePrimaryKeys
         
     | 
| 
       72806 
     | 
    
         
            -
                      ).find((c) => SQLiteSquasher.unsquashPK(c).includes(statement.columnName));
         
     | 
| 
       72807 
     | 
    
         
            -
                      const columnIsPartOfIndex = Object.values(
         
     | 
| 
       72808 
     | 
    
         
            -
                        json1.tables[newTableName].indexes
         
     | 
| 
       72809 
     | 
    
         
            -
                      ).find((c) => SQLiteSquasher.unsquashIdx(c).columns.includes(statement.columnName));
         
     | 
| 
       72810 
     | 
    
         
            -
                      const columnIsPk = json1.tables[newTableName].columns[statement.columnName].primaryKey;
         
     | 
| 
       72811 
     | 
    
         
            -
                      const columnIsPartOfFk = Object.values(
         
     | 
| 
       72812 
     | 
    
         
            -
                        json1.tables[newTableName].foreignKeys
         
     | 
| 
       72813 
     | 
    
         
            -
                      ).find(
         
     | 
| 
       72814 
     | 
    
         
            -
                        (t2) => SQLiteSquasher.unsquashPushFK(t2).columnsFrom.includes(
         
     | 
| 
       72815 
     | 
    
         
            -
                          statement.columnName
         
     | 
| 
       72816 
     | 
    
         
            -
                        )
         
     | 
| 
       72817 
     | 
    
         
            -
                      );
         
     | 
| 
       72818 
     | 
    
         
            -
                      const res = await connection.query(
         
     | 
| 
       72819 
     | 
    
         
            -
                        `select count(*) as count from \`${newTableName}\``
         
     | 
| 
       72820 
     | 
    
         
            -
                      );
         
     | 
| 
       72821 
     | 
    
         
            -
                      const count = Number(res[0].count);
         
     | 
| 
       72822 
     | 
    
         
            -
                      if (count > 0) {
         
     | 
| 
       72823 
     | 
    
         
            -
                        infoToPrint.push(
         
     | 
| 
       72824 
     | 
    
         
            -
                          `\xB7 You're about to delete ${source_default.underline(
         
     | 
| 
       72825 
     | 
    
         
            -
                            statement.columnName
         
     | 
| 
       72826 
     | 
    
         
            -
                          )} column in ${newTableName} table with ${count} items`
         
     | 
| 
       72827 
     | 
    
         
            -
                        );
         
     | 
| 
       72828 
     | 
    
         
            -
                        columnsToRemove.push(`${newTableName}_${statement.columnName}`);
         
     | 
| 
       72829 
     | 
    
         
            -
                        shouldAskForApprove = true;
         
     | 
| 
       72830 
     | 
    
         
            -
                      }
         
     | 
| 
       72831 
     | 
    
         
            -
                      if (columnIsPk || columnIsPartOfPk || columnIsPartOfIndex || columnIsPartOfFk) {
         
     | 
| 
       72832 
     | 
    
         
            -
                        tablesContext[newTableName] = [
         
     | 
| 
       72833 
     | 
    
         
            -
                          ..._moveDataStatements(statement.tableName, json2, true)
         
     | 
| 
       72834 
     | 
    
         
            -
                        ];
         
     | 
| 
       72835 
     | 
    
         
            -
                        const tablesReferncingCurrent = [];
         
     | 
| 
       72836 
     | 
    
         
            -
                        for (const table4 of Object.values(json1.tables)) {
         
     | 
| 
       72837 
     | 
    
         
            -
                          const tablesRefs = Object.values(json1.tables[table4.name].foreignKeys).filter(
         
     | 
| 
       72838 
     | 
    
         
            -
                            (t2) => SQLiteSquasher.unsquashPushFK(t2).tableTo === newTableName
         
     | 
| 
       72839 
     | 
    
         
            -
                          ).map((t2) => SQLiteSquasher.unsquashPushFK(t2).tableFrom);
         
     | 
| 
       72840 
     | 
    
         
            -
                          tablesReferncingCurrent.push(...tablesRefs);
         
     | 
| 
       72841 
     | 
    
         
            -
                        }
         
     | 
| 
       72842 
     | 
    
         
            -
                        const uniqueTableRefs = [...new Set(tablesReferncingCurrent)];
         
     | 
| 
       72843 
     | 
    
         
            -
                        for (const table4 of uniqueTableRefs) {
         
     | 
| 
       72844 
     | 
    
         
            -
                          if (typeof tablesContext[table4] === "undefined") {
         
     | 
| 
       72845 
     | 
    
         
            -
                            tablesContext[table4] = [..._moveDataStatements(table4, json2)];
         
     | 
| 
       72846 
     | 
    
         
            -
                          }
         
     | 
| 
       72847 
     | 
    
         
            -
                        }
         
     | 
| 
       72848 
     | 
    
         
            -
                      } else {
         
     | 
| 
       72849 
     | 
    
         
            -
                        if (typeof tablesContext[newTableName] === "undefined") {
         
     | 
| 
       72850 
     | 
    
         
            -
                          const stmnt = fromJson([statement], "sqlite")[0];
         
     | 
| 
       72851 
     | 
    
         
            -
                          statementsToExecute.push(stmnt);
         
     | 
| 
       72852 
     | 
    
         
            -
                        }
         
     | 
| 
       72853 
     | 
    
         
            -
                      }
         
     | 
| 
       72854 
     | 
    
         
            -
                    } else if (statement.type === "sqlite_alter_table_add_column") {
         
     | 
| 
       72855 
     | 
    
         
            -
                      const newTableName = getOldTableName(statement.tableName, meta);
         
     | 
| 
       72856 
     | 
    
         
            -
                      if (statement.column.notNull && !statement.column.default) {
         
     | 
| 
       72857 
     | 
    
         
            -
                        const res = await connection.query(
         
     | 
| 
       72858 
     | 
    
         
            -
                          `select count(*) as count from \`${newTableName}\``
         
     | 
| 
       72859 
     | 
    
         
            -
                        );
         
     | 
| 
       72860 
     | 
    
         
            -
                        const count = Number(res[0].count);
         
     | 
| 
       72861 
     | 
    
         
            -
                        if (count > 0) {
         
     | 
| 
       72862 
     | 
    
         
            -
                          infoToPrint.push(
         
     | 
| 
       72863 
     | 
    
         
            -
                            `\xB7 You're about to add not-null ${source_default.underline(
         
     | 
| 
       72864 
     | 
    
         
            -
                              statement.column.name
         
     | 
| 
       72865 
     | 
    
         
            -
                            )} column without default value, which contains ${count} items`
         
     | 
| 
       72866 
     | 
    
         
            -
                          );
         
     | 
| 
       72867 
     | 
    
         
            -
                          tablesToTruncate.push(newTableName);
         
     | 
| 
       72868 
     | 
    
         
            -
                          statementsToExecute.push(`delete from ${newTableName};`);
         
     | 
| 
       72869 
     | 
    
         
            -
                          shouldAskForApprove = true;
         
     | 
| 
       72870 
     | 
    
         
            -
                        }
         
     | 
| 
       72871 
     | 
    
         
            -
                      }
         
     | 
| 
       72872 
     | 
    
         
            -
                      if (statement.column.primaryKey) {
         
     | 
| 
       72873 
     | 
    
         
            -
                        tablesContext[newTableName] = [
         
     | 
| 
       72874 
     | 
    
         
            -
                          ..._moveDataStatements(statement.tableName, json2, true)
         
     | 
| 
       72875 
     | 
    
         
            -
                        ];
         
     | 
| 
       72876 
     | 
    
         
            -
                        const tablesReferncingCurrent = [];
         
     | 
| 
       72877 
     | 
    
         
            -
                        for (const table4 of Object.values(json1.tables)) {
         
     | 
| 
       72878 
     | 
    
         
            -
                          const tablesRefs = Object.values(json1.tables[table4.name].foreignKeys).filter(
         
     | 
| 
       72879 
     | 
    
         
            -
                            (t2) => SQLiteSquasher.unsquashPushFK(t2).tableTo === newTableName
         
     | 
| 
       72880 
     | 
    
         
            -
                          ).map((t2) => SQLiteSquasher.unsquashPushFK(t2).tableFrom);
         
     | 
| 
       72881 
     | 
    
         
            -
                          tablesReferncingCurrent.push(...tablesRefs);
         
     | 
| 
       72882 
     | 
    
         
            -
                        }
         
     | 
| 
       72883 
     | 
    
         
            -
                        const uniqueTableRefs = [...new Set(tablesReferncingCurrent)];
         
     | 
| 
       72884 
     | 
    
         
            -
                        for (const table4 of uniqueTableRefs) {
         
     | 
| 
       72885 
     | 
    
         
            -
                          if (typeof tablesContext[table4] === "undefined") {
         
     | 
| 
       72886 
     | 
    
         
            -
                            tablesContext[table4] = [..._moveDataStatements(table4, json2)];
         
     | 
| 
       72887 
     | 
    
         
            -
                          }
         
     | 
| 
       72888 
     | 
    
         
            -
                        }
         
     | 
| 
       72889 
     | 
    
         
            -
                      } else {
         
     | 
| 
       72890 
     | 
    
         
            -
                        if (typeof tablesContext[newTableName] === "undefined") {
         
     | 
| 
       72891 
     | 
    
         
            -
                          const stmnt = fromJson([statement], "sqlite")[0];
         
     | 
| 
       72892 
     | 
    
         
            -
                          statementsToExecute.push(stmnt);
         
     | 
| 
       72893 
     | 
    
         
            -
                        }
         
     | 
| 
       72894 
     | 
    
         
            -
                      }
         
     | 
| 
       72895 
     | 
    
         
            -
                    } else if (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_pk" || statement.type === "alter_table_alter_column_set_pk") {
         
     | 
| 
       72896 
     | 
    
         
            -
                      if (!(statement.type === "alter_table_alter_column_set_notnull" && statement.columnPk)) {
         
     | 
| 
       72897 
     | 
    
         
            -
                        const newTableName = getOldTableName(statement.tableName, meta);
         
     | 
| 
       72898 
     | 
    
         
            -
                        if (statement.type === "alter_table_alter_column_set_notnull" && typeof statement.columnDefault === "undefined") {
         
     | 
| 
       72899 
     | 
    
         
            -
                          const res = await connection.query(
         
     | 
| 
       72900 
     | 
    
         
            -
                            `select count(*) as count from \`${newTableName}\``
         
     | 
| 
       72901 
     | 
    
         
            -
                          );
         
     | 
| 
       72902 
     | 
    
         
            -
                          const count = Number(res[0].count);
         
     | 
| 
       72903 
     | 
    
         
            -
                          if (count > 0) {
         
     | 
| 
       72904 
     | 
    
         
            -
                            infoToPrint.push(
         
     | 
| 
       72905 
     | 
    
         
            -
                              `\xB7 You're about to add not-null constraint to ${source_default.underline(
         
     | 
| 
       72906 
     | 
    
         
            -
                                statement.columnName
         
     | 
| 
       72907 
     | 
    
         
            -
                              )} column without default value, which contains ${count} items`
         
     | 
| 
       72908 
     | 
    
         
            -
                            );
         
     | 
| 
       72909 
     | 
    
         
            -
                            tablesToTruncate.push(newTableName);
         
     | 
| 
       72910 
     | 
    
         
            -
                            shouldAskForApprove = true;
         
     | 
| 
       72911 
     | 
    
         
            -
                          }
         
     | 
| 
       72912 
     | 
    
         
            -
                          tablesContext[newTableName] = _moveDataStatements(
         
     | 
| 
       72913 
     | 
    
         
            -
                            statement.tableName,
         
     | 
| 
       72914 
     | 
    
         
            -
                            json1,
         
     | 
| 
       72915 
     | 
    
         
            -
                            true
         
     | 
| 
       72916 
     | 
    
         
            -
                          );
         
     | 
| 
       72917 
     | 
    
         
            -
                        } else {
         
     | 
| 
       72918 
     | 
    
         
            -
                          if (typeof tablesContext[newTableName] === "undefined") {
         
     | 
| 
       72919 
     | 
    
         
            -
                            tablesContext[newTableName] = _moveDataStatements(
         
     | 
| 
       72920 
     | 
    
         
            -
                              statement.tableName,
         
     | 
| 
       72921 
     | 
    
         
            -
                              json1
         
     | 
| 
       72922 
     | 
    
         
            -
                            );
         
     | 
| 
       72923 
     | 
    
         
            -
                          }
         
     | 
| 
       72924 
     | 
    
         
            -
                        }
         
     | 
| 
       72925 
     | 
    
         
            -
                        const tablesReferncingCurrent = [];
         
     | 
| 
       72926 
     | 
    
         
            -
                        for (const table4 of Object.values(json1.tables)) {
         
     | 
| 
       72927 
     | 
    
         
            -
                          const tablesRefs = Object.values(json1.tables[table4.name].foreignKeys).filter(
         
     | 
| 
       72928 
     | 
    
         
            -
                            (t2) => SQLiteSquasher.unsquashPushFK(t2).tableTo === newTableName
         
     | 
| 
       72929 
     | 
    
         
            -
                          ).map((t2) => {
         
     | 
| 
       72930 
     | 
    
         
            -
                            return getNewTableName(
         
     | 
| 
       72931 
     | 
    
         
            -
                              SQLiteSquasher.unsquashPushFK(t2).tableFrom,
         
     | 
| 
       72932 
     | 
    
         
            -
                              meta
         
     | 
| 
       72933 
     | 
    
         
            -
                            );
         
     | 
| 
       72934 
     | 
    
         
            -
                          });
         
     | 
| 
       72935 
     | 
    
         
            -
                          tablesReferncingCurrent.push(...tablesRefs);
         
     | 
| 
       72936 
     | 
    
         
            -
                        }
         
     | 
| 
       72937 
     | 
    
         
            -
                        const uniqueTableRefs = [...new Set(tablesReferncingCurrent)];
         
     | 
| 
       72938 
     | 
    
         
            -
                        for (const table4 of uniqueTableRefs) {
         
     | 
| 
       72939 
     | 
    
         
            -
                          if (typeof tablesContext[table4] === "undefined") {
         
     | 
| 
       72940 
     | 
    
         
            -
                            tablesContext[table4] = [..._moveDataStatements(table4, json1)];
         
     | 
| 
       72941 
     | 
    
         
            -
                          }
         
     | 
| 
       72942 
     | 
    
         
            -
                        }
         
     | 
| 
       72943 
     | 
    
         
            -
                      }
         
     | 
| 
       72944 
     | 
    
         
            -
                    } else if (statement.type === "create_reference" || statement.type === "delete_reference" || statement.type === "alter_reference") {
         
     | 
| 
       72945 
     | 
    
         
            -
                      const fk4 = SQLiteSquasher.unsquashPushFK(statement.data);
         
     | 
| 
       72946 
     | 
    
         
            -
                      if (typeof tablesContext[statement.tableName] === "undefined") {
         
     | 
| 
       72947 
     | 
    
         
            -
                        tablesContext[statement.tableName] = _moveDataStatements(
         
     | 
| 
       72948 
     | 
    
         
            -
                          statement.tableName,
         
     | 
| 
       72949 
     | 
    
         
            -
                          json2
         
     | 
| 
       72950 
     | 
    
         
            -
                        );
         
     | 
| 
       72951 
     | 
    
         
            -
                      }
         
     | 
| 
       72952 
     | 
    
         
            -
                    } else if (statement.type === "create_composite_pk" || statement.type === "alter_composite_pk" || statement.type === "delete_composite_pk" || statement.type === "create_unique_constraint" || statement.type === "delete_unique_constraint") {
         
     | 
| 
       72953 
     | 
    
         
            -
                      const newTableName = getOldTableName(statement.tableName, meta);
         
     | 
| 
       72954 
     | 
    
         
            -
                      if (typeof tablesContext[newTableName] === "undefined") {
         
     | 
| 
       72955 
     | 
    
         
            -
                        tablesContext[newTableName] = _moveDataStatements(
         
     | 
| 
       72956 
     | 
    
         
            -
                          statement.tableName,
         
     | 
| 
       72957 
     | 
    
         
            -
                          json2
         
     | 
| 
       72958 
     | 
    
         
            -
                        );
         
     | 
| 
       72959 
     | 
    
         
            -
                      }
         
     | 
| 
       72960 
     | 
    
         
            -
                    } else {
         
     | 
| 
       72961 
     | 
    
         
            -
                      const stmnt = fromJson([statement], "sqlite");
         
     | 
| 
       72962 
     | 
    
         
            -
                      if (typeof stmnt !== "undefined") {
         
     | 
| 
       72963 
     | 
    
         
            -
                        statementsToExecute.push(...stmnt);
         
     | 
| 
       72964 
     | 
    
         
            -
                      }
         
     | 
| 
       72965 
     | 
    
         
            -
                    }
         
     | 
| 
       72966 
     | 
    
         
            -
                  }
         
     | 
| 
       72967 
     | 
    
         
            -
                  for (const context of Object.values(tablesContext)) {
         
     | 
| 
       72968 
     | 
    
         
            -
                    statementsToExecute.push(...context);
         
     | 
| 
       72969 
     | 
    
         
            -
                  }
         
     | 
| 
       72970 
     | 
    
         
            -
                  return {
         
     | 
| 
       72971 
     | 
    
         
            -
                    statementsToExecute,
         
     | 
| 
       72972 
     | 
    
         
            -
                    shouldAskForApprove,
         
     | 
| 
       72973 
     | 
    
         
            -
                    infoToPrint,
         
     | 
| 
       72974 
     | 
    
         
            -
                    columnsToRemove: [...new Set(columnsToRemove)],
         
     | 
| 
       72975 
     | 
    
         
            -
                    schemasToRemove: [...new Set(schemasToRemove)],
         
     | 
| 
       72976 
     | 
    
         
            -
                    tablesToTruncate: [...new Set(tablesToTruncate)],
         
     | 
| 
       72977 
     | 
    
         
            -
                    tablesToRemove: [...new Set(tablesToRemove)]
         
     | 
| 
       72978 
     | 
    
         
            -
                  };
         
     | 
| 
       72979 
     | 
    
         
            -
                };
         
     | 
| 
       72980 
     | 
    
         
            -
              }
         
     | 
| 
       72981 
     | 
    
         
            -
            });
         
     | 
| 
       72982 
     | 
    
         
            -
             
     | 
| 
       72983 
73858 
     | 
    
         
             
            // ../node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/brace-expressions.js
         
     | 
| 
       72984 
73859 
     | 
    
         
             
            var posixClasses, braceEscape, regexpEscape, rangesToString, parseClass;
         
     | 
| 
       72985 
73860 
     | 
    
         
             
            var init_brace_expressions = __esm({
         
     | 
| 
         @@ -74542,11 +75417,12 @@ var init_sqliteIntrospect = __esm({ 
     | 
|
| 
       74542 
75417 
     | 
    
         
             
            // src/cli/commands/push.ts
         
     | 
| 
       74543 
75418 
     | 
    
         
             
            var push_exports = {};
         
     | 
| 
       74544 
75419 
     | 
    
         
             
            __export(push_exports, {
         
     | 
| 
      
 75420 
     | 
    
         
            +
              libSQLPush: () => libSQLPush,
         
     | 
| 
       74545 
75421 
     | 
    
         
             
              mysqlPush: () => mysqlPush,
         
     | 
| 
       74546 
75422 
     | 
    
         
             
              pgPush: () => pgPush,
         
     | 
| 
       74547 
75423 
     | 
    
         
             
              sqlitePush: () => sqlitePush
         
     | 
| 
       74548 
75424 
     | 
    
         
             
            });
         
     | 
| 
       74549 
     | 
    
         
            -
            var import_hanji11, mysqlPush, pgPush, sqlitePush;
         
     | 
| 
      
 75425 
     | 
    
         
            +
            var import_hanji11, mysqlPush, pgPush, sqlitePush, libSQLPush;
         
     | 
| 
       74550 
75426 
     | 
    
         
             
            var init_push = __esm({
         
     | 
| 
       74551 
75427 
     | 
    
         
             
              "src/cli/commands/push.ts"() {
         
     | 
| 
       74552 
75428 
     | 
    
         
             
                "use strict";
         
     | 
| 
         @@ -74555,6 +75431,7 @@ var init_push = __esm({ 
     | 
|
| 
       74555 
75431 
     | 
    
         
             
                init_sqlgenerator();
         
     | 
| 
       74556 
75432 
     | 
    
         
             
                init_selector_ui();
         
     | 
| 
       74557 
75433 
     | 
    
         
             
                init_outputs();
         
     | 
| 
      
 75434 
     | 
    
         
            +
                init_libSqlPushUtils();
         
     | 
| 
       74558 
75435 
     | 
    
         
             
                init_mysqlPushUtils();
         
     | 
| 
       74559 
75436 
     | 
    
         
             
                init_pgPushUtils();
         
     | 
| 
       74560 
75437 
     | 
    
         
             
                init_sqlitePushUtils();
         
     | 
| 
         @@ -74582,7 +75459,7 @@ var init_push = __esm({ 
     | 
|
| 
       74582 
75459 
     | 
    
         
             
                        tablesToTruncate,
         
     | 
| 
       74583 
75460 
     | 
    
         
             
                        infoToPrint,
         
     | 
| 
       74584 
75461 
     | 
    
         
             
                        schemasToRemove
         
     | 
| 
       74585 
     | 
    
         
            -
                      } = await  
     | 
| 
      
 75462 
     | 
    
         
            +
                      } = await logSuggestionsAndReturn2(
         
     | 
| 
       74586 
75463 
     | 
    
         
             
                        db,
         
     | 
| 
       74587 
75464 
     | 
    
         
             
                        filteredStatements,
         
     | 
| 
       74588 
75465 
     | 
    
         
             
                        statements.validatedCur
         
     | 
| 
         @@ -74601,7 +75478,6 @@ var init_push = __esm({ 
     | 
|
| 
       74601 
75478 
     | 
    
         
             
                        }
         
     | 
| 
       74602 
75479 
     | 
    
         
             
                      });
         
     | 
| 
       74603 
75480 
     | 
    
         
             
                      if (verbose) {
         
     | 
| 
       74604 
     | 
    
         
            -
                        console.log();
         
     | 
| 
       74605 
75481 
     | 
    
         
             
                        console.log(
         
     | 
| 
       74606 
75482 
     | 
    
         
             
                          withStyle.warning("You are about to execute current statements:")
         
     | 
| 
       74607 
75483 
     | 
    
         
             
                        );
         
     | 
| 
         @@ -74752,11 +75628,100 @@ var init_push = __esm({ 
     | 
|
| 
       74752 
75628 
     | 
    
         
             
                      tablesToTruncate,
         
     | 
| 
       74753 
75629 
     | 
    
         
             
                      infoToPrint,
         
     | 
| 
       74754 
75630 
     | 
    
         
             
                      schemasToRemove
         
     | 
| 
       74755 
     | 
    
         
            -
                    } = await  
     | 
| 
      
 75631 
     | 
    
         
            +
                    } = await logSuggestionsAndReturn(
         
     | 
| 
       74756 
75632 
     | 
    
         
             
                      db,
         
     | 
| 
       74757 
75633 
     | 
    
         
             
                      statements.statements,
         
     | 
| 
      
 75634 
     | 
    
         
            +
                      statements.squashedPrev,
         
     | 
| 
       74758 
75635 
     | 
    
         
             
                      statements.squashedCur,
         
     | 
| 
      
 75636 
     | 
    
         
            +
                      statements.meta
         
     | 
| 
      
 75637 
     | 
    
         
            +
                    );
         
     | 
| 
      
 75638 
     | 
    
         
            +
                    if (verbose && statementsToExecute.length > 0) {
         
     | 
| 
      
 75639 
     | 
    
         
            +
                      console.log();
         
     | 
| 
      
 75640 
     | 
    
         
            +
                      console.log(
         
     | 
| 
      
 75641 
     | 
    
         
            +
                        withStyle.warning("You are about to execute current statements:")
         
     | 
| 
      
 75642 
     | 
    
         
            +
                      );
         
     | 
| 
      
 75643 
     | 
    
         
            +
                      console.log();
         
     | 
| 
      
 75644 
     | 
    
         
            +
                      console.log(statementsToExecute.map((s2) => source_default.blue(s2)).join("\n"));
         
     | 
| 
      
 75645 
     | 
    
         
            +
                      console.log();
         
     | 
| 
      
 75646 
     | 
    
         
            +
                    }
         
     | 
| 
      
 75647 
     | 
    
         
            +
                    if (!force && strict) {
         
     | 
| 
      
 75648 
     | 
    
         
            +
                      if (!shouldAskForApprove) {
         
     | 
| 
      
 75649 
     | 
    
         
            +
                        const { status, data } = await (0, import_hanji11.render)(
         
     | 
| 
      
 75650 
     | 
    
         
            +
                          new Select(["No, abort", `Yes, I want to execute all statements`])
         
     | 
| 
      
 75651 
     | 
    
         
            +
                        );
         
     | 
| 
      
 75652 
     | 
    
         
            +
                        if ((data == null ? void 0 : data.index) === 0) {
         
     | 
| 
      
 75653 
     | 
    
         
            +
                          (0, import_hanji11.render)(`[${source_default.red("x")}] All changes were aborted`);
         
     | 
| 
      
 75654 
     | 
    
         
            +
                          process.exit(0);
         
     | 
| 
      
 75655 
     | 
    
         
            +
                        }
         
     | 
| 
      
 75656 
     | 
    
         
            +
                      }
         
     | 
| 
      
 75657 
     | 
    
         
            +
                    }
         
     | 
| 
      
 75658 
     | 
    
         
            +
                    if (!force && shouldAskForApprove) {
         
     | 
| 
      
 75659 
     | 
    
         
            +
                      console.log(withStyle.warning("Found data-loss statements:"));
         
     | 
| 
      
 75660 
     | 
    
         
            +
                      console.log(infoToPrint.join("\n"));
         
     | 
| 
      
 75661 
     | 
    
         
            +
                      console.log();
         
     | 
| 
      
 75662 
     | 
    
         
            +
                      console.log(
         
     | 
| 
      
 75663 
     | 
    
         
            +
                        source_default.red.bold(
         
     | 
| 
      
 75664 
     | 
    
         
            +
                          "THIS ACTION WILL CAUSE DATA LOSS AND CANNOT BE REVERTED\n"
         
     | 
| 
      
 75665 
     | 
    
         
            +
                        )
         
     | 
| 
      
 75666 
     | 
    
         
            +
                      );
         
     | 
| 
      
 75667 
     | 
    
         
            +
                      console.log(source_default.white("Do you still want to push changes?"));
         
     | 
| 
      
 75668 
     | 
    
         
            +
                      const { status, data } = await (0, import_hanji11.render)(
         
     | 
| 
      
 75669 
     | 
    
         
            +
                        new Select([
         
     | 
| 
      
 75670 
     | 
    
         
            +
                          "No, abort",
         
     | 
| 
      
 75671 
     | 
    
         
            +
                          `Yes, I want to${tablesToRemove.length > 0 ? ` remove ${tablesToRemove.length} ${tablesToRemove.length > 1 ? "tables" : "table"},` : " "}${columnsToRemove.length > 0 ? ` remove ${columnsToRemove.length} ${columnsToRemove.length > 1 ? "columns" : "column"},` : " "}${tablesToTruncate.length > 0 ? ` truncate ${tablesToTruncate.length} ${tablesToTruncate.length > 1 ? "tables" : "table"}` : ""}`.trimEnd().replace(/(^,)|(,$)/g, "").replace(/ +(?= )/g, "")
         
     | 
| 
      
 75672 
     | 
    
         
            +
                        ])
         
     | 
| 
      
 75673 
     | 
    
         
            +
                      );
         
     | 
| 
      
 75674 
     | 
    
         
            +
                      if ((data == null ? void 0 : data.index) === 0) {
         
     | 
| 
      
 75675 
     | 
    
         
            +
                        (0, import_hanji11.render)(`[${source_default.red("x")}] All changes were aborted`);
         
     | 
| 
      
 75676 
     | 
    
         
            +
                        process.exit(0);
         
     | 
| 
      
 75677 
     | 
    
         
            +
                      }
         
     | 
| 
      
 75678 
     | 
    
         
            +
                    }
         
     | 
| 
      
 75679 
     | 
    
         
            +
                    if (statementsToExecute.length === 0) {
         
     | 
| 
      
 75680 
     | 
    
         
            +
                      (0, import_hanji11.render)(`
         
     | 
| 
      
 75681 
     | 
    
         
            +
            [${source_default.blue("i")}] No changes detected`);
         
     | 
| 
      
 75682 
     | 
    
         
            +
                    } else {
         
     | 
| 
      
 75683 
     | 
    
         
            +
                      if (!("driver" in credentials2)) {
         
     | 
| 
      
 75684 
     | 
    
         
            +
                        await db.query("begin");
         
     | 
| 
      
 75685 
     | 
    
         
            +
                        try {
         
     | 
| 
      
 75686 
     | 
    
         
            +
                          for (const dStmnt of statementsToExecute) {
         
     | 
| 
      
 75687 
     | 
    
         
            +
                            await db.query(dStmnt);
         
     | 
| 
      
 75688 
     | 
    
         
            +
                          }
         
     | 
| 
      
 75689 
     | 
    
         
            +
                          await db.query("commit");
         
     | 
| 
      
 75690 
     | 
    
         
            +
                        } catch (e2) {
         
     | 
| 
      
 75691 
     | 
    
         
            +
                          console.error(e2);
         
     | 
| 
      
 75692 
     | 
    
         
            +
                          await db.query("rollback");
         
     | 
| 
      
 75693 
     | 
    
         
            +
                          process.exit(1);
         
     | 
| 
      
 75694 
     | 
    
         
            +
                        }
         
     | 
| 
      
 75695 
     | 
    
         
            +
                      } else if (credentials2.driver === "turso") {
         
     | 
| 
      
 75696 
     | 
    
         
            +
                        await db.batch(statementsToExecute.map((it) => ({ query: it })));
         
     | 
| 
      
 75697 
     | 
    
         
            +
                      }
         
     | 
| 
      
 75698 
     | 
    
         
            +
                      (0, import_hanji11.render)(`[${source_default.green("\u2713")}] Changes applied`);
         
     | 
| 
      
 75699 
     | 
    
         
            +
                    }
         
     | 
| 
      
 75700 
     | 
    
         
            +
                  }
         
     | 
| 
      
 75701 
     | 
    
         
            +
                };
         
     | 
| 
      
 75702 
     | 
    
         
            +
                libSQLPush = async (schemaPath, verbose, strict, credentials2, tablesFilter, force) => {
         
     | 
| 
      
 75703 
     | 
    
         
            +
                  const { connectToSQLite: connectToSQLite2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
         
     | 
| 
      
 75704 
     | 
    
         
            +
                  const { sqlitePushIntrospect: sqlitePushIntrospect2 } = await Promise.resolve().then(() => (init_sqliteIntrospect(), sqliteIntrospect_exports));
         
     | 
| 
      
 75705 
     | 
    
         
            +
                  const db = await connectToSQLite2(credentials2);
         
     | 
| 
      
 75706 
     | 
    
         
            +
                  const { schema: schema5 } = await sqlitePushIntrospect2(db, tablesFilter);
         
     | 
| 
      
 75707 
     | 
    
         
            +
                  const { prepareLibSQLPush: prepareLibSQLPush2 } = await Promise.resolve().then(() => (init_migrate(), migrate_exports));
         
     | 
| 
      
 75708 
     | 
    
         
            +
                  const statements = await prepareLibSQLPush2(schemaPath, schema5);
         
     | 
| 
      
 75709 
     | 
    
         
            +
                  if (statements.sqlStatements.length === 0) {
         
     | 
| 
      
 75710 
     | 
    
         
            +
                    (0, import_hanji11.render)(`
         
     | 
| 
      
 75711 
     | 
    
         
            +
            [${source_default.blue("i")}] No changes detected`);
         
     | 
| 
      
 75712 
     | 
    
         
            +
                  } else {
         
     | 
| 
      
 75713 
     | 
    
         
            +
                    const {
         
     | 
| 
      
 75714 
     | 
    
         
            +
                      shouldAskForApprove,
         
     | 
| 
      
 75715 
     | 
    
         
            +
                      statementsToExecute,
         
     | 
| 
      
 75716 
     | 
    
         
            +
                      columnsToRemove,
         
     | 
| 
      
 75717 
     | 
    
         
            +
                      tablesToRemove,
         
     | 
| 
      
 75718 
     | 
    
         
            +
                      tablesToTruncate,
         
     | 
| 
      
 75719 
     | 
    
         
            +
                      infoToPrint
         
     | 
| 
      
 75720 
     | 
    
         
            +
                    } = await libSqlLogSuggestionsAndReturn(
         
     | 
| 
      
 75721 
     | 
    
         
            +
                      db,
         
     | 
| 
      
 75722 
     | 
    
         
            +
                      statements.statements,
         
     | 
| 
       74759 
75723 
     | 
    
         
             
                      statements.squashedPrev,
         
     | 
| 
      
 75724 
     | 
    
         
            +
                      statements.squashedCur,
         
     | 
| 
       74760 
75725 
     | 
    
         
             
                      statements.meta
         
     | 
| 
       74761 
75726 
     | 
    
         
             
                    );
         
     | 
| 
       74762 
75727 
     | 
    
         
             
                    if (verbose && statementsToExecute.length > 0) {
         
     | 
| 
         @@ -80519,7 +81484,7 @@ var init_studio2 = __esm({ 
     | 
|
| 
       80519 
81484 
     | 
    
         
             
              }
         
     | 
| 
       80520 
81485 
     | 
    
         
             
            });
         
     | 
| 
       80521 
81486 
     | 
    
         | 
| 
       80522 
     | 
    
         
            -
            // ../node_modules/.pnpm/@drizzle-team+brocli@0. 
     | 
| 
      
 81487 
     | 
    
         
            +
            // ../node_modules/.pnpm/@drizzle-team+brocli@0.8.2/node_modules/@drizzle-team/brocli/index.js
         
     | 
| 
       80523 
81488 
     | 
    
         
             
            var __create2 = Object.create;
         
     | 
| 
       80524 
81489 
     | 
    
         
             
            var __defProp2 = Object.defineProperty;
         
     | 
| 
       80525 
81490 
     | 
    
         
             
            var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
         
     | 
| 
         @@ -80966,299 +81931,130 @@ var require_shell_quote = __commonJS2({ 
     | 
|
| 
       80966 
81931 
     | 
    
         
             
              }
         
     | 
| 
       80967 
81932 
     | 
    
         
             
            });
         
     | 
| 
       80968 
81933 
     | 
    
         
             
            var BroCliError = class extends Error {
         
     | 
| 
       80969 
     | 
    
         
            -
              constructor(message 
     | 
| 
      
 81934 
     | 
    
         
            +
              constructor(message) {
         
     | 
| 
       80970 
81935 
     | 
    
         
             
                const errPrefix = "BroCli error: ";
         
     | 
| 
       80971 
81936 
     | 
    
         
             
                super(message === void 0 ? message : `${errPrefix}${message}`);
         
     | 
| 
       80972 
     | 
    
         
            -
                this.event = event;
         
     | 
| 
       80973 
81937 
     | 
    
         
             
              }
         
     | 
| 
       80974 
81938 
     | 
    
         
             
            };
         
     | 
| 
       80975 
81939 
     | 
    
         
             
            var import_clone = __toESM2(require_clone(), 1);
         
     | 
| 
       80976 
     | 
    
         
            -
            var  
     | 
| 
       80977 
     | 
    
         
            -
             
     | 
| 
       80978 
     | 
    
         
            -
               
     | 
| 
       80979 
     | 
    
         
            -
                 
     | 
| 
       80980 
     | 
    
         
            -
             
     | 
| 
       80981 
     | 
    
         
            -
                   
     | 
| 
       80982 
     | 
    
         
            -
             
     | 
| 
       80983 
     | 
    
         
            -
                   
     | 
| 
       80984 
     | 
    
         
            -
             
     | 
| 
       80985 
     | 
    
         
            -
             
     | 
| 
       80986 
     | 
    
         
            -
             
     | 
| 
       80987 
     | 
    
         
            -
             
     | 
| 
       80988 
     | 
    
         
            -
             
     | 
| 
       80989 
     | 
    
         
            -
             
     | 
| 
       80990 
     | 
    
         
            -
             
     | 
| 
       80991 
     | 
    
         
            -
             
     | 
| 
       80992 
     | 
    
         
            -
             
     | 
| 
       80993 
     | 
    
         
            -
             
     | 
| 
       80994 
     | 
    
         
            -
             
     | 
| 
       80995 
     | 
    
         
            -
             
     | 
| 
       80996 
     | 
    
         
            -
                     
     | 
| 
       80997 
     | 
    
         
            -
             
     | 
| 
       80998 
     | 
    
         
            -
             
     | 
| 
       80999 
     | 
    
         
            -
                     
     | 
| 
       81000 
     | 
    
         
            -
                     
     | 
| 
       81001 
     | 
    
         
            -
                  }
         
     | 
| 
       81002 
     | 
    
         
            -
             
     | 
| 
       81003 
     | 
    
         
            -
             
     | 
| 
       81004 
     | 
    
         
            -
             
     | 
| 
       81005 
     | 
    
         
            -
                 
     | 
| 
       81006 
     | 
    
         
            -
             
     | 
| 
       81007 
     | 
    
         
            -
             
     | 
| 
       81008 
     | 
    
         
            -
             
     | 
| 
       81009 
     | 
    
         
            -
             
     | 
| 
       81010 
     | 
    
         
            -
                  result = "string";
         
     | 
| 
       81011 
     | 
    
         
            -
                  break;
         
     | 
| 
       81012 
     | 
    
         
            -
                }
         
     | 
| 
       81013 
     | 
    
         
            -
                case "positional": {
         
     | 
| 
       81014 
     | 
    
         
            -
                  result = `${option.isRequired ? "<" : "["}${option.enumVals ? option.enumVals.join("|") : option.name}${option.isRequired ? ">" : "]"}`;
         
     | 
| 
       81015 
     | 
    
         
            -
                  break;
         
     | 
| 
       81016 
     | 
    
         
            -
                }
         
     | 
| 
       81017 
     | 
    
         
            -
              }
         
     | 
| 
       81018 
     | 
    
         
            -
              if (option.isRequired && option.type !== "positional")
         
     | 
| 
       81019 
     | 
    
         
            -
                result = "!" + result.length ? " " : "" + result;
         
     | 
| 
       81020 
     | 
    
         
            -
              return result;
         
     | 
| 
       81021 
     | 
    
         
            -
            };
         
     | 
| 
       81022 
     | 
    
         
            -
            var defaultEventHandler = async (event) => {
         
     | 
| 
       81023 
     | 
    
         
            -
              var _a;
         
     | 
| 
       81024 
     | 
    
         
            -
              switch (event.type) {
         
     | 
| 
       81025 
     | 
    
         
            -
                case "command_help": {
         
     | 
| 
       81026 
     | 
    
         
            -
                  const command2 = event.command;
         
     | 
| 
       81027 
     | 
    
         
            -
                  const commandName = getCommandNameWithParents(command2);
         
     | 
| 
       81028 
     | 
    
         
            -
                  const cliName = event.name;
         
     | 
| 
       81029 
     | 
    
         
            -
                  const desc = command2.desc ?? command2.shortDesc;
         
     | 
| 
       81030 
     | 
    
         
            -
                  const subs = (_a = command2.subcommands) == null ? void 0 : _a.filter((s2) => !s2.hidden);
         
     | 
| 
       81031 
     | 
    
         
            -
                  const subcommands = subs && subs.length ? subs : void 0;
         
     | 
| 
       81032 
     | 
    
         
            -
                  if (desc !== void 0) {
         
     | 
| 
       81033 
     | 
    
         
            -
                    console.log(`
         
     | 
| 
       81034 
     | 
    
         
            -
            ${desc}`);
         
     | 
| 
       81035 
     | 
    
         
            -
                  }
         
     | 
| 
       81036 
     | 
    
         
            -
                  const opts = Object.values(command2.options ?? {}).filter(
         
     | 
| 
       81037 
     | 
    
         
            -
                    (opt) => !opt.config.isHidden
         
     | 
| 
       81038 
     | 
    
         
            -
                  );
         
     | 
| 
       81039 
     | 
    
         
            -
                  const positionals = opts.filter((opt) => opt.config.type === "positional");
         
     | 
| 
       81040 
     | 
    
         
            -
                  const options = opts.filter((opt) => opt.config.type !== "positional");
         
     | 
| 
       81041 
     | 
    
         
            -
                  console.log("\nUsage:");
         
     | 
| 
       81042 
     | 
    
         
            -
                  if (command2.handler) {
         
     | 
| 
       81043 
     | 
    
         
            -
                    console.log(
         
     | 
| 
       81044 
     | 
    
         
            -
                      `  ${cliName ? cliName + " " : ""}${commandName}${positionals.length ? " " + positionals.map(({ config: p2 }) => getOptionTypeText(p2)).join(" ") : ""} [flags]`
         
     | 
| 
       81045 
     | 
    
         
            -
                    );
         
     | 
| 
       81046 
     | 
    
         
            -
                  } else
         
     | 
| 
       81047 
     | 
    
         
            -
                    console.log(`  ${cliName ? cliName + " " : ""}${commandName} [command]`);
         
     | 
| 
       81048 
     | 
    
         
            -
                  if (command2.aliases) {
         
     | 
| 
       81049 
     | 
    
         
            -
                    console.log(`
         
     | 
| 
       81050 
     | 
    
         
            -
            Aliases:`);
         
     | 
| 
       81051 
     | 
    
         
            -
                    console.log(`  ${[command2.name, ...command2.aliases].join(", ")}`);
         
     | 
| 
       81052 
     | 
    
         
            -
                  }
         
     | 
| 
       81053 
     | 
    
         
            -
                  if (subcommands) {
         
     | 
| 
       81054 
     | 
    
         
            -
                    console.log("\nAvailable Commands:");
         
     | 
| 
       81055 
     | 
    
         
            -
                    const padding = 3;
         
     | 
| 
       81056 
     | 
    
         
            -
                    const maxLength = subcommands.reduce((p2, e2) => e2.name.length > p2 ? e2.name.length : p2, 0);
         
     | 
| 
       81057 
     | 
    
         
            -
                    const paddedLength = maxLength + padding;
         
     | 
| 
       81058 
     | 
    
         
            -
                    const preDescPad = 2 + paddedLength;
         
     | 
| 
       81059 
     | 
    
         
            -
                    const data = subcommands.map(
         
     | 
| 
       81060 
     | 
    
         
            -
                      (s2) => `  ${s2.name.padEnd(paddedLength)}${(() => {
         
     | 
| 
       81061 
     | 
    
         
            -
                        const description = s2.shortDesc ?? s2.desc;
         
     | 
| 
       81062 
     | 
    
         
            -
                        if (!(description == null ? void 0 : description.length))
         
     | 
| 
       81063 
     | 
    
         
            -
                          return "";
         
     | 
| 
       81064 
     | 
    
         
            -
                        const split = description.split("\n");
         
     | 
| 
       81065 
     | 
    
         
            -
                        const first = split.shift();
         
     | 
| 
       81066 
     | 
    
         
            -
                        const final = [first, ...split.map((s22) => "".padEnd(preDescPad) + s22)].join("\n");
         
     | 
| 
       81067 
     | 
    
         
            -
                        return final;
         
     | 
| 
       81068 
     | 
    
         
            -
                      })()}`
         
     | 
| 
       81069 
     | 
    
         
            -
                    ).join("\n");
         
     | 
| 
       81070 
     | 
    
         
            -
                    console.log(data);
         
     | 
| 
       81071 
     | 
    
         
            -
                  }
         
     | 
| 
       81072 
     | 
    
         
            -
                  if (options.length) {
         
     | 
| 
       81073 
     | 
    
         
            -
                    const aliasLength = options.reduce((p2, e2) => {
         
     | 
| 
       81074 
     | 
    
         
            -
                      const currentLength = e2.config.aliases.reduce((pa, a) => pa + a.length, 0) + (e2.config.aliases.length - 1) * 2 + 1;
         
     | 
| 
       81075 
     | 
    
         
            -
                      return currentLength > p2 ? currentLength : p2;
         
     | 
| 
       81076 
     | 
    
         
            -
                    }, 0);
         
     | 
| 
       81077 
     | 
    
         
            -
                    const paddedAliasLength = aliasLength > 0 ? aliasLength + 1 : 0;
         
     | 
| 
       81078 
     | 
    
         
            -
                    const nameLength = options.reduce((p2, e2) => {
         
     | 
| 
       81079 
     | 
    
         
            -
                      const typeLen = getOptionTypeText(e2.config).length;
         
     | 
| 
       81080 
     | 
    
         
            -
                      const length = typeLen > 0 ? e2.config.name.length + 1 + typeLen : e2.config.name.length;
         
     | 
| 
       81081 
     | 
    
         
            -
                      return length > p2 ? length : p2;
         
     | 
| 
       81082 
     | 
    
         
            -
                    }, 0) + 3;
         
     | 
| 
       81083 
     | 
    
         
            -
                    const preDescPad = paddedAliasLength + nameLength + 2;
         
     | 
| 
       81084 
     | 
    
         
            -
                    const data = options.map(
         
     | 
| 
       81085 
     | 
    
         
            -
                      ({ config: opt }) => `  ${`${opt.aliases.length ? opt.aliases.join(", ") + "," : ""}`.padEnd(paddedAliasLength)}${`${opt.name}${(() => {
         
     | 
| 
       81086 
     | 
    
         
            -
                        const typeText = getOptionTypeText(opt);
         
     | 
| 
       81087 
     | 
    
         
            -
                        return typeText.length ? " " + typeText : "";
         
     | 
| 
       81088 
     | 
    
         
            -
                      })()}`.padEnd(nameLength)}${(() => {
         
     | 
| 
       81089 
     | 
    
         
            -
                        var _a2;
         
     | 
| 
       81090 
     | 
    
         
            -
                        if (!((_a2 = opt.description) == null ? void 0 : _a2.length)) {
         
     | 
| 
       81091 
     | 
    
         
            -
                          return opt.default !== void 0 ? `default: ${JSON.stringify(opt.default)}` : "";
         
     | 
| 
       81092 
     | 
    
         
            -
                        }
         
     | 
| 
       81093 
     | 
    
         
            -
                        const split = opt.description.split("\n");
         
     | 
| 
       81094 
     | 
    
         
            -
                        const first = split.shift();
         
     | 
| 
       81095 
     | 
    
         
            -
                        const def = opt.default !== void 0 ? ` (default: ${JSON.stringify(opt.default)})` : "";
         
     | 
| 
       81096 
     | 
    
         
            -
                        const final = [first, ...split.map((s2) => "".padEnd(preDescPad) + s2)].join("\n") + def;
         
     | 
| 
       81097 
     | 
    
         
            -
                        return final;
         
     | 
| 
       81098 
     | 
    
         
            -
                      })()}`
         
     | 
| 
       81099 
     | 
    
         
            -
                    ).join("\n");
         
     | 
| 
       81100 
     | 
    
         
            -
                    console.log("\nFlags:");
         
     | 
| 
       81101 
     | 
    
         
            -
                    console.log(data);
         
     | 
| 
       81102 
     | 
    
         
            -
                  }
         
     | 
| 
       81103 
     | 
    
         
            -
                  console.log("\nGlobal flags:");
         
     | 
| 
       81104 
     | 
    
         
            -
                  console.log(`  -h, --help      help for ${commandName}`);
         
     | 
| 
       81105 
     | 
    
         
            -
                  console.log(`  -v, --version   version${cliName ? ` for ${cliName}` : ""}`);
         
     | 
| 
       81106 
     | 
    
         
            -
                  if (subcommands) {
         
     | 
| 
       81107 
     | 
    
         
            -
                    console.log(
         
     | 
| 
       81108 
     | 
    
         
            -
                      `
         
     | 
| 
       81109 
     | 
    
         
            -
            Use "${cliName ? cliName + " " : ""}${commandName} [command] --help" for more information about a command.
         
     | 
| 
       81110 
     | 
    
         
            -
            `
         
     | 
| 
       81111 
     | 
    
         
            -
                    );
         
     | 
| 
       81112 
     | 
    
         
            -
                  }
         
     | 
| 
       81113 
     | 
    
         
            -
                  return true;
         
     | 
| 
       81114 
     | 
    
         
            -
                }
         
     | 
| 
       81115 
     | 
    
         
            -
                case "global_help": {
         
     | 
| 
       81116 
     | 
    
         
            -
                  const cliName = event.name;
         
     | 
| 
       81117 
     | 
    
         
            -
                  const desc = event.description;
         
     | 
| 
       81118 
     | 
    
         
            -
                  const commands = event.commands.filter((c) => !c.hidden);
         
     | 
| 
       81119 
     | 
    
         
            -
                  if (desc !== void 0) {
         
     | 
| 
       81120 
     | 
    
         
            -
                    console.log(`${desc}
         
     | 
| 
       81121 
     | 
    
         
            -
            `);
         
     | 
| 
       81122 
     | 
    
         
            -
                  }
         
     | 
| 
       81123 
     | 
    
         
            -
                  console.log("Usage:");
         
     | 
| 
       81124 
     | 
    
         
            -
                  console.log(`  ${cliName ? cliName + " " : ""}[command]`);
         
     | 
| 
       81125 
     | 
    
         
            -
                  if (commands.length) {
         
     | 
| 
       81126 
     | 
    
         
            -
                    console.log("\nAvailable Commands:");
         
     | 
| 
       81127 
     | 
    
         
            -
                    const padding = 3;
         
     | 
| 
       81128 
     | 
    
         
            -
                    const maxLength = commands.reduce((p2, e2) => e2.name.length > p2 ? e2.name.length : p2, 0);
         
     | 
| 
       81129 
     | 
    
         
            -
                    const paddedLength = maxLength + padding;
         
     | 
| 
       81130 
     | 
    
         
            -
                    const data = commands.map(
         
     | 
| 
       81131 
     | 
    
         
            -
                      (\u0441) => `  ${\u0441.name.padEnd(paddedLength)}${(() => {
         
     | 
| 
       81132 
     | 
    
         
            -
                        const desc2 = \u0441.shortDesc ?? \u0441.desc;
         
     | 
| 
       81133 
     | 
    
         
            -
                        if (!(desc2 == null ? void 0 : desc2.length))
         
     | 
| 
       81134 
     | 
    
         
            -
                          return "";
         
     | 
| 
       81135 
     | 
    
         
            -
                        const split = desc2.split("\n");
         
     | 
| 
       81136 
     | 
    
         
            -
                        const first = split.shift();
         
     | 
| 
       81137 
     | 
    
         
            -
                        const final = [first, ...split.map((s2) => "".padEnd(paddedLength + 2) + s2)].join("\n");
         
     | 
| 
       81138 
     | 
    
         
            -
                        return final;
         
     | 
| 
       81139 
     | 
    
         
            -
                      })()}`
         
     | 
| 
       81140 
     | 
    
         
            -
                    ).join("\n");
         
     | 
| 
       81141 
     | 
    
         
            -
                    console.log(data);
         
     | 
| 
       81142 
     | 
    
         
            -
                  } else {
         
     | 
| 
       81143 
     | 
    
         
            -
                    console.log("\nNo available commands.");
         
     | 
| 
       81144 
     | 
    
         
            -
                  }
         
     | 
| 
       81145 
     | 
    
         
            -
                  console.log("\nFlags:");
         
     | 
| 
       81146 
     | 
    
         
            -
                  console.log(`  -h, --help      help${cliName ? ` for ${cliName}` : ""}`);
         
     | 
| 
       81147 
     | 
    
         
            -
                  console.log(`  -v, --version   version${cliName ? ` for ${cliName}` : ""}`);
         
     | 
| 
       81148 
     | 
    
         
            -
                  console.log("\n");
         
     | 
| 
       81149 
     | 
    
         
            -
                  return true;
         
     | 
| 
       81150 
     | 
    
         
            -
                }
         
     | 
| 
       81151 
     | 
    
         
            -
                case "version": {
         
     | 
| 
       81152 
     | 
    
         
            -
                  return true;
         
     | 
| 
       81153 
     | 
    
         
            -
                }
         
     | 
| 
       81154 
     | 
    
         
            -
                case "error": {
         
     | 
| 
       81155 
     | 
    
         
            -
                  let msg;
         
     | 
| 
       81156 
     | 
    
         
            -
                  switch (event.violation) {
         
     | 
| 
       81157 
     | 
    
         
            -
                    case "above_max": {
         
     | 
| 
       81158 
     | 
    
         
            -
                      const matchedName = event.offender.namePart;
         
     | 
| 
       81159 
     | 
    
         
            -
                      const data = event.offender.dataPart;
         
     | 
| 
       81160 
     | 
    
         
            -
                      const option = event.option;
         
     | 
| 
       81161 
     | 
    
         
            -
                      const max = option.maxVal;
         
     | 
| 
       81162 
     | 
    
         
            -
                      msg = `Invalid value: number type argument '${matchedName}' expects maximal value of ${max} as an input, got: ${data}`;
         
     | 
| 
       81163 
     | 
    
         
            -
                      break;
         
     | 
| 
       81164 
     | 
    
         
            -
                    }
         
     | 
| 
       81165 
     | 
    
         
            -
                    case "below_min": {
         
     | 
| 
       81166 
     | 
    
         
            -
                      const matchedName = event.offender.namePart;
         
     | 
| 
       81167 
     | 
    
         
            -
                      const data = event.offender.dataPart;
         
     | 
| 
       81168 
     | 
    
         
            -
                      const option = event.option;
         
     | 
| 
       81169 
     | 
    
         
            -
                      const min = option.minVal;
         
     | 
| 
       81170 
     | 
    
         
            -
                      msg = `Invalid value: number type argument '${matchedName}' expects minimal value of ${min} as an input, got: ${data}`;
         
     | 
| 
       81171 
     | 
    
         
            -
                      break;
         
     | 
| 
       81172 
     | 
    
         
            -
                    }
         
     | 
| 
       81173 
     | 
    
         
            -
                    case "expected_int": {
         
     | 
| 
       81174 
     | 
    
         
            -
                      const matchedName = event.offender.namePart;
         
     | 
| 
       81175 
     | 
    
         
            -
                      const data = event.offender.dataPart;
         
     | 
| 
       81176 
     | 
    
         
            -
                      msg = `Invalid value: number type argument '${matchedName}' expects an integer as an input, got: ${data}`;
         
     | 
| 
       81177 
     | 
    
         
            -
                      break;
         
     | 
| 
       81178 
     | 
    
         
            -
                    }
         
     | 
| 
       81179 
     | 
    
         
            -
                    case "invalid_boolean_syntax": {
         
     | 
| 
       81180 
     | 
    
         
            -
                      const matchedName = event.offender.namePart;
         
     | 
| 
       81181 
     | 
    
         
            -
                      const data = event.offender.dataPart;
         
     | 
| 
       81182 
     | 
    
         
            -
                      msg = `Invalid syntax: boolean type argument '${matchedName}' must have it's value passed in the following formats: ${matchedName}=<value> | ${matchedName} <value> | ${matchedName}.
         
     | 
| 
       81183 
     | 
    
         
            -
            Allowed values: true, false, 0, 1`;
         
     | 
| 
       81184 
     | 
    
         
            -
                      break;
         
     | 
| 
       81185 
     | 
    
         
            -
                    }
         
     | 
| 
       81186 
     | 
    
         
            -
                    case "invalid_string_syntax": {
         
     | 
| 
       81187 
     | 
    
         
            -
                      const matchedName = event.offender.namePart;
         
     | 
| 
       81188 
     | 
    
         
            -
                      msg = `Invalid syntax: string type argument '${matchedName}' must have it's value passed in the following formats: ${matchedName}=<value> | ${matchedName} <value>`;
         
     | 
| 
       81189 
     | 
    
         
            -
                      break;
         
     | 
| 
       81190 
     | 
    
         
            -
                    }
         
     | 
| 
       81191 
     | 
    
         
            -
                    case "invalid_number_syntax": {
         
     | 
| 
       81192 
     | 
    
         
            -
                      const matchedName = event.offender.namePart;
         
     | 
| 
       81193 
     | 
    
         
            -
                      msg = `Invalid syntax: number type argument '${matchedName}' must have it's value passed in the following formats: ${matchedName}=<value> | ${matchedName} <value>`;
         
     | 
| 
       81194 
     | 
    
         
            -
                      break;
         
     | 
| 
       81195 
     | 
    
         
            -
                    }
         
     | 
| 
       81196 
     | 
    
         
            -
                    case "invalid_number_value": {
         
     | 
| 
       81197 
     | 
    
         
            -
                      const matchedName = event.offender.namePart;
         
     | 
| 
       81198 
     | 
    
         
            -
                      const data = event.offender.dataPart;
         
     | 
| 
       81199 
     | 
    
         
            -
                      msg = `Invalid value: number type argument '${matchedName}' expects a number as an input, got: ${data}`;
         
     | 
| 
       81200 
     | 
    
         
            -
                      break;
         
     | 
| 
       81201 
     | 
    
         
            -
                    }
         
     | 
| 
       81202 
     | 
    
         
            -
                    case "enum_violation": {
         
     | 
| 
       81203 
     | 
    
         
            -
                      const matchedName = event.offender.namePart;
         
     | 
| 
       81204 
     | 
    
         
            -
                      const data = event.offender.dataPart;
         
     | 
| 
       81205 
     | 
    
         
            -
                      const option = event.option;
         
     | 
| 
       81206 
     | 
    
         
            -
                      const values = option.enumVals;
         
     | 
| 
       81207 
     | 
    
         
            -
                      msg = option.type === "positional" ? `Invalid value: value for the positional argument '${option.name}' must be either one of the following: ${values.join(", ")}; Received: ${data}` : `Invalid value: value for the argument '${matchedName}' must be either one of the following: ${values.join(", ")}; Received: ${data}`;
         
     | 
| 
       81208 
     | 
    
         
            -
                      break;
         
     | 
| 
       81209 
     | 
    
         
            -
                    }
         
     | 
| 
       81210 
     | 
    
         
            -
                    case "unknown_command_error": {
         
     | 
| 
       81211 
     | 
    
         
            -
                      const msg2 = `Unknown command: '${event.offender}'.
         
     | 
| 
       81212 
     | 
    
         
            -
            Type '--help' to get help on the cli.`;
         
     | 
| 
       81213 
     | 
    
         
            -
                      console.error(msg2);
         
     | 
| 
       81214 
     | 
    
         
            -
                      return true;
         
     | 
| 
       81215 
     | 
    
         
            -
                    }
         
     | 
| 
       81216 
     | 
    
         
            -
                    case "unknown_subcommand_error": {
         
     | 
| 
       81217 
     | 
    
         
            -
                      const cName = getCommandNameWithParents(event.command);
         
     | 
| 
       81218 
     | 
    
         
            -
                      const msg2 = `Unknown command: ${cName} ${event.offender}.
         
     | 
| 
       81219 
     | 
    
         
            -
            Type '${cName} --help' to get the help on command.`;
         
     | 
| 
       81220 
     | 
    
         
            -
                      console.error(msg2);
         
     | 
| 
       81221 
     | 
    
         
            -
                      return true;
         
     | 
| 
       81222 
     | 
    
         
            -
                    }
         
     | 
| 
       81223 
     | 
    
         
            -
                    case "missing_args_error": {
         
     | 
| 
       81224 
     | 
    
         
            -
                      const missingOpts = event.missing;
         
     | 
| 
       81225 
     | 
    
         
            -
                      msg = `Command '${command.name}' is missing following required options: ${missingOpts.map((opt) => {
         
     | 
| 
       81226 
     | 
    
         
            -
                        const name = opt.shift();
         
     | 
| 
       81227 
     | 
    
         
            -
                        const aliases = opt;
         
     | 
| 
       81228 
     | 
    
         
            -
                        if (aliases.length)
         
     | 
| 
       81229 
     | 
    
         
            -
                          return `${name} [${aliases.join(", ")}]`;
         
     | 
| 
       81230 
     | 
    
         
            -
                        return name;
         
     | 
| 
       81231 
     | 
    
         
            -
                      }).join(", ")}`;
         
     | 
| 
       81232 
     | 
    
         
            -
                      break;
         
     | 
| 
       81233 
     | 
    
         
            -
                    }
         
     | 
| 
       81234 
     | 
    
         
            -
                    case "unrecognized_args_error": {
         
     | 
| 
       81235 
     | 
    
         
            -
                      const { command: command2, unrecognized } = event;
         
     | 
| 
       81236 
     | 
    
         
            -
                      msg = `Unrecognized options for command '${command2.name}': ${unrecognized.join(", ")}`;
         
     | 
| 
       81237 
     | 
    
         
            -
                      break;
         
     | 
| 
       81238 
     | 
    
         
            -
                    }
         
     | 
| 
       81239 
     | 
    
         
            -
                    case "unknown_error": {
         
     | 
| 
       81240 
     | 
    
         
            -
                      const e2 = event.error;
         
     | 
| 
       81241 
     | 
    
         
            -
                      console.error(typeof e2 === "object" && e2 !== null && "message" in e2 ? e2.message : e2);
         
     | 
| 
       81242 
     | 
    
         
            -
                      return true;
         
     | 
| 
       81243 
     | 
    
         
            -
                    }
         
     | 
| 
       81244 
     | 
    
         
            -
                  }
         
     | 
| 
       81245 
     | 
    
         
            -
                  console.error(msg);
         
     | 
| 
       81246 
     | 
    
         
            -
                  return true;
         
     | 
| 
       81247 
     | 
    
         
            -
                }
         
     | 
| 
      
 81940 
     | 
    
         
            +
            var import_shell_quote = __toESM2(require_shell_quote(), 1);
         
     | 
| 
      
 81941 
     | 
    
         
            +
            var defaultTheme = (calledFor) => {
         
     | 
| 
      
 81942 
     | 
    
         
            +
              if (Array.isArray(calledFor)) {
         
     | 
| 
      
 81943 
     | 
    
         
            +
                const cmds = calledFor.filter((cmd) => !cmd.hidden);
         
     | 
| 
      
 81944 
     | 
    
         
            +
                const tableCmds = cmds.map((cmd) => ({
         
     | 
| 
      
 81945 
     | 
    
         
            +
                  name: cmd.name,
         
     | 
| 
      
 81946 
     | 
    
         
            +
                  aliases: cmd.aliases ? cmd.aliases.join(", ") : "-",
         
     | 
| 
      
 81947 
     | 
    
         
            +
                  description: cmd.description ?? "-"
         
     | 
| 
      
 81948 
     | 
    
         
            +
                }));
         
     | 
| 
      
 81949 
     | 
    
         
            +
                console.log(`Here's the list of all available commands:`);
         
     | 
| 
      
 81950 
     | 
    
         
            +
                console.table(tableCmds);
         
     | 
| 
      
 81951 
     | 
    
         
            +
                console.log(
         
     | 
| 
      
 81952 
     | 
    
         
            +
                  "To read the details about any particular command type: [commandName] --help"
         
     | 
| 
      
 81953 
     | 
    
         
            +
                );
         
     | 
| 
      
 81954 
     | 
    
         
            +
              } else {
         
     | 
| 
      
 81955 
     | 
    
         
            +
                const options = calledFor.options ? Object.values(calledFor.options).filter((opt) => {
         
     | 
| 
      
 81956 
     | 
    
         
            +
                  var _a;
         
     | 
| 
      
 81957 
     | 
    
         
            +
                  return !((_a = opt.config) == null ? void 0 : _a.isHidden);
         
     | 
| 
      
 81958 
     | 
    
         
            +
                }).map(
         
     | 
| 
      
 81959 
     | 
    
         
            +
                  ({ config: opt }) => ({
         
     | 
| 
      
 81960 
     | 
    
         
            +
                    name: opt.name,
         
     | 
| 
      
 81961 
     | 
    
         
            +
                    aliases: opt.aliases.length ? `${opt.aliases.join(", ")}` : "-",
         
     | 
| 
      
 81962 
     | 
    
         
            +
                    description: opt.description ?? "-",
         
     | 
| 
      
 81963 
     | 
    
         
            +
                    type: opt.type,
         
     | 
| 
      
 81964 
     | 
    
         
            +
                    required: opt.isRequired ? "\u2713" : "\u2717"
         
     | 
| 
      
 81965 
     | 
    
         
            +
                  })
         
     | 
| 
      
 81966 
     | 
    
         
            +
                ) : void 0;
         
     | 
| 
      
 81967 
     | 
    
         
            +
                console.log(
         
     | 
| 
      
 81968 
     | 
    
         
            +
                  `Command: ${calledFor.name}${calledFor.aliases ? ` [${calledFor.aliases.join(", ")}]` : ""}${calledFor.description ? ` - ${calledFor.description}` : ""}`
         
     | 
| 
      
 81969 
     | 
    
         
            +
                );
         
     | 
| 
      
 81970 
     | 
    
         
            +
                if (!(options == null ? void 0 : options.length))
         
     | 
| 
      
 81971 
     | 
    
         
            +
                  return;
         
     | 
| 
      
 81972 
     | 
    
         
            +
                console.log("\nOptions:");
         
     | 
| 
      
 81973 
     | 
    
         
            +
                console.table(options);
         
     | 
| 
       81248 
81974 
     | 
    
         
             
              }
         
     | 
| 
       81249 
     | 
    
         
            -
              return false;
         
     | 
| 
       81250 
81975 
     | 
    
         
             
            };
         
     | 
| 
       81251 
     | 
    
         
            -
            var eventHandlerWrapper = (customEventHandler) => async (event) => await customEventHandler(event) ? true : await defaultEventHandler(event);
         
     | 
| 
       81252 
     | 
    
         
            -
            var import_shell_quote = __toESM2(require_shell_quote(), 1);
         
     | 
| 
       81253 
81976 
     | 
    
         
             
            function isInt(value) {
         
     | 
| 
       81254 
81977 
     | 
    
         
             
              return value === Math.floor(value);
         
     | 
| 
       81255 
81978 
     | 
    
         
             
            }
         
     | 
| 
       81256 
     | 
    
         
            -
            var  
     | 
| 
      
 81979 
     | 
    
         
            +
            var unknownCommand = (caller) => {
         
     | 
| 
      
 81980 
     | 
    
         
            +
              const msg = `Unknown command: '${caller}'.
         
     | 
| 
      
 81981 
     | 
    
         
            +
            Type '--help' to get help on the cli.`;
         
     | 
| 
      
 81982 
     | 
    
         
            +
              return new Error(msg);
         
     | 
| 
      
 81983 
     | 
    
         
            +
            };
         
     | 
| 
      
 81984 
     | 
    
         
            +
            var unknownSubcommand = (command2, caller) => {
         
     | 
| 
      
 81985 
     | 
    
         
            +
              const name = getCommandNameRecursive(command2);
         
     | 
| 
      
 81986 
     | 
    
         
            +
              const msg = `Unknown command: ${name} ${caller}.
         
     | 
| 
      
 81987 
     | 
    
         
            +
            Type '${name} --help' to get the help on command.`;
         
     | 
| 
      
 81988 
     | 
    
         
            +
              new Error(
         
     | 
| 
      
 81989 
     | 
    
         
            +
                msg
         
     | 
| 
      
 81990 
     | 
    
         
            +
              );
         
     | 
| 
      
 81991 
     | 
    
         
            +
              return new Error(msg);
         
     | 
| 
      
 81992 
     | 
    
         
            +
            };
         
     | 
| 
      
 81993 
     | 
    
         
            +
            var missingRequired = (command2, missingOpts) => {
         
     | 
| 
      
 81994 
     | 
    
         
            +
              const msg = `Command '${command2.name}' is missing following required options: ${missingOpts.map((opt) => {
         
     | 
| 
      
 81995 
     | 
    
         
            +
                const name = opt.shift();
         
     | 
| 
      
 81996 
     | 
    
         
            +
                const aliases = opt;
         
     | 
| 
      
 81997 
     | 
    
         
            +
                if (aliases.length)
         
     | 
| 
      
 81998 
     | 
    
         
            +
                  return `${name} [${aliases.join(", ")}]`;
         
     | 
| 
      
 81999 
     | 
    
         
            +
                return name;
         
     | 
| 
      
 82000 
     | 
    
         
            +
              }).join(", ")}`;
         
     | 
| 
      
 82001 
     | 
    
         
            +
              return new Error(msg);
         
     | 
| 
      
 82002 
     | 
    
         
            +
            };
         
     | 
| 
      
 82003 
     | 
    
         
            +
            var unrecognizedOptions = (command2, unrecognizedArgs) => {
         
     | 
| 
      
 82004 
     | 
    
         
            +
              const msg = `Unrecognized options for command '${command2.name}': ${unrecognizedArgs.join(", ")}`;
         
     | 
| 
      
 82005 
     | 
    
         
            +
              return new Error(msg);
         
     | 
| 
      
 82006 
     | 
    
         
            +
            };
         
     | 
| 
      
 82007 
     | 
    
         
            +
            var invalidBooleanSyntax = (matchedName) => {
         
     | 
| 
      
 82008 
     | 
    
         
            +
              return new Error(
         
     | 
| 
      
 82009 
     | 
    
         
            +
                `Invalid syntax: boolean type argument '${matchedName}' must have it's value passed in the following formats: ${matchedName}=<value> | ${matchedName} <value> | ${matchedName}.
         
     | 
| 
      
 82010 
     | 
    
         
            +
            Allowed values: true, false, 0, 1`
         
     | 
| 
      
 82011 
     | 
    
         
            +
              );
         
     | 
| 
      
 82012 
     | 
    
         
            +
            };
         
     | 
| 
      
 82013 
     | 
    
         
            +
            var invalidStringSyntax = (matchedName) => {
         
     | 
| 
      
 82014 
     | 
    
         
            +
              return new Error(
         
     | 
| 
      
 82015 
     | 
    
         
            +
                `Invalid syntax: string type argument '${matchedName}' must have it's value passed in the following formats: ${matchedName}=<value> | ${matchedName} <value>`
         
     | 
| 
      
 82016 
     | 
    
         
            +
              );
         
     | 
| 
      
 82017 
     | 
    
         
            +
            };
         
     | 
| 
      
 82018 
     | 
    
         
            +
            var enumViolation = (matchedName, data, values) => {
         
     | 
| 
      
 82019 
     | 
    
         
            +
              return new Error(
         
     | 
| 
      
 82020 
     | 
    
         
            +
                `Invalid value: value for the argument '${matchedName}' must be either one of the following: ${values.join(", ")}; Received: ${data}`
         
     | 
| 
      
 82021 
     | 
    
         
            +
              );
         
     | 
| 
      
 82022 
     | 
    
         
            +
            };
         
     | 
| 
      
 82023 
     | 
    
         
            +
            var enumViolationPos = (matchedName, data, values) => {
         
     | 
| 
      
 82024 
     | 
    
         
            +
              return new Error(
         
     | 
| 
      
 82025 
     | 
    
         
            +
                `Invalid value: value for the argument '${matchedName}' must be either one of the following: ${values.join(", ")}; Received: ${data}`
         
     | 
| 
      
 82026 
     | 
    
         
            +
              );
         
     | 
| 
      
 82027 
     | 
    
         
            +
            };
         
     | 
| 
      
 82028 
     | 
    
         
            +
            var invalidNumberSyntax = (matchedName) => {
         
     | 
| 
      
 82029 
     | 
    
         
            +
              return new Error(
         
     | 
| 
      
 82030 
     | 
    
         
            +
                `Invalid syntax: number type argument '${matchedName}' must have it's value passed in the following formats: ${matchedName}=<value> | ${matchedName} <value>`
         
     | 
| 
      
 82031 
     | 
    
         
            +
              );
         
     | 
| 
      
 82032 
     | 
    
         
            +
            };
         
     | 
| 
      
 82033 
     | 
    
         
            +
            var invalidNumberValue = (matchedName, data) => {
         
     | 
| 
      
 82034 
     | 
    
         
            +
              return new Error(
         
     | 
| 
      
 82035 
     | 
    
         
            +
                `Invalid value: number type argument '${matchedName}' expects a number as an input, got: ${data}`
         
     | 
| 
      
 82036 
     | 
    
         
            +
              );
         
     | 
| 
      
 82037 
     | 
    
         
            +
            };
         
     | 
| 
      
 82038 
     | 
    
         
            +
            var invalidInteger = (matchedName, data) => {
         
     | 
| 
      
 82039 
     | 
    
         
            +
              return new Error(
         
     | 
| 
      
 82040 
     | 
    
         
            +
                `Invalid value: number type argument '${matchedName}' expects an integer as an input, got: ${data}`
         
     | 
| 
      
 82041 
     | 
    
         
            +
              );
         
     | 
| 
      
 82042 
     | 
    
         
            +
            };
         
     | 
| 
      
 82043 
     | 
    
         
            +
            var belowMin = (matchedName, data, min) => {
         
     | 
| 
      
 82044 
     | 
    
         
            +
              return new Error(
         
     | 
| 
      
 82045 
     | 
    
         
            +
                `Invalid value: number type argument '${matchedName}' expects minimal value of ${min} as an input, got: ${data}`
         
     | 
| 
      
 82046 
     | 
    
         
            +
              );
         
     | 
| 
      
 82047 
     | 
    
         
            +
            };
         
     | 
| 
      
 82048 
     | 
    
         
            +
            var aboveMax = (matchedName, data, max) => {
         
     | 
| 
      
 82049 
     | 
    
         
            +
              return new Error(
         
     | 
| 
      
 82050 
     | 
    
         
            +
                `Invalid value: number type argument '${matchedName}' expects maximal value of ${max} as an input, got: ${data}`
         
     | 
| 
      
 82051 
     | 
    
         
            +
              );
         
     | 
| 
      
 82052 
     | 
    
         
            +
            };
         
     | 
| 
       81257 
82053 
     | 
    
         
             
            var generatePrefix = (name) => name.startsWith("-") ? name : name.length > 1 ? `--${name}` : `-${name}`;
         
     | 
| 
       81258 
82054 
     | 
    
         
             
            var validateOptions = (config) => {
         
     | 
| 
       81259 
82055 
     | 
    
         
             
              const cloned = (0, import_clone.default)(config);
         
     | 
| 
       81260 
82056 
     | 
    
         
             
              const entries = [];
         
     | 
| 
       81261 
     | 
    
         
            -
              const storedNames =  
     | 
| 
      
 82057 
     | 
    
         
            +
              const storedNames = {};
         
     | 
| 
       81262 
82058 
     | 
    
         
             
              const cfgEntries = Object.entries(cloned);
         
     | 
| 
       81263 
82059 
     | 
    
         
             
              for (const [key, value] of cfgEntries) {
         
     | 
| 
       81264 
82060 
     | 
    
         
             
                const cfg = value._.config;
         
     | 
| 
         @@ -81268,13 +82064,13 @@ var validateOptions = (config) => { 
     | 
|
| 
       81268 
82064 
     | 
    
         
             
                  continue;
         
     | 
| 
       81269 
82065 
     | 
    
         
             
                if (cfg.name.includes("=")) {
         
     | 
| 
       81270 
82066 
     | 
    
         
             
                  throw new BroCliError(
         
     | 
| 
       81271 
     | 
    
         
            -
                    `Can't define option  
     | 
| 
      
 82067 
     | 
    
         
            +
                    `Can't define option ${cfg.name} - option names and aliases cannot contain '='!`
         
     | 
| 
       81272 
82068 
     | 
    
         
             
                  );
         
     | 
| 
       81273 
82069 
     | 
    
         
             
                }
         
     | 
| 
       81274 
82070 
     | 
    
         
             
                for (const alias of cfg.aliases) {
         
     | 
| 
       81275 
82071 
     | 
    
         
             
                  if (alias.includes("=")) {
         
     | 
| 
       81276 
82072 
     | 
    
         
             
                    throw new BroCliError(
         
     | 
| 
       81277 
     | 
    
         
            -
                      `Can't define option  
     | 
| 
      
 82073 
     | 
    
         
            +
                      `Can't define option ${cfg.name} - option names and aliases cannot contain '='!`
         
     | 
| 
       81278 
82074 
     | 
    
         
             
                    );
         
     | 
| 
       81279 
82075 
     | 
    
         
             
                  }
         
     | 
| 
       81280 
82076 
     | 
    
         
             
                }
         
     | 
| 
         @@ -81292,33 +82088,33 @@ var validateOptions = (config) => { 
     | 
|
| 
       81292 
82088 
     | 
    
         
             
                for (const name of allNames) {
         
     | 
| 
       81293 
82089 
     | 
    
         
             
                  const match2 = reservedNames.find((n) => n === name);
         
     | 
| 
       81294 
82090 
     | 
    
         
             
                  if (match2)
         
     | 
| 
       81295 
     | 
    
         
            -
                    throw new BroCliError(`Can't define option  
     | 
| 
      
 82091 
     | 
    
         
            +
                    throw new BroCliError(`Can't define option ${cfg.name} - name '${match2}' is reserved!`);
         
     | 
| 
       81296 
82092 
     | 
    
         
             
                }
         
     | 
| 
       81297 
     | 
    
         
            -
                 
     | 
| 
      
 82093 
     | 
    
         
            +
                const storageVals = Object.values(storedNames);
         
     | 
| 
      
 82094 
     | 
    
         
            +
                for (const storage2 of storageVals) {
         
     | 
| 
       81298 
82095 
     | 
    
         
             
                  const nameOccupier = storage2.find((e2) => e2 === cfg.name);
         
     | 
| 
       81299 
82096 
     | 
    
         
             
                  if (!nameOccupier)
         
     | 
| 
       81300 
82097 
     | 
    
         
             
                    continue;
         
     | 
| 
       81301 
82098 
     | 
    
         
             
                  throw new BroCliError(
         
     | 
| 
       81302 
     | 
    
         
            -
                    `Can't define option '${cfg.name}'  
     | 
| 
      
 82099 
     | 
    
         
            +
                    `Can't define option '${cfg.name}': name is already in use by option '${storage2[0]}'!`
         
     | 
| 
       81303 
82100 
     | 
    
         
             
                  );
         
     | 
| 
       81304 
82101 
     | 
    
         
             
                }
         
     | 
| 
       81305 
82102 
     | 
    
         
             
                for (const alias of cfg.aliases) {
         
     | 
| 
       81306 
     | 
    
         
            -
                  for (const storage2 of  
     | 
| 
      
 82103 
     | 
    
         
            +
                  for (const storage2 of storageVals) {
         
     | 
| 
       81307 
82104 
     | 
    
         
             
                    const nameOccupier = storage2.find((e2) => e2 === alias);
         
     | 
| 
       81308 
82105 
     | 
    
         
             
                    if (!nameOccupier)
         
     | 
| 
       81309 
82106 
     | 
    
         
             
                      continue;
         
     | 
| 
       81310 
82107 
     | 
    
         
             
                    throw new BroCliError(
         
     | 
| 
       81311 
     | 
    
         
            -
                      `Can't define option '${cfg.name}'  
     | 
| 
      
 82108 
     | 
    
         
            +
                      `Can't define option '${cfg.name}': alias '${alias}' is already in use by option '${storage2[0]}'!`
         
     | 
| 
       81312 
82109 
     | 
    
         
             
                    );
         
     | 
| 
       81313 
82110 
     | 
    
         
             
                  }
         
     | 
| 
       81314 
82111 
     | 
    
         
             
                }
         
     | 
| 
       81315 
     | 
    
         
            -
                 
     | 
| 
       81316 
     | 
    
         
            -
                storedNames. 
     | 
| 
       81317 
     | 
    
         
            -
             
     | 
| 
       81318 
     | 
    
         
            -
                  if (currentNames.findIndex((e2) => e2 === name) === idx)
         
     | 
| 
      
 82112 
     | 
    
         
            +
                storedNames[cfg.name] = [cfg.name, ...cfg.aliases];
         
     | 
| 
      
 82113 
     | 
    
         
            +
                storedNames[cfg.name].forEach((name, idx) => {
         
     | 
| 
      
 82114 
     | 
    
         
            +
                  if (storedNames[cfg.name].findIndex((e2) => e2 === name) === idx)
         
     | 
| 
       81319 
82115 
     | 
    
         
             
                    return;
         
     | 
| 
       81320 
82116 
     | 
    
         
             
                  throw new BroCliError(
         
     | 
| 
       81321 
     | 
    
         
            -
                    `Can't define option '${cfg.name}'  
     | 
| 
      
 82117 
     | 
    
         
            +
                    `Can't define option '${cfg.name}': duplicate aliases '${name}'!`
         
     | 
| 
       81322 
82118 
     | 
    
         
             
                  );
         
     | 
| 
       81323 
82119 
     | 
    
         
             
                });
         
     | 
| 
       81324 
82120 
     | 
    
         
             
                entries.push([key, { config: cfg, $output: void 0 }]);
         
     | 
| 
         @@ -81339,17 +82135,14 @@ var command = (command2) => { 
     | 
|
| 
       81339 
82135 
     | 
    
         
             
                  `Can't define command '${cmd.name}' - command can't have subcommands and positional args at the same time!`
         
     | 
| 
       81340 
82136 
     | 
    
         
             
                );
         
     | 
| 
       81341 
82137 
     | 
    
         
             
              }
         
     | 
| 
       81342 
     | 
    
         
            -
              if (!command2.handler && !command2.subcommands) {
         
     | 
| 
       81343 
     | 
    
         
            -
                throw new BroCliError(
         
     | 
| 
       81344 
     | 
    
         
            -
                  `Can't define command '${cmd.name}' - command without subcommands must have a handler present!`
         
     | 
| 
       81345 
     | 
    
         
            -
                );
         
     | 
| 
       81346 
     | 
    
         
            -
              }
         
     | 
| 
       81347 
82138 
     | 
    
         
             
              const processedOptions = command2.options ? validateOptions(command2.options) : void 0;
         
     | 
| 
       81348 
82139 
     | 
    
         
             
              cmd.options = processedOptions;
         
     | 
| 
       81349 
82140 
     | 
    
         
             
              cmd.name = cmd.name ?? ((_a = cmd.aliases) == null ? void 0 : _a.shift());
         
     | 
| 
       81350 
82141 
     | 
    
         
             
              if (!cmd.name)
         
     | 
| 
       81351 
82142 
     | 
    
         
             
                throw new BroCliError(`Can't define command without name!`);
         
     | 
| 
       81352 
82143 
     | 
    
         
             
              cmd.aliases = ((_b = cmd.aliases) == null ? void 0 : _b.length) ? cmd.aliases : void 0;
         
     | 
| 
      
 82144 
     | 
    
         
            +
              if (!cmd.handler)
         
     | 
| 
      
 82145 
     | 
    
         
            +
                throw new BroCliError(`Can't define command '${cmd.name}' - command must have a handler!`);
         
     | 
| 
       81353 
82146 
     | 
    
         
             
              if (cmd.name.startsWith("-")) {
         
     | 
| 
       81354 
82147 
     | 
    
         
             
                throw new BroCliError(`Can't define command '${cmd.name}' - command name can't start with '-'!`);
         
     | 
| 
       81355 
82148 
     | 
    
         
             
              }
         
     | 
| 
         @@ -81379,7 +82172,7 @@ var command = (command2) => { 
     | 
|
| 
       81379 
82172 
     | 
    
         
             
              }
         
     | 
| 
       81380 
82173 
     | 
    
         
             
              return cmd;
         
     | 
| 
       81381 
82174 
     | 
    
         
             
            };
         
     | 
| 
       81382 
     | 
    
         
            -
            var getCommandInner = (commands, candidates, args 
     | 
| 
      
 82175 
     | 
    
         
            +
            var getCommandInner = (commands, candidates, args) => {
         
     | 
| 
       81383 
82176 
     | 
    
         
             
              const { data: arg, originalIndex: index4 } = candidates.shift();
         
     | 
| 
       81384 
82177 
     | 
    
         
             
              const command2 = commands.find((c) => {
         
     | 
| 
       81385 
82178 
     | 
    
         
             
                const names = c.aliases ? [c.name, ...c.aliases] : [c.name];
         
     | 
| 
         @@ -81400,20 +82193,12 @@ var getCommandInner = (commands, candidates, args, cliName, cliDescription) => { 
     | 
|
| 
       81400 
82193 
     | 
    
         
             
                };
         
     | 
| 
       81401 
82194 
     | 
    
         
             
              }
         
     | 
| 
       81402 
82195 
     | 
    
         
             
              const newCandidates = candidates.map((c) => ({ data: c.data, originalIndex: c.originalIndex - 1 }));
         
     | 
| 
       81403 
     | 
    
         
            -
              const subcommand = getCommandInner(command2.subcommands, newCandidates, newArgs 
     | 
| 
       81404 
     | 
    
         
            -
              if (!subcommand.command) 
     | 
| 
       81405 
     | 
    
         
            -
                throw  
     | 
| 
       81406 
     | 
    
         
            -
                  type: "error",
         
     | 
| 
       81407 
     | 
    
         
            -
                  violation: "unknown_subcommand_error",
         
     | 
| 
       81408 
     | 
    
         
            -
                  name: cliName,
         
     | 
| 
       81409 
     | 
    
         
            -
                  description: cliDescription,
         
     | 
| 
       81410 
     | 
    
         
            -
                  command: command2,
         
     | 
| 
       81411 
     | 
    
         
            -
                  offender: candidates[0].data
         
     | 
| 
       81412 
     | 
    
         
            -
                });
         
     | 
| 
       81413 
     | 
    
         
            -
              }
         
     | 
| 
      
 82196 
     | 
    
         
            +
              const subcommand = getCommandInner(command2.subcommands, newCandidates, newArgs);
         
     | 
| 
      
 82197 
     | 
    
         
            +
              if (!subcommand.command)
         
     | 
| 
      
 82198 
     | 
    
         
            +
                throw unknownSubcommand(command2, candidates[0].data);
         
     | 
| 
       81414 
82199 
     | 
    
         
             
              return subcommand;
         
     | 
| 
       81415 
82200 
     | 
    
         
             
            };
         
     | 
| 
       81416 
     | 
    
         
            -
            var getCommand = (commands, args 
     | 
| 
      
 82201 
     | 
    
         
            +
            var getCommand = (commands, args) => {
         
     | 
| 
       81417 
82202 
     | 
    
         
             
              var _a;
         
     | 
| 
       81418 
82203 
     | 
    
         
             
              const candidates = [];
         
     | 
| 
       81419 
82204 
     | 
    
         
             
              for (let i2 = 0; i2 < args.length; ++i2) {
         
     | 
| 
         @@ -81447,23 +82232,15 @@ var getCommand = (commands, args, cliName, cliDescription) => { 
     | 
|
| 
       81447 
82232 
     | 
    
         
             
                  args: removeByIndex(args, firstCandidate.originalIndex)
         
     | 
| 
       81448 
82233 
     | 
    
         
             
                };
         
     | 
| 
       81449 
82234 
     | 
    
         
             
              }
         
     | 
| 
       81450 
     | 
    
         
            -
              const { command: command2, args: argsRes } = getCommandInner(commands, candidates, args 
     | 
| 
       81451 
     | 
    
         
            -
              if (!command2) 
     | 
| 
       81452 
     | 
    
         
            -
                throw  
     | 
| 
       81453 
     | 
    
         
            -
                  type: "error",
         
     | 
| 
       81454 
     | 
    
         
            -
                  violation: "unknown_command_error",
         
     | 
| 
       81455 
     | 
    
         
            -
                  commands,
         
     | 
| 
       81456 
     | 
    
         
            -
                  name: cliName,
         
     | 
| 
       81457 
     | 
    
         
            -
                  description: cliDescription,
         
     | 
| 
       81458 
     | 
    
         
            -
                  offender: firstCandidate.data
         
     | 
| 
       81459 
     | 
    
         
            -
                });
         
     | 
| 
       81460 
     | 
    
         
            -
              }
         
     | 
| 
      
 82235 
     | 
    
         
            +
              const { command: command2, args: argsRes } = getCommandInner(commands, candidates, args);
         
     | 
| 
      
 82236 
     | 
    
         
            +
              if (!command2)
         
     | 
| 
      
 82237 
     | 
    
         
            +
                throw unknownCommand(firstCandidate.data);
         
     | 
| 
       81461 
82238 
     | 
    
         
             
              return {
         
     | 
| 
       81462 
82239 
     | 
    
         
             
                command: command2,
         
     | 
| 
       81463 
82240 
     | 
    
         
             
                args: argsRes
         
     | 
| 
       81464 
82241 
     | 
    
         
             
              };
         
     | 
| 
       81465 
82242 
     | 
    
         
             
            };
         
     | 
| 
       81466 
     | 
    
         
            -
            var parseArg = ( 
     | 
| 
      
 82243 
     | 
    
         
            +
            var parseArg = (options, positionals, arg, nextArg) => {
         
     | 
| 
       81467 
82244 
     | 
    
         
             
              let data = void 0;
         
     | 
| 
       81468 
82245 
     | 
    
         
             
              const argSplit = arg.split("=");
         
     | 
| 
       81469 
82246 
     | 
    
         
             
              const hasEq = arg.includes("=");
         
     | 
| 
         @@ -81484,18 +82261,8 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri 
     | 
|
| 
       81484 
82261 
     | 
    
         
             
                if (!positionals.length)
         
     | 
| 
       81485 
82262 
     | 
    
         
             
                  return {};
         
     | 
| 
       81486 
82263 
     | 
    
         
             
                const pos = positionals.shift();
         
     | 
| 
       81487 
     | 
    
         
            -
                if (pos[1].enumVals && !pos[1].enumVals.find((val2) => val2 ===  
     | 
| 
       81488 
     | 
    
         
            -
                  throw  
     | 
| 
       81489 
     | 
    
         
            -
                    type: "error",
         
     | 
| 
       81490 
     | 
    
         
            -
                    name: cliName,
         
     | 
| 
       81491 
     | 
    
         
            -
                    description: cliDescription,
         
     | 
| 
       81492 
     | 
    
         
            -
                    violation: "enum_violation",
         
     | 
| 
       81493 
     | 
    
         
            -
                    command: command2,
         
     | 
| 
       81494 
     | 
    
         
            -
                    option: pos[1],
         
     | 
| 
       81495 
     | 
    
         
            -
                    offender: {
         
     | 
| 
       81496 
     | 
    
         
            -
                      dataPart: arg
         
     | 
| 
       81497 
     | 
    
         
            -
                    }
         
     | 
| 
       81498 
     | 
    
         
            -
                  });
         
     | 
| 
      
 82264 
     | 
    
         
            +
                if (pos[1].enumVals && !pos[1].enumVals.find((val2) => val2 === dataPart)) {
         
     | 
| 
      
 82265 
     | 
    
         
            +
                  throw enumViolationPos(pos[1].name, arg, pos[1].enumVals);
         
     | 
| 
       81499 
82266 
     | 
    
         
             
                }
         
     | 
| 
       81500 
82267 
     | 
    
         
             
                data = arg;
         
     | 
| 
       81501 
82268 
     | 
    
         
             
                return {
         
     | 
| 
         @@ -81530,126 +82297,32 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri 
     | 
|
| 
       81530 
82297 
     | 
    
         
             
                    skipNext = false;
         
     | 
| 
       81531 
82298 
     | 
    
         
             
                    return true;
         
     | 
| 
       81532 
82299 
     | 
    
         
             
                  }
         
     | 
| 
       81533 
     | 
    
         
            -
                  throw  
     | 
| 
       81534 
     | 
    
         
            -
                    type: "error",
         
     | 
| 
       81535 
     | 
    
         
            -
                    name: cliName,
         
     | 
| 
       81536 
     | 
    
         
            -
                    description: cliDescription,
         
     | 
| 
       81537 
     | 
    
         
            -
                    violation: "invalid_boolean_syntax",
         
     | 
| 
       81538 
     | 
    
         
            -
                    option: opt,
         
     | 
| 
       81539 
     | 
    
         
            -
                    command: command2,
         
     | 
| 
       81540 
     | 
    
         
            -
                    offender: {
         
     | 
| 
       81541 
     | 
    
         
            -
                      namePart,
         
     | 
| 
       81542 
     | 
    
         
            -
                      dataPart
         
     | 
| 
       81543 
     | 
    
         
            -
                    }
         
     | 
| 
       81544 
     | 
    
         
            -
                  });
         
     | 
| 
      
 82300 
     | 
    
         
            +
                  throw invalidBooleanSyntax(match2);
         
     | 
| 
       81545 
82301 
     | 
    
         
             
                } else {
         
     | 
| 
       81546 
82302 
     | 
    
         
             
                  const match2 = names.find((name) => name === namePart);
         
     | 
| 
       81547 
82303 
     | 
    
         
             
                  if (!match2)
         
     | 
| 
       81548 
82304 
     | 
    
         
             
                    return false;
         
     | 
| 
       81549 
82305 
     | 
    
         
             
                  if (opt.type === "string") {
         
     | 
| 
       81550 
     | 
    
         
            -
                    if (!hasEq && nextArg === void 0) 
     | 
| 
       81551 
     | 
    
         
            -
                      throw  
     | 
| 
       81552 
     | 
    
         
            -
                        type: "error",
         
     | 
| 
       81553 
     | 
    
         
            -
                        name: cliName,
         
     | 
| 
       81554 
     | 
    
         
            -
                        description: cliDescription,
         
     | 
| 
       81555 
     | 
    
         
            -
                        violation: "invalid_string_syntax",
         
     | 
| 
       81556 
     | 
    
         
            -
                        option: opt,
         
     | 
| 
       81557 
     | 
    
         
            -
                        command: command2,
         
     | 
| 
       81558 
     | 
    
         
            -
                        offender: {
         
     | 
| 
       81559 
     | 
    
         
            -
                          namePart,
         
     | 
| 
       81560 
     | 
    
         
            -
                          dataPart
         
     | 
| 
       81561 
     | 
    
         
            -
                        }
         
     | 
| 
       81562 
     | 
    
         
            -
                      });
         
     | 
| 
       81563 
     | 
    
         
            -
                    }
         
     | 
| 
      
 82306 
     | 
    
         
            +
                    if (!hasEq && nextArg === void 0)
         
     | 
| 
      
 82307 
     | 
    
         
            +
                      throw invalidStringSyntax(match2);
         
     | 
| 
       81564 
82308 
     | 
    
         
             
                    if (opt.enumVals && !opt.enumVals.find((val2) => val2 === dataPart)) {
         
     | 
| 
       81565 
     | 
    
         
            -
                      throw  
     | 
| 
       81566 
     | 
    
         
            -
                        type: "error",
         
     | 
| 
       81567 
     | 
    
         
            -
                        name: cliName,
         
     | 
| 
       81568 
     | 
    
         
            -
                        description: cliDescription,
         
     | 
| 
       81569 
     | 
    
         
            -
                        violation: "enum_violation",
         
     | 
| 
       81570 
     | 
    
         
            -
                        option: opt,
         
     | 
| 
       81571 
     | 
    
         
            -
                        command: command2,
         
     | 
| 
       81572 
     | 
    
         
            -
                        offender: {
         
     | 
| 
       81573 
     | 
    
         
            -
                          namePart,
         
     | 
| 
       81574 
     | 
    
         
            -
                          dataPart
         
     | 
| 
       81575 
     | 
    
         
            -
                        }
         
     | 
| 
       81576 
     | 
    
         
            -
                      });
         
     | 
| 
      
 82309 
     | 
    
         
            +
                      throw enumViolation(match2, dataPart, opt.enumVals);
         
     | 
| 
       81577 
82310 
     | 
    
         
             
                    }
         
     | 
| 
       81578 
82311 
     | 
    
         
             
                    data = dataPart;
         
     | 
| 
       81579 
82312 
     | 
    
         
             
                    return true;
         
     | 
| 
       81580 
82313 
     | 
    
         
             
                  }
         
     | 
| 
       81581 
     | 
    
         
            -
                  if (!hasEq && nextArg === void 0) 
     | 
| 
       81582 
     | 
    
         
            -
                    throw  
     | 
| 
       81583 
     | 
    
         
            -
                      type: "error",
         
     | 
| 
       81584 
     | 
    
         
            -
                      name: cliName,
         
     | 
| 
       81585 
     | 
    
         
            -
                      description: cliDescription,
         
     | 
| 
       81586 
     | 
    
         
            -
                      violation: "invalid_number_syntax",
         
     | 
| 
       81587 
     | 
    
         
            -
                      option: opt,
         
     | 
| 
       81588 
     | 
    
         
            -
                      command: command2,
         
     | 
| 
       81589 
     | 
    
         
            -
                      offender: {
         
     | 
| 
       81590 
     | 
    
         
            -
                        namePart,
         
     | 
| 
       81591 
     | 
    
         
            -
                        dataPart
         
     | 
| 
       81592 
     | 
    
         
            -
                      }
         
     | 
| 
       81593 
     | 
    
         
            -
                    });
         
     | 
| 
       81594 
     | 
    
         
            -
                  }
         
     | 
| 
      
 82314 
     | 
    
         
            +
                  if (!hasEq && nextArg === void 0)
         
     | 
| 
      
 82315 
     | 
    
         
            +
                    throw invalidNumberSyntax(match2);
         
     | 
| 
       81595 
82316 
     | 
    
         
             
                  const numData = Number(dataPart);
         
     | 
| 
       81596 
     | 
    
         
            -
                  if (isNaN(numData)) 
     | 
| 
       81597 
     | 
    
         
            -
                    throw  
     | 
| 
       81598 
     | 
    
         
            -
             
     | 
| 
       81599 
     | 
    
         
            -
             
     | 
| 
       81600 
     | 
    
         
            -
             
     | 
| 
       81601 
     | 
    
         
            -
             
     | 
| 
       81602 
     | 
    
         
            -
             
     | 
| 
       81603 
     | 
    
         
            -
             
     | 
| 
       81604 
     | 
    
         
            -
             
     | 
| 
       81605 
     | 
    
         
            -
                        namePart,
         
     | 
| 
       81606 
     | 
    
         
            -
                        dataPart
         
     | 
| 
       81607 
     | 
    
         
            -
                      }
         
     | 
| 
       81608 
     | 
    
         
            -
                    });
         
     | 
| 
       81609 
     | 
    
         
            -
                  }
         
     | 
| 
       81610 
     | 
    
         
            -
                  if (opt.isInt && !isInt(numData)) {
         
     | 
| 
       81611 
     | 
    
         
            -
                    throw new BroCliError(void 0, {
         
     | 
| 
       81612 
     | 
    
         
            -
                      type: "error",
         
     | 
| 
       81613 
     | 
    
         
            -
                      name: cliName,
         
     | 
| 
       81614 
     | 
    
         
            -
                      description: cliDescription,
         
     | 
| 
       81615 
     | 
    
         
            -
                      violation: "expected_int",
         
     | 
| 
       81616 
     | 
    
         
            -
                      option: opt,
         
     | 
| 
       81617 
     | 
    
         
            -
                      command: command2,
         
     | 
| 
       81618 
     | 
    
         
            -
                      offender: {
         
     | 
| 
       81619 
     | 
    
         
            -
                        namePart,
         
     | 
| 
       81620 
     | 
    
         
            -
                        dataPart
         
     | 
| 
       81621 
     | 
    
         
            -
                      }
         
     | 
| 
       81622 
     | 
    
         
            -
                    });
         
     | 
| 
       81623 
     | 
    
         
            -
                  }
         
     | 
| 
       81624 
     | 
    
         
            -
                  if (opt.minVal !== void 0 && numData < opt.minVal) {
         
     | 
| 
       81625 
     | 
    
         
            -
                    throw new BroCliError(void 0, {
         
     | 
| 
       81626 
     | 
    
         
            -
                      type: "error",
         
     | 
| 
       81627 
     | 
    
         
            -
                      name: cliName,
         
     | 
| 
       81628 
     | 
    
         
            -
                      description: cliDescription,
         
     | 
| 
       81629 
     | 
    
         
            -
                      violation: "below_min",
         
     | 
| 
       81630 
     | 
    
         
            -
                      option: opt,
         
     | 
| 
       81631 
     | 
    
         
            -
                      command: command2,
         
     | 
| 
       81632 
     | 
    
         
            -
                      offender: {
         
     | 
| 
       81633 
     | 
    
         
            -
                        namePart,
         
     | 
| 
       81634 
     | 
    
         
            -
                        dataPart
         
     | 
| 
       81635 
     | 
    
         
            -
                      }
         
     | 
| 
       81636 
     | 
    
         
            -
                    });
         
     | 
| 
       81637 
     | 
    
         
            -
                  }
         
     | 
| 
       81638 
     | 
    
         
            -
                  if (opt.maxVal !== void 0 && numData > opt.maxVal) {
         
     | 
| 
       81639 
     | 
    
         
            -
                    throw new BroCliError(void 0, {
         
     | 
| 
       81640 
     | 
    
         
            -
                      type: "error",
         
     | 
| 
       81641 
     | 
    
         
            -
                      name: cliName,
         
     | 
| 
       81642 
     | 
    
         
            -
                      description: cliDescription,
         
     | 
| 
       81643 
     | 
    
         
            -
                      violation: "above_max",
         
     | 
| 
       81644 
     | 
    
         
            -
                      option: opt,
         
     | 
| 
       81645 
     | 
    
         
            -
                      command: command2,
         
     | 
| 
       81646 
     | 
    
         
            -
                      offender: {
         
     | 
| 
       81647 
     | 
    
         
            -
                        namePart,
         
     | 
| 
       81648 
     | 
    
         
            -
                        dataPart
         
     | 
| 
       81649 
     | 
    
         
            -
                      }
         
     | 
| 
       81650 
     | 
    
         
            -
                    });
         
     | 
| 
       81651 
     | 
    
         
            -
                  }
         
     | 
| 
       81652 
     | 
    
         
            -
                  data = numData;
         
     | 
| 
      
 82317 
     | 
    
         
            +
                  if (isNaN(numData))
         
     | 
| 
      
 82318 
     | 
    
         
            +
                    throw invalidNumberValue(match2, dataPart);
         
     | 
| 
      
 82319 
     | 
    
         
            +
                  if (opt.isInt && !isInt(numData))
         
     | 
| 
      
 82320 
     | 
    
         
            +
                    throw invalidInteger(match2, dataPart);
         
     | 
| 
      
 82321 
     | 
    
         
            +
                  if (opt.minVal !== void 0 && numData < opt.minVal)
         
     | 
| 
      
 82322 
     | 
    
         
            +
                    throw belowMin(match2, dataPart, opt.minVal);
         
     | 
| 
      
 82323 
     | 
    
         
            +
                  if (opt.maxVal !== void 0 && numData > opt.maxVal)
         
     | 
| 
      
 82324 
     | 
    
         
            +
                    throw aboveMax(match2, dataPart, opt.maxVal);
         
     | 
| 
      
 82325 
     | 
    
         
            +
                  data = dataPart;
         
     | 
| 
       81653 
82326 
     | 
    
         
             
                  return true;
         
     | 
| 
       81654 
82327 
     | 
    
         
             
                }
         
     | 
| 
       81655 
82328 
     | 
    
         
             
              });
         
     | 
| 
         @@ -81660,7 +82333,7 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri 
     | 
|
| 
       81660 
82333 
     | 
    
         
             
                option: option == null ? void 0 : option[1]
         
     | 
| 
       81661 
82334 
     | 
    
         
             
              };
         
     | 
| 
       81662 
82335 
     | 
    
         
             
            };
         
     | 
| 
       81663 
     | 
    
         
            -
            var parseOptions = (command2, args,  
     | 
| 
      
 82336 
     | 
    
         
            +
            var parseOptions = (command2, args, omitKeysOfUndefinedOptions) => {
         
     | 
| 
       81664 
82337 
     | 
    
         
             
              const options = command2.options;
         
     | 
| 
       81665 
82338 
     | 
    
         
             
              const optEntries = Object.entries(options ?? {}).map(
         
     | 
| 
       81666 
82339 
     | 
    
         
             
                (opt) => [opt[0], opt[1].config]
         
     | 
| 
         @@ -81680,16 +82353,16 @@ var parseOptions = (command2, args, cliName, cliDescription, omitKeysOfUndefined 
     | 
|
| 
       81680 
82353 
     | 
    
         
             
                  skipNext,
         
     | 
| 
       81681 
82354 
     | 
    
         
             
                  isHelp,
         
     | 
| 
       81682 
82355 
     | 
    
         
             
                  isVersion
         
     | 
| 
       81683 
     | 
    
         
            -
                } = parseArg( 
     | 
| 
      
 82356 
     | 
    
         
            +
                } = parseArg(nonPositionalEntries, positionalEntries, arg, nextArg);
         
     | 
| 
       81684 
82357 
     | 
    
         
             
                if (!option)
         
     | 
| 
       81685 
82358 
     | 
    
         
             
                  unrecognizedArgsArr.push(arg.split("=")[0]);
         
     | 
| 
       81686 
82359 
     | 
    
         
             
                if (skipNext)
         
     | 
| 
       81687 
82360 
     | 
    
         
             
                  ++i2;
         
     | 
| 
      
 82361 
     | 
    
         
            +
                result[name] = data;
         
     | 
| 
       81688 
82362 
     | 
    
         
             
                if (isHelp)
         
     | 
| 
       81689 
82363 
     | 
    
         
             
                  return "help";
         
     | 
| 
       81690 
82364 
     | 
    
         
             
                if (isVersion)
         
     | 
| 
       81691 
82365 
     | 
    
         
             
                  return "version";
         
     | 
| 
       81692 
     | 
    
         
            -
                result[name] = data;
         
     | 
| 
       81693 
82366 
     | 
    
         
             
              }
         
     | 
| 
       81694 
82367 
     | 
    
         
             
              for (const [optKey, option] of optEntries) {
         
     | 
| 
       81695 
82368 
     | 
    
         
             
                const data = result[optKey] ?? option.default;
         
     | 
| 
         @@ -81702,29 +82375,19 @@ var parseOptions = (command2, args, cliName, cliDescription, omitKeysOfUndefined 
     | 
|
| 
       81702 
82375 
     | 
    
         
             
                if (option.isRequired && result[optKey] === void 0)
         
     | 
| 
       81703 
82376 
     | 
    
         
             
                  missingRequiredArr.push([option.name, ...option.aliases]);
         
     | 
| 
       81704 
82377 
     | 
    
         
             
              }
         
     | 
| 
       81705 
     | 
    
         
            -
              if (missingRequiredArr.length) 
     | 
| 
       81706 
     | 
    
         
            -
                throw  
     | 
| 
       81707 
     | 
    
         
            -
             
     | 
| 
       81708 
     | 
    
         
            -
             
     | 
| 
       81709 
     | 
    
         
            -
             
     | 
| 
       81710 
     | 
    
         
            -
                  description: cliDescription,
         
     | 
| 
       81711 
     | 
    
         
            -
                  command: command2,
         
     | 
| 
       81712 
     | 
    
         
            -
                  missing: missingRequiredArr
         
     | 
| 
       81713 
     | 
    
         
            -
                });
         
     | 
| 
       81714 
     | 
    
         
            -
              }
         
     | 
| 
       81715 
     | 
    
         
            -
              if (unrecognizedArgsArr.length) {
         
     | 
| 
       81716 
     | 
    
         
            -
                throw new BroCliError(void 0, {
         
     | 
| 
       81717 
     | 
    
         
            -
                  type: "error",
         
     | 
| 
       81718 
     | 
    
         
            -
                  violation: "unrecognized_args_error",
         
     | 
| 
       81719 
     | 
    
         
            -
                  name: cliName,
         
     | 
| 
       81720 
     | 
    
         
            -
                  description: cliDescription,
         
     | 
| 
       81721 
     | 
    
         
            -
                  command: command2,
         
     | 
| 
       81722 
     | 
    
         
            -
                  unrecognized: unrecognizedArgsArr
         
     | 
| 
       81723 
     | 
    
         
            -
                });
         
     | 
| 
       81724 
     | 
    
         
            -
              }
         
     | 
| 
       81725 
     | 
    
         
            -
              return Object.keys(result).length ? result : void 0;
         
     | 
| 
      
 82378 
     | 
    
         
            +
              if (missingRequiredArr.length)
         
     | 
| 
      
 82379 
     | 
    
         
            +
                throw missingRequired(command2, missingRequiredArr);
         
     | 
| 
      
 82380 
     | 
    
         
            +
              if (unrecognizedArgsArr.length)
         
     | 
| 
      
 82381 
     | 
    
         
            +
                throw unrecognizedOptions(command2, unrecognizedArgsArr);
         
     | 
| 
      
 82382 
     | 
    
         
            +
              return result;
         
     | 
| 
       81726 
82383 
     | 
    
         
             
            };
         
     | 
| 
       81727 
     | 
    
         
            -
            var  
     | 
| 
      
 82384 
     | 
    
         
            +
            var executeOrLog = async (target) => {
         
     | 
| 
      
 82385 
     | 
    
         
            +
              if (!target || typeof target === "string")
         
     | 
| 
      
 82386 
     | 
    
         
            +
                console.log(target);
         
     | 
| 
      
 82387 
     | 
    
         
            +
              else
         
     | 
| 
      
 82388 
     | 
    
         
            +
                await target();
         
     | 
| 
      
 82389 
     | 
    
         
            +
            };
         
     | 
| 
      
 82390 
     | 
    
         
            +
            var getCommandNameRecursive = (command2) => command2.parent ? `${getCommandNameRecursive(command2.parent)} ${command2.name}` : command2.name;
         
     | 
| 
       81728 
82391 
     | 
    
         
             
            var validateCommands = (commands, parent) => {
         
     | 
| 
       81729 
82392 
     | 
    
         
             
              const storedNames = {};
         
     | 
| 
       81730 
82393 
     | 
    
         
             
              for (const cmd of commands) {
         
     | 
| 
         @@ -81733,8 +82396,8 @@ var validateCommands = (commands, parent) => { 
     | 
|
| 
       81733 
82396 
     | 
    
         
             
                  const nameOccupier = storage2.find((e2) => e2 === cmd.name);
         
     | 
| 
       81734 
82397 
     | 
    
         
             
                  if (!nameOccupier)
         
     | 
| 
       81735 
82398 
     | 
    
         
             
                    continue;
         
     | 
| 
       81736 
     | 
    
         
            -
                  throw new  
     | 
| 
       81737 
     | 
    
         
            -
                    `Can't define command '${ 
     | 
| 
      
 82399 
     | 
    
         
            +
                  throw new Error(
         
     | 
| 
      
 82400 
     | 
    
         
            +
                    `Can't define command '${getCommandNameRecursive(cmd)}': name is already in use by command '${parent ? `${getCommandNameRecursive(parent)} ` : ""}${storage2[0]}'!`
         
     | 
| 
       81738 
82401 
     | 
    
         
             
                  );
         
     | 
| 
       81739 
82402 
     | 
    
         
             
                }
         
     | 
| 
       81740 
82403 
     | 
    
         
             
                if (cmd.aliases) {
         
     | 
| 
         @@ -81743,8 +82406,8 @@ var validateCommands = (commands, parent) => { 
     | 
|
| 
       81743 
82406 
     | 
    
         
             
                      const nameOccupier = storage2.find((e2) => e2 === alias);
         
     | 
| 
       81744 
82407 
     | 
    
         
             
                      if (!nameOccupier)
         
     | 
| 
       81745 
82408 
     | 
    
         
             
                        continue;
         
     | 
| 
       81746 
     | 
    
         
            -
                      throw new  
     | 
| 
       81747 
     | 
    
         
            -
                        `Can't define command '${ 
     | 
| 
      
 82409 
     | 
    
         
            +
                      throw new Error(
         
     | 
| 
      
 82410 
     | 
    
         
            +
                        `Can't define command '${getCommandNameRecursive(cmd)}': alias '${alias}' is already in use by command '${parent ? `${getCommandNameRecursive(parent)} ` : ""}${storage2[0]}'!`
         
     | 
| 
       81748 
82411 
     | 
    
         
             
                      );
         
     | 
| 
       81749 
82412 
     | 
    
         
             
                    }
         
     | 
| 
       81750 
82413 
     | 
    
         
             
                  }
         
     | 
| 
         @@ -81756,135 +82419,53 @@ var validateCommands = (commands, parent) => { 
     | 
|
| 
       81756 
82419 
     | 
    
         
             
              return commands;
         
     | 
| 
       81757 
82420 
     | 
    
         
             
            };
         
     | 
| 
       81758 
82421 
     | 
    
         
             
            var removeByIndex = (arr, idx) => [...arr.slice(0, idx), ...arr.slice(idx + 1, arr.length)];
         
     | 
| 
       81759 
     | 
    
         
            -
            var  
     | 
| 
      
 82422 
     | 
    
         
            +
            var help = async (command2, commands, helpHandler) => typeof command2 === "object" ? command2.help !== void 0 ? await executeOrLog(command2.help) : await helpHandler(command2) : await helpHandler(commands);
         
     | 
| 
      
 82423 
     | 
    
         
            +
            var rawCli = async (commands, config) => {
         
     | 
| 
       81760 
82424 
     | 
    
         
             
              var _a, _b;
         
     | 
| 
       81761 
     | 
    
         
            -
              const  
     | 
| 
      
 82425 
     | 
    
         
            +
              const processedCmds = validateCommands(commands);
         
     | 
| 
       81762 
82426 
     | 
    
         
             
              const argSource = (config == null ? void 0 : config.argSource) ?? process.argv;
         
     | 
| 
       81763 
82427 
     | 
    
         
             
              const version3 = config == null ? void 0 : config.version;
         
     | 
| 
       81764 
     | 
    
         
            -
              const  
     | 
| 
      
 82428 
     | 
    
         
            +
              const helpHandler = (config == null ? void 0 : config.help) ?? defaultTheme;
         
     | 
| 
       81765 
82429 
     | 
    
         
             
              const omitKeysOfUndefinedOptions = (config == null ? void 0 : config.omitKeysOfUndefinedOptions) ?? false;
         
     | 
| 
       81766 
     | 
    
         
            -
               
     | 
| 
       81767 
     | 
    
         
            -
               
     | 
| 
      
 82430 
     | 
    
         
            +
              let args = argSource.slice(2, argSource.length);
         
     | 
| 
      
 82431 
     | 
    
         
            +
              if (!args.length)
         
     | 
| 
      
 82432 
     | 
    
         
            +
                return await helpHandler(processedCmds);
         
     | 
| 
      
 82433 
     | 
    
         
            +
              const helpIndex = args.findIndex((arg) => arg === "--help" || arg === "-h");
         
     | 
| 
      
 82434 
     | 
    
         
            +
              if (helpIndex !== -1 && (helpIndex > 0 ? ((_a = args[helpIndex - 1]) == null ? void 0 : _a.startsWith("-")) && !args[helpIndex - 1].includes("=") ? false : true : true)) {
         
     | 
| 
      
 82435 
     | 
    
         
            +
                const command3 = getCommand(processedCmds, args).command;
         
     | 
| 
      
 82436 
     | 
    
         
            +
                return help(command3, processedCmds, helpHandler);
         
     | 
| 
      
 82437 
     | 
    
         
            +
              }
         
     | 
| 
      
 82438 
     | 
    
         
            +
              const versionIndex = args.findIndex((arg) => arg === "--version" || arg === "-v");
         
     | 
| 
      
 82439 
     | 
    
         
            +
              if (versionIndex !== -1 && (versionIndex > 0 ? ((_b = args[versionIndex - 1]) == null ? void 0 : _b.startsWith("-")) ? false : true : true)) {
         
     | 
| 
      
 82440 
     | 
    
         
            +
                return await executeOrLog(version3);
         
     | 
| 
      
 82441 
     | 
    
         
            +
              }
         
     | 
| 
      
 82442 
     | 
    
         
            +
              const { command: command2, args: newArgs } = getCommand(processedCmds, args);
         
     | 
| 
      
 82443 
     | 
    
         
            +
              if (!command2)
         
     | 
| 
      
 82444 
     | 
    
         
            +
                return helpHandler(processedCmds);
         
     | 
| 
      
 82445 
     | 
    
         
            +
              if (command2 === "help") {
         
     | 
| 
      
 82446 
     | 
    
         
            +
                const { command: helpCommand } = getCommand(processedCmds, newArgs);
         
     | 
| 
      
 82447 
     | 
    
         
            +
                return help(helpCommand, processedCmds, helpHandler);
         
     | 
| 
      
 82448 
     | 
    
         
            +
              }
         
     | 
| 
      
 82449 
     | 
    
         
            +
              const optionResult = parseOptions(command2, newArgs, omitKeysOfUndefinedOptions);
         
     | 
| 
      
 82450 
     | 
    
         
            +
              if (optionResult === "help")
         
     | 
| 
      
 82451 
     | 
    
         
            +
                return await help(command2, commands, helpHandler);
         
     | 
| 
      
 82452 
     | 
    
         
            +
              if (optionResult === "version")
         
     | 
| 
      
 82453 
     | 
    
         
            +
                return await executeOrLog(version3);
         
     | 
| 
      
 82454 
     | 
    
         
            +
              if (optionResult) {
         
     | 
| 
      
 82455 
     | 
    
         
            +
                if (config == null ? void 0 : config.hook)
         
     | 
| 
      
 82456 
     | 
    
         
            +
                  await config.hook("pre", command2);
         
     | 
| 
      
 82457 
     | 
    
         
            +
                await command2.handler(command2.transform ? await command2.transform(optionResult) : optionResult);
         
     | 
| 
      
 82458 
     | 
    
         
            +
                if (config == null ? void 0 : config.hook)
         
     | 
| 
      
 82459 
     | 
    
         
            +
                  await config.hook("post", command2);
         
     | 
| 
      
 82460 
     | 
    
         
            +
              }
         
     | 
| 
      
 82461 
     | 
    
         
            +
              return void 0;
         
     | 
| 
      
 82462 
     | 
    
         
            +
            };
         
     | 
| 
      
 82463 
     | 
    
         
            +
            var run = async (commands, config) => {
         
     | 
| 
       81768 
82464 
     | 
    
         
             
              try {
         
     | 
| 
       81769 
     | 
    
         
            -
                 
     | 
| 
       81770 
     | 
    
         
            -
                let args = argSource.slice(2, argSource.length);
         
     | 
| 
       81771 
     | 
    
         
            -
                if (!args.length) {
         
     | 
| 
       81772 
     | 
    
         
            -
                  return help !== void 0 ? await executeOrLog(help) : await eventHandler({
         
     | 
| 
       81773 
     | 
    
         
            -
                    type: "global_help",
         
     | 
| 
       81774 
     | 
    
         
            -
                    description: cliDescription,
         
     | 
| 
       81775 
     | 
    
         
            -
                    name: cliName,
         
     | 
| 
       81776 
     | 
    
         
            -
                    commands: processedCmds
         
     | 
| 
       81777 
     | 
    
         
            -
                  });
         
     | 
| 
       81778 
     | 
    
         
            -
                }
         
     | 
| 
       81779 
     | 
    
         
            -
                const helpIndex = args.findIndex((arg) => arg === "--help" || arg === "-h");
         
     | 
| 
       81780 
     | 
    
         
            -
                if (helpIndex !== -1 && (helpIndex > 0 ? ((_a = args[helpIndex - 1]) == null ? void 0 : _a.startsWith("-")) && !args[helpIndex - 1].includes("=") ? false : true : true)) {
         
     | 
| 
       81781 
     | 
    
         
            -
                  const command3 = getCommand(processedCmds, args, cliName, cliDescription).command;
         
     | 
| 
       81782 
     | 
    
         
            -
                  if (typeof command3 === "object") {
         
     | 
| 
       81783 
     | 
    
         
            -
                    return command3.help !== void 0 ? await executeOrLog(command3.help) : await eventHandler({
         
     | 
| 
       81784 
     | 
    
         
            -
                      type: "command_help",
         
     | 
| 
       81785 
     | 
    
         
            -
                      description: cliDescription,
         
     | 
| 
       81786 
     | 
    
         
            -
                      name: cliName,
         
     | 
| 
       81787 
     | 
    
         
            -
                      command: command3
         
     | 
| 
       81788 
     | 
    
         
            -
                    });
         
     | 
| 
       81789 
     | 
    
         
            -
                  } else {
         
     | 
| 
       81790 
     | 
    
         
            -
                    return help !== void 0 ? await executeOrLog(help) : await eventHandler({
         
     | 
| 
       81791 
     | 
    
         
            -
                      type: "global_help",
         
     | 
| 
       81792 
     | 
    
         
            -
                      description: cliDescription,
         
     | 
| 
       81793 
     | 
    
         
            -
                      name: cliName,
         
     | 
| 
       81794 
     | 
    
         
            -
                      commands: processedCmds
         
     | 
| 
       81795 
     | 
    
         
            -
                    });
         
     | 
| 
       81796 
     | 
    
         
            -
                  }
         
     | 
| 
       81797 
     | 
    
         
            -
                }
         
     | 
| 
       81798 
     | 
    
         
            -
                const versionIndex = args.findIndex((arg) => arg === "--version" || arg === "-v");
         
     | 
| 
       81799 
     | 
    
         
            -
                if (versionIndex !== -1 && (versionIndex > 0 ? ((_b = args[versionIndex - 1]) == null ? void 0 : _b.startsWith("-")) ? false : true : true)) {
         
     | 
| 
       81800 
     | 
    
         
            -
                  return version3 !== void 0 ? await executeOrLog(version3) : await eventHandler({
         
     | 
| 
       81801 
     | 
    
         
            -
                    type: "version",
         
     | 
| 
       81802 
     | 
    
         
            -
                    name: cliName,
         
     | 
| 
       81803 
     | 
    
         
            -
                    description: cliDescription
         
     | 
| 
       81804 
     | 
    
         
            -
                  });
         
     | 
| 
       81805 
     | 
    
         
            -
                }
         
     | 
| 
       81806 
     | 
    
         
            -
                const { command: command2, args: newArgs } = getCommand(processedCmds, args, cliName, cliDescription);
         
     | 
| 
       81807 
     | 
    
         
            -
                if (!command2) {
         
     | 
| 
       81808 
     | 
    
         
            -
                  return help !== void 0 ? await executeOrLog(help) : await eventHandler({
         
     | 
| 
       81809 
     | 
    
         
            -
                    type: "global_help",
         
     | 
| 
       81810 
     | 
    
         
            -
                    description: cliDescription,
         
     | 
| 
       81811 
     | 
    
         
            -
                    name: cliName,
         
     | 
| 
       81812 
     | 
    
         
            -
                    commands: processedCmds
         
     | 
| 
       81813 
     | 
    
         
            -
                  });
         
     | 
| 
       81814 
     | 
    
         
            -
                }
         
     | 
| 
       81815 
     | 
    
         
            -
                if (command2 === "help") {
         
     | 
| 
       81816 
     | 
    
         
            -
                  let helpCommand;
         
     | 
| 
       81817 
     | 
    
         
            -
                  let newestArgs = newArgs;
         
     | 
| 
       81818 
     | 
    
         
            -
                  do {
         
     | 
| 
       81819 
     | 
    
         
            -
                    const res = getCommand(processedCmds, newestArgs, cliName, cliDescription);
         
     | 
| 
       81820 
     | 
    
         
            -
                    helpCommand = res.command;
         
     | 
| 
       81821 
     | 
    
         
            -
                    newestArgs = res.args;
         
     | 
| 
       81822 
     | 
    
         
            -
                  } while (helpCommand === "help");
         
     | 
| 
       81823 
     | 
    
         
            -
                  return helpCommand ? helpCommand.help !== void 0 ? await executeOrLog(helpCommand.help) : await eventHandler({
         
     | 
| 
       81824 
     | 
    
         
            -
                    type: "command_help",
         
     | 
| 
       81825 
     | 
    
         
            -
                    description: cliDescription,
         
     | 
| 
       81826 
     | 
    
         
            -
                    name: cliName,
         
     | 
| 
       81827 
     | 
    
         
            -
                    command: helpCommand
         
     | 
| 
       81828 
     | 
    
         
            -
                  }) : help !== void 0 ? await executeOrLog(help) : await eventHandler({
         
     | 
| 
       81829 
     | 
    
         
            -
                    type: "global_help",
         
     | 
| 
       81830 
     | 
    
         
            -
                    description: cliDescription,
         
     | 
| 
       81831 
     | 
    
         
            -
                    name: cliName,
         
     | 
| 
       81832 
     | 
    
         
            -
                    commands: processedCmds
         
     | 
| 
       81833 
     | 
    
         
            -
                  });
         
     | 
| 
       81834 
     | 
    
         
            -
                }
         
     | 
| 
       81835 
     | 
    
         
            -
                const optionResult = parseOptions(command2, newArgs, cliName, cliDescription, omitKeysOfUndefinedOptions);
         
     | 
| 
       81836 
     | 
    
         
            -
                if (optionResult === "help") {
         
     | 
| 
       81837 
     | 
    
         
            -
                  return command2.help !== void 0 ? await executeOrLog(command2.help) : await eventHandler({
         
     | 
| 
       81838 
     | 
    
         
            -
                    type: "command_help",
         
     | 
| 
       81839 
     | 
    
         
            -
                    description: cliDescription,
         
     | 
| 
       81840 
     | 
    
         
            -
                    name: cliName,
         
     | 
| 
       81841 
     | 
    
         
            -
                    command: command2
         
     | 
| 
       81842 
     | 
    
         
            -
                  });
         
     | 
| 
       81843 
     | 
    
         
            -
                }
         
     | 
| 
       81844 
     | 
    
         
            -
                if (optionResult === "version") {
         
     | 
| 
       81845 
     | 
    
         
            -
                  return version3 !== void 0 ? await executeOrLog(version3) : await eventHandler({
         
     | 
| 
       81846 
     | 
    
         
            -
                    type: "version",
         
     | 
| 
       81847 
     | 
    
         
            -
                    name: cliName,
         
     | 
| 
       81848 
     | 
    
         
            -
                    description: cliDescription
         
     | 
| 
       81849 
     | 
    
         
            -
                  });
         
     | 
| 
       81850 
     | 
    
         
            -
                }
         
     | 
| 
       81851 
     | 
    
         
            -
                if (command2.handler) {
         
     | 
| 
       81852 
     | 
    
         
            -
                  if (config == null ? void 0 : config.hook)
         
     | 
| 
       81853 
     | 
    
         
            -
                    await config.hook("before", command2);
         
     | 
| 
       81854 
     | 
    
         
            -
                  await command2.handler(command2.transform ? await command2.transform(optionResult) : optionResult);
         
     | 
| 
       81855 
     | 
    
         
            -
                  if (config == null ? void 0 : config.hook)
         
     | 
| 
       81856 
     | 
    
         
            -
                    await config.hook("after", command2);
         
     | 
| 
       81857 
     | 
    
         
            -
                  return;
         
     | 
| 
       81858 
     | 
    
         
            -
                } else {
         
     | 
| 
       81859 
     | 
    
         
            -
                  return command2.help !== void 0 ? await executeOrLog(command2.help) : await eventHandler({
         
     | 
| 
       81860 
     | 
    
         
            -
                    type: "command_help",
         
     | 
| 
       81861 
     | 
    
         
            -
                    description: cliDescription,
         
     | 
| 
       81862 
     | 
    
         
            -
                    name: cliName,
         
     | 
| 
       81863 
     | 
    
         
            -
                    command: command2
         
     | 
| 
       81864 
     | 
    
         
            -
                  });
         
     | 
| 
       81865 
     | 
    
         
            -
                }
         
     | 
| 
      
 82465 
     | 
    
         
            +
                await rawCli(commands, config);
         
     | 
| 
       81866 
82466 
     | 
    
         
             
              } catch (e2) {
         
     | 
| 
       81867 
     | 
    
         
            -
                 
     | 
| 
       81868 
     | 
    
         
            -
             
     | 
| 
       81869 
     | 
    
         
            -
                    await eventHandler(e2.event);
         
     | 
| 
       81870 
     | 
    
         
            -
                  else {
         
     | 
| 
       81871 
     | 
    
         
            -
                    if (!(config == null ? void 0 : config.noExit))
         
     | 
| 
       81872 
     | 
    
         
            -
                      console.error(e2.message);
         
     | 
| 
       81873 
     | 
    
         
            -
                    else
         
     | 
| 
       81874 
     | 
    
         
            -
                      return e2.message;
         
     | 
| 
       81875 
     | 
    
         
            -
                  }
         
     | 
| 
       81876 
     | 
    
         
            -
                } else {
         
     | 
| 
       81877 
     | 
    
         
            -
                  await eventHandler({
         
     | 
| 
       81878 
     | 
    
         
            -
                    type: "error",
         
     | 
| 
       81879 
     | 
    
         
            -
                    violation: "unknown_error",
         
     | 
| 
       81880 
     | 
    
         
            -
                    name: cliName,
         
     | 
| 
       81881 
     | 
    
         
            -
                    description: cliDescription,
         
     | 
| 
       81882 
     | 
    
         
            -
                    error: e2
         
     | 
| 
       81883 
     | 
    
         
            -
                  });
         
     | 
| 
       81884 
     | 
    
         
            -
                }
         
     | 
| 
       81885 
     | 
    
         
            -
                if (!(config == null ? void 0 : config.noExit))
         
     | 
| 
       81886 
     | 
    
         
            -
                  process.exit(1);
         
     | 
| 
       81887 
     | 
    
         
            -
                return;
         
     | 
| 
      
 82467 
     | 
    
         
            +
                console.error(typeof e2 === "object" && e2 !== null && "message" in e2 ? e2.message : e2);
         
     | 
| 
      
 82468 
     | 
    
         
            +
                process.exit(1);
         
     | 
| 
       81888 
82469 
     | 
    
         
             
              }
         
     | 
| 
       81889 
82470 
     | 
    
         
             
            };
         
     | 
| 
       81890 
82471 
     | 
    
         
             
            var OptionBuilderBase = class _OptionBuilderBase {
         
     | 
| 
         @@ -81962,7 +82543,7 @@ var OptionBuilderBase = class _OptionBuilderBase { 
     | 
|
| 
       81962 
82543 
     | 
    
         
             
              max(value) {
         
     | 
| 
       81963 
82544 
     | 
    
         
             
                const config = this.config();
         
     | 
| 
       81964 
82545 
     | 
    
         
             
                const minVal = config.minVal;
         
     | 
| 
       81965 
     | 
    
         
            -
                if (minVal !== void 0 && minVal  
     | 
| 
      
 82546 
     | 
    
         
            +
                if (minVal !== void 0 && minVal < value) {
         
     | 
| 
       81966 
82547 
     | 
    
         
             
                  throw new BroCliError("Unable to define option's max value to be lower than min value!");
         
     | 
| 
       81967 
82548 
     | 
    
         
             
                }
         
     | 
| 
       81968 
82549 
     | 
    
         
             
                return new _OptionBuilderBase({ ...config, maxVal: value });
         
     | 
| 
         @@ -83493,7 +84074,7 @@ var push = command({ 
     | 
|
| 
       83493 
84074 
     | 
    
         
             
                      schemasFilter,
         
     | 
| 
       83494 
84075 
     | 
    
         
             
                      force
         
     | 
| 
       83495 
84076 
     | 
    
         
             
                    );
         
     | 
| 
       83496 
     | 
    
         
            -
                  } else if (dialect7 === "sqlite") {
         
     | 
| 
      
 84077 
     | 
    
         
            +
                  } else if (dialect7 === "sqlite" && !("driver" in credentials2)) {
         
     | 
| 
       83497 
84078 
     | 
    
         
             
                    const { sqlitePush: sqlitePush2 } = await Promise.resolve().then(() => (init_push(), push_exports));
         
     | 
| 
       83498 
84079 
     | 
    
         
             
                    await sqlitePush2(
         
     | 
| 
       83499 
84080 
     | 
    
         
             
                      schemaPath,
         
     | 
| 
         @@ -83503,6 +84084,16 @@ var push = command({ 
     | 
|
| 
       83503 
84084 
     | 
    
         
             
                      tablesFilter,
         
     | 
| 
       83504 
84085 
     | 
    
         
             
                      force
         
     | 
| 
       83505 
84086 
     | 
    
         
             
                    );
         
     | 
| 
      
 84087 
     | 
    
         
            +
                  } else if (dialect7 === "sqlite" && ("driver" in credentials2 && credentials2.driver === "turso")) {
         
     | 
| 
      
 84088 
     | 
    
         
            +
                    const { libSQLPush: libSQLPush2 } = await Promise.resolve().then(() => (init_push(), push_exports));
         
     | 
| 
      
 84089 
     | 
    
         
            +
                    await libSQLPush2(
         
     | 
| 
      
 84090 
     | 
    
         
            +
                      schemaPath,
         
     | 
| 
      
 84091 
     | 
    
         
            +
                      verbose,
         
     | 
| 
      
 84092 
     | 
    
         
            +
                      strict,
         
     | 
| 
      
 84093 
     | 
    
         
            +
                      credentials2,
         
     | 
| 
      
 84094 
     | 
    
         
            +
                      tablesFilter,
         
     | 
| 
      
 84095 
     | 
    
         
            +
                      force
         
     | 
| 
      
 84096 
     | 
    
         
            +
                    );
         
     | 
| 
       83506 
84097 
     | 
    
         
             
                  } else {
         
     | 
| 
       83507 
84098 
     | 
    
         
             
                    assertUnreachable(dialect7);
         
     | 
| 
       83508 
84099 
     | 
    
         
             
                  }
         
     | 
| 
         @@ -83786,7 +84377,7 @@ init_utils2(); 
     | 
|
| 
       83786 
84377 
     | 
    
         
             
            var version2 = async () => {
         
     | 
| 
       83787 
84378 
     | 
    
         
             
              const { npmVersion } = await ormCoreVersions();
         
     | 
| 
       83788 
84379 
     | 
    
         
             
              const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
         
     | 
| 
       83789 
     | 
    
         
            -
              const envVersion = "0.24.0- 
     | 
| 
      
 84380 
     | 
    
         
            +
              const envVersion = "0.24.0-bb966f7";
         
     | 
| 
       83790 
84381 
     | 
    
         
             
              const kitVersion = envVersion ? `v${envVersion}` : "--";
         
     | 
| 
       83791 
84382 
     | 
    
         
             
              const versions = `drizzle-kit: ${kitVersion}
         
     | 
| 
       83792 
84383 
     | 
    
         
             
            ${ormVersion}`;
         
     | 
| 
         @@ -83821,7 +84412,6 @@ var legacy = [ 
     | 
|
| 
       83821 
84412 
     | 
    
         
             
              legacyCommand("check:sqlite", "check")
         
     | 
| 
       83822 
84413 
     | 
    
         
             
            ];
         
     | 
| 
       83823 
84414 
     | 
    
         
             
            run([generate, migrate, pull, push, studio, up, check, drop, ...legacy], {
         
     | 
| 
       83824 
     | 
    
         
            -
              name: "drizzle-kit",
         
     | 
| 
       83825 
84415 
     | 
    
         
             
              version: version2
         
     | 
| 
       83826 
84416 
     | 
    
         
             
            });
         
     | 
| 
       83827 
84417 
     | 
    
         
             
            /*! Bundled license information:
         
     |