igaster/laravel_cities

FOREIGN_KEY_CHECKS

ninjasitm opened this issue · 2 comments

Getting this error when seeding on PostgreSQL:

SQLSTATE[42704]: Undefined object: 7 ERROR:  unrecognized configuration parameter "foreign_key_checks" (SQL: SET FOREIGN_KEY_CHECKS=1;)

This is caused by:

\DB::statement('SET FOREIGN_KEY_CHECKS=1;');

This is found on line 173 in seedGeoFile.php;

Fortunately Laravel supports:

Schema::disableForeignKeyConstraints();

Same issue using test environment with sqlite

testing.ERROR: SQLSTATE[HY000]: General error: 1 near "SET": syntax error (SQL: SET FOREIGN_KEY_CHECKS=1;) {"exception":"[object] (Illuminate\\Database\\QueryException(code: HY000): SQLSTATE[HY000]: General error: 1 near \"SET\": syntax error (SQL: SET FOREIGN_KEY_CHECKS=1;) at /home/runner/work/app1t/app1t/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, Doctrine\\DBAL\\Driver\\PDOException(code: HY000): SQLSTATE[HY000]: General error: 1 near \"SET\": syntax error at /home/runner/work/app1t/app1t/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:63, PDOException(code: HY000): SQLSTATE[HY000]: General error: 1 near \"SET\": syntax error at /home/runner/work/app1t/app1t/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:61)