murilo
4 months ago

desabilitate foreign key and DROP ALL TABLES IN POSTGREE

Posted 4 months ago by murilo

Hello guys , I have this comman that I use in Laravel , that desabilitate foreign key , and delete .

     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
        foreach (ResetMigrationTables::getAll() as $table){
            Schema::dropIfExists($table);
        }

        Schema::dropIfExists('migrations');

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

those commands works in mySQL -

DB::statement('SET FOREIGN_KEY_CHECKS=0;');
...
DB::statement('SET FOREIGN_KEY_CHECKS=1;');

IN Postgree I dint find any command like this that can desabilitate the forner key , to I delete alll I tryed this one

  Schema::disableForeignKeyConstraints();
  Schema::enableForeignKeyConstraints();

But does not work , does some one had the same problem ?

Please sign in or create an account to participate in this conversation.