diff --git a/src/Migrations.php b/src/Migrations.php index fcf250b..83daed7 100644 --- a/src/Migrations.php +++ b/src/Migrations.php @@ -508,7 +508,7 @@ private static function connectionSetup(array $options): void self::$storage = new $adapter($configArray); if ($database->adapter === 'Mysql') { - //self::$storage->query('SET FOREIGN_KEY_CHECKS=0'); + self::$storage->query('SET FOREIGN_KEY_CHECKS=0'); } if (!self::$storage->tableExists(self::MIGRATION_LOG_TABLE)) { diff --git a/tests/cli/RunCest.php b/tests/cli/RunCest.php index 11ec3f0..3afaa6f 100644 --- a/tests/cli/RunCest.php +++ b/tests/cli/RunCest.php @@ -69,7 +69,7 @@ public function skipForeignKeys(CliTester $I): void $table1 = 'client'; $table2 = 'x-skip-foreign-keys'; - $this->createTablesWithForeignKey($I); + $this->createTablesWithForeignKey($I, $table1, $table2); $I->runShellCommand('php phalcon-migrations generate --config=' . $this->configPath); $I->seeInShellOutput('Success: Version 1.0.0 was successfully generated'); @@ -91,17 +91,17 @@ public function skipForeignKeys(CliTester $I): void */ public function expectForeignKeyDbError(CliTester $I): void { - $table1 = 'client'; - $table2 = 'x-skip-foreign-keys'; + $table1 = 'z-client'; + $table2 = 'skip-foreign-keys'; - $this->createTablesWithForeignKey($I); + $this->createTablesWithForeignKey($I, $table1, $table2); $I->runShellCommand('php phalcon-migrations generate --config=' . $this->configPath); $I->seeInShellOutput('Success: Version 1.0.0 was successfully generated'); $I->seeResultCodeIs(0); $migrationContent = file_get_contents(codecept_output_dir('1.0.0/' . $table2 . '.php')); - $I->assertNotFalse(strpos($migrationContent, "'referencedTable' => 'client',")); + $I->assertNotFalse(strpos($migrationContent, "'referencedTable' => '" . $table1 . "',")); $I->getPhalconDb()->dropTable($table2); $I->getPhalconDb()->dropTable($table1); @@ -115,12 +115,12 @@ public function expectForeignKeyDbError(CliTester $I): void * DRY! * * @param CliTester $I + * @param string $table1 + * @param string $table2 */ - protected function createTablesWithForeignKey(CliTester $I): void + protected function createTablesWithForeignKey(CliTester $I, string $table1, string $table2): void { $schema = getenv('MYSQL_TEST_DB_DATABASE'); - $table1 = 'client'; - $table2 = 'x-skip-foreign-keys'; $I->getPhalconDb()->createTable($table1, $schema, [ 'columns' => [