Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FOREIGN_KEY_CHECKS #25

Open
ninjasitm opened this issue Nov 26, 2019 · 2 comments
Open

FOREIGN_KEY_CHECKS #25

ninjasitm opened this issue Nov 26, 2019 · 2 comments

Comments

@ninjasitm
Copy link

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();
@davidjoan
Copy link

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)

@Ethan-Rivas
Copy link

You could add a Trait as mentioned here, it helped me:
https://laracasts.com/discuss/channels/eloquent/foreign-key-constraints-on-seeding

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants