Environnement:
- php 8.1
- symfony 5.4
- doctrine/dbal 3.3
- doctrine/doctrine-bundle 2.7
- doctrine/migrations 3.5.1
- postgresql 14.4
My problem is the following; We have a database containing several schema to separate the data useful to the system and those published directly to users. We use of course the classic entity declaration with Symfony & Doctrine:
/**
* @ORM\Table(name="stats", schema="system")
* @ORM\Entity(repositoryClass="App\Repository\System\StatsRepository")
*/
class Stats
The problem is that when we delete a relation between the public
schema and the system
schema, the migration generated by the command bin/console doctrine:schema:update
has an error when deleting the index.
Here is the migration generated:
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('DROP INDEX idx_2225600edc6d4b4b');
$this->addSql('ALTER TABLE system.stats DROP article_id');
}
The problem being that in deleting the index, the line forgets to specify that the index comes from the system
schema.
We need:
$this->addSql('DROP INDEX system.idx_2225600edc6d4b4b');
We want to keep the bin/console doctrine:schema:update
operation for updating the database, but this problem now forces us to use the migration system to change the drop index.
I know that the obvious solution would be to use the migration system (bin/console make:migration
) but this implies some changes in the IC. That's why I'm wondering; have you ever had this problem? If yes, how did you solve the problem?