Description
- Laravel Version: v9.17.0 (but also the same with any lower version
- PHP Version: 8.1 (but PHP version does not take affect)
- Database Driver & Version: PostgreSQL (14.3), but also does not take affect
Description:
I can not drop existing index in my database (PostgreSQL) with standard migration.
The problem persist, if using PostgreSQL and prefix is not empty string.
The problem is in file:
Line: 355
It generates index name without prefix.
When primary key index name is generating, it leaves naming for PostgreSQL, even if passing optional parameter $index. Generated SQL is something like:
alter table "prefix_test" add primary key ("id")
and PostgreSQL creates index name: prefix_test_pkey
When executing $table->dropPrimary(), raw sql is:
alter table "prefix_test" drop constraint "test_pkey", it does not add prefix and so migration throws error that:
constraint "test_pkey" of relation "prefix_test" does not exist.
It should generate prefix_test_pkey
Optionally $table->primary() and $table->dropPrimary() allows to pass index name, but PostgresGrammar ignores it.
Steps To Reproduce:
- install Laravel
- change .env DB_CONNECTION to pgsql
- change config/database.php line 75 from 'prefix' => '', to 'prefix' => 'prefix_', (under pgsql)
- delete all files from database/migrations
- create migration file (php artisan make:migration create_test_table (see below)
- php artisan migrate (throws error)
file: XXXXXX_create_test_table.php
id(); $table->dropPrimary(); }); } /** * Reverse the migrations. * * @return void */ public function down() { } };