jeroenzwart / laravel-csv-seeder

Seed your database with Laravel using CSV files
Other
92 stars 30 forks source link

No FOREIGN_KEY_CHECKS configuration in PostgreSQL #24

Closed duffn closed 2 years ago

duffn commented 2 years ago

First, thanks for the package.

This does not work with PostgreSQL if truncate is set to true. PostgreSQL does not have a FOREIGN_KEY_CHECKS configuration option. https://github.com/jeroenzwart/laravel-csv-seeder/blob/4c6746c4af83437809d623b0dd133884eccd3946/src/CsvSeeder.php#L282-L291

This is the error received:

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

The workaround is to set $this->truncate = false; in the seeder.