Skip to content

Dependent objects still exist #709

@meeftah

Description

@meeftah

I'm using filamentPHP v5, when I run php artisan shield:setup --fresh I got this error

In Connection.php line 838:
                                                                                                                                                                              
  SQLSTATE[2BP01]: Dependent objects still exist: 7 ERROR:  cannot drop table roles because other objects depend on it                                                        
  DETAIL:  constraint model_has_roles_role_id_foreign on table model_has_roles depends on table roles                                                                         
  constraint role_has_permissions_role_id_foreign on table role_has_permissions depends on table roles                                                                        
  HINT:  Use DROP ... CASCADE to drop the dependent objects too. (Connection: custom_connection, Host: 127.0.0.1, Port: 5432, Database: my_database, SQL: DROP TABLE I  
  F EXISTS roles)                                                                                                                                                             
                                                                                                                                                                              

In Connection.php line 584:
                                                                                                                        
  SQLSTATE[2BP01]: Dependent objects still exist: 7 ERROR:  cannot drop table roles because other objects depend on it  
  DETAIL:  constraint model_has_roles_role_id_foreign on table model_has_roles depends on table roles                   
  constraint role_has_permissions_role_id_foreign on table role_has_permissions depends on table roles                  
  HINT:  Use DROP ... CASCADE to drop the dependent objects too.

it's because I'm using custom connection, I can bypass this using this command

DB_CONNECTION=pgsql \
DB_HOST=127.0.0.1 \
DB_PORT=5432 \
DB_DATABASE=my_database \
DB_USERNAME=my_user \
DB_PASSWORD='secret' \
php artisan shield:setup --fresh

This is my package patch suggestion (best logic):
Use DB::connection()->getDriverName() === 'pgsql' instead of checking database.default string

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions