<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20260125143939 extends AbstractMigration
{
    public function getDescription(): string
    {
        return '';
    }

    public function up(Schema $schema): void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_f95a3199df92e79b') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_f95a3199df92e79b RENAME TO IDX_F95A3199CC8A4CEE';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_f95a3199a3fdb2a7') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_f95a3199a3fdb2a7 RENAME TO IDX_F95A319936799605';
  END IF;
END $$;
SQL
);
        $this->addSql('ALTER TABLE _composantconstructeurs DROP CONSTRAINT IF EXISTS "_ComposantConstructeurs_A_fkey"');
        $this->addSql('ALTER TABLE _composantconstructeurs DROP CONSTRAINT IF EXISTS "_ComposantConstructeurs_B_fkey"');
        $this->addSql('ALTER TABLE _composantconstructeurs ALTER A TYPE VARCHAR(36)');
        $this->addSql('ALTER TABLE _composantconstructeurs ALTER B TYPE VARCHAR(36)');
        $this->addSql('ALTER TABLE _composantconstructeurs ADD CONSTRAINT FK_60760125D3D99E8B FOREIGN KEY (A) REFERENCES composants (id) ON DELETE CASCADE NOT DEFERRABLE');
        $this->addSql('ALTER TABLE _composantconstructeurs ADD CONSTRAINT FK_607601254AD0CF31 FOREIGN KEY (B) REFERENCES constructeurs (id) ON DELETE CASCADE NOT DEFERRABLE');
        $this->addSql('ALTER TABLE _composantconstructeurs ADD PRIMARY KEY (A, B)');
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_5b97d813e8b7be43') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_5b97d813e8b7be43 RENAME TO IDX_60760125D3D99E8B';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('_composantconstructeurs_b_index') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX _composantconstructeurs_b_index RENAME TO IDX_607601254AD0CF31';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_6b64d7ff6736d61') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_6b64d7ff6736d61 RENAME TO IDX_6B64D7FF5C4A705F';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_6b64d7fff6bae05f') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_6b64d7fff6bae05f RENAME TO IDX_6B64D7FF633EC4FD';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_6b64d7ffa1dac1c6') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_6b64d7ffa1dac1c6 RENAME TO IDX_6B64D7FF345EE564';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_6b64d7ff96428d73') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_6b64d7ff96428d73 RENAME TO IDX_6B64D7FF3C6A9D1';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_6b64d7ffa3fdb2a7') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_6b64d7ffa3fdb2a7 RENAME TO IDX_6B64D7FF36799605';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_4a48378c158582c3') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_4a48378c158582c3 RENAME TO IDX_4A48378C2F024C2';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_4a48378cdf92e79b') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_4a48378cdf92e79b RENAME TO IDX_4A48378CCC8A4CEE';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_4a48378c4ca601c8') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_4a48378c4ca601c8 RENAME TO IDX_4A48378C169F1CF6';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_4a48378c40c2d03b') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_4a48378c40c2d03b RENAME TO IDX_4A48378C57B7763A';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_a2b07288f6bae05f') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_a2b07288f6bae05f RENAME TO IDX_A2B07288633EC4FD';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_a2b07288a1dac1c6') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_a2b07288a1dac1c6 RENAME TO IDX_A2B07288345EE564';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_a2b0728896428d73') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_a2b0728896428d73 RENAME TO IDX_A2B072883C6A9D1';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_a2b07288a3fdb2a7') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_a2b07288a3fdb2a7 RENAME TO IDX_A2B0728836799605';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_a2b07288fcf7805f') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_a2b07288fcf7805f RENAME TO IDX_A2B072886973A4FD';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_528efe19f6bae05f') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_528efe19f6bae05f RENAME TO IDX_528EFE19633EC4FD';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_528efe19a1dac1c6') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_528efe19a1dac1c6 RENAME TO IDX_528EFE19345EE564';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_528efe197d44d2df') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_528efe197d44d2df RENAME TO IDX_528EFE19EF6CF34B';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_528efe19bcced9e3') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_528efe19bcced9e3 RENAME TO IDX_528EFE19C44B383C';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_62941615f6bae05f') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_62941615f6bae05f RENAME TO IDX_62941615633EC4FD';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_6294161596428d73') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_6294161596428d73 RENAME TO IDX_629416153C6A9D1';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_629416157d44d2df') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_629416157d44d2df RENAME TO IDX_62941615EF6CF34B';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_6294161532c54aaf') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_6294161532c54aaf RENAME TO IDX_62941615F957D314';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('machine_product_links_machineid_idx') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX machine_product_links_machineid_idx RENAME TO IDX_8CC32259633EC4FD';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('machine_product_links_productid_idx') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX machine_product_links_productid_idx RENAME TO IDX_8CC3225936799605';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_8cc32259357fdbff') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_8cc32259357fdbff RENAME TO IDX_8CC32259B590B209';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_8cc322597d44d2df') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_8cc322597d44d2df RENAME TO IDX_8CC32259EF6CF34B';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_8cc32259bcd7dad6') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_8cc32259bcd7dad6 RENAME TO IDX_8CC32259A63AC5DC';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_8cc3225987ceb33f') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_8cc3225987ceb33f RENAME TO IDX_8CC32259937A1D7C';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_f1ce8dedfcf7805f') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_f1ce8dedfcf7805f RENAME TO IDX_F1CE8DED6973A4FD';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_f1ce8ded158582c3') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_f1ce8ded158582c3 RENAME TO IDX_F1CE8DED2F024C2';
  END IF;
END $$;
SQL
);
        $this->addSql('ALTER TABLE _machineconstructeurs DROP CONSTRAINT IF EXISTS "_MachineConstructeurs_B_fkey"');
        $this->addSql('ALTER TABLE _machineconstructeurs DROP CONSTRAINT IF EXISTS "_MachineConstructeurs_A_fkey"');
        $this->addSql('ALTER TABLE _machineconstructeurs ALTER A TYPE VARCHAR(36)');
        $this->addSql('ALTER TABLE _machineconstructeurs ALTER B TYPE VARCHAR(36)');
        $this->addSql('ALTER TABLE _machineconstructeurs ADD CONSTRAINT FK_E6A040CCD3D99E8B FOREIGN KEY (A) REFERENCES machines (id) ON DELETE CASCADE NOT DEFERRABLE');
        $this->addSql('ALTER TABLE _machineconstructeurs ADD CONSTRAINT FK_E6A040CC4AD0CF31 FOREIGN KEY (B) REFERENCES constructeurs (id) ON DELETE CASCADE NOT DEFERRABLE');
        $this->addSql('ALTER TABLE _machineconstructeurs ADD PRIMARY KEY (A, B)');
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_4f225b32e8b7be43') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_4f225b32e8b7be43 RENAME TO IDX_E6A040CCD3D99E8B';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('_machineconstructeurs_b_index') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX _machineconstructeurs_b_index RENAME TO IDX_E6A040CC4AD0CF31';
  END IF;
END $$;
SQL
);
        $this->addSql('ALTER TABLE model_types DROP CONSTRAINT IF EXISTS "ModelType_category_name_key"');
        $this->addSql('ALTER TABLE model_types DROP CONSTRAINT IF EXISTS "ModelType_code_key"');
        $this->addSql('ALTER TABLE model_types ALTER id TYPE VARCHAR(36)');
        $this->addSql('ALTER TABLE model_types ALTER category TYPE VARCHAR(255)');
        $this->addSql('ALTER TABLE model_types ALTER createdAt DROP DEFAULT');
        $this->addSql('ALTER TABLE model_types ALTER componentSkeleton TYPE JSON');
        $this->addSql('ALTER TABLE model_types ALTER pieceSkeleton TYPE JSON');
        $this->addSql('ALTER TABLE model_types ALTER productSkeleton TYPE JSON');
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_b92d74724ca601c8') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_b92d74724ca601c8 RENAME TO IDX_B92D7472169F1CF6';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_b92d7472a3fdb2a7') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_b92d7472a3fdb2a7 RENAME TO IDX_B92D747236799605';
  END IF;
END $$;
SQL
);
        $this->addSql('ALTER TABLE _piececonstructeurs DROP CONSTRAINT IF EXISTS "_PieceConstructeurs_A_fkey"');
        $this->addSql('ALTER TABLE _piececonstructeurs DROP CONSTRAINT IF EXISTS "_PieceConstructeurs_B_fkey"');
        $this->addSql('ALTER TABLE _piececonstructeurs ALTER A TYPE VARCHAR(36)');
        $this->addSql('ALTER TABLE _piececonstructeurs ALTER B TYPE VARCHAR(36)');
        $this->addSql('ALTER TABLE _piececonstructeurs ADD CONSTRAINT FK_E94732E5D3D99E8B FOREIGN KEY (A) REFERENCES pieces (id) ON DELETE CASCADE NOT DEFERRABLE');
        $this->addSql('ALTER TABLE _piececonstructeurs ADD CONSTRAINT FK_E94732E54AD0CF31 FOREIGN KEY (B) REFERENCES constructeurs (id) ON DELETE CASCADE NOT DEFERRABLE');
        $this->addSql('ALTER TABLE _piececonstructeurs ADD PRIMARY KEY (A, B)');
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_77fc120e8b7be43') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_77fc120e8b7be43 RENAME TO IDX_E94732E5D3D99E8B';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('_piececonstructeurs_b_index') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX _piececonstructeurs_b_index RENAME TO IDX_E94732E54AD0CF31';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_b3ba5a5a40c2d03b') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_b3ba5a5a40c2d03b RENAME TO IDX_B3BA5A5A57B7763A';
  END IF;
END $$;
SQL
);
        $this->addSql('ALTER TABLE _productconstructeurs DROP CONSTRAINT IF EXISTS "_ProductConstructeurs_B_fkey"');
        $this->addSql('ALTER TABLE _productconstructeurs DROP CONSTRAINT IF EXISTS "_ProductConstructeurs_A_fkey"');
        $this->addSql('ALTER TABLE _productconstructeurs ALTER A TYPE VARCHAR(36)');
        $this->addSql('ALTER TABLE _productconstructeurs ALTER B TYPE VARCHAR(36)');
        // Clean orphaned relations before re-adding foreign keys.
        $this->addSql('DELETE FROM _productconstructeurs WHERE A IS NULL OR B IS NULL');
        $this->addSql('DELETE FROM _productconstructeurs pc WHERE NOT EXISTS (SELECT 1 FROM products p WHERE p.id = pc.A)');
        $this->addSql('DELETE FROM _productconstructeurs pc WHERE NOT EXISTS (SELECT 1 FROM constructeurs c WHERE c.id = pc.B)');
        $this->addSql('ALTER TABLE _productconstructeurs ADD CONSTRAINT FK_CF7403FCD3D99E8B FOREIGN KEY (A) REFERENCES products (id) ON DELETE CASCADE NOT DEFERRABLE');
        $this->addSql('ALTER TABLE _productconstructeurs ADD CONSTRAINT FK_CF7403FC4AD0CF31 FOREIGN KEY (B) REFERENCES constructeurs (id) ON DELETE CASCADE NOT DEFERRABLE');
        $this->addSql('ALTER TABLE _productconstructeurs ADD PRIMARY KEY (A, B)');
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_66f61802e8b7be43') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_66f61802e8b7be43 RENAME TO IDX_CF7403FCD3D99E8B';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('_productconstructeurs_b_index') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX _productconstructeurs_b_index RENAME TO IDX_CF7403FC4AD0CF31';
  END IF;
END $$;
SQL
);
        $this->addSql('DROP INDEX IF EXISTS uniq_profiles_email');
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_96958790158582c3') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_96958790158582c3 RENAME TO IDX_969587902F024C2';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_96958790df92e79b') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_96958790df92e79b RENAME TO IDX_96958790CC8A4CEE';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_f609e59e158582c3') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_f609e59e158582c3 RENAME TO IDX_F609E59E2F024C2';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_f609e59e4ca601c8') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_f609e59e4ca601c8 RENAME TO IDX_F609E59E169F1CF6';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_29a51f98158582c3') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_29a51f98158582c3 RENAME TO IDX_29A51F982F024C2';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_29a51f9840c2d03b') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_29a51f9840c2d03b RENAME TO IDX_29A51F9857B7763A';
  END IF;
END $$;
SQL
);
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE _ComposantConstructeurs DROP CONSTRAINT IF EXISTS FK_60760125D3D99E8B');
        $this->addSql('ALTER TABLE _ComposantConstructeurs DROP CONSTRAINT IF EXISTS FK_607601254AD0CF31');
        $this->addSql('ALTER TABLE _ComposantConstructeurs DROP CONSTRAINT IF EXISTS _ComposantConstructeurs_pkey');
        $this->addSql('ALTER TABLE _ComposantConstructeurs ALTER a TYPE TEXT');
        $this->addSql('ALTER TABLE _ComposantConstructeurs ALTER b TYPE TEXT');
        $this->addSql('ALTER TABLE _ComposantConstructeurs ADD CONSTRAINT "_ComposantConstructeurs_A_fkey" FOREIGN KEY (a) REFERENCES composants (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE _ComposantConstructeurs ADD CONSTRAINT "_ComposantConstructeurs_B_fkey" FOREIGN KEY (b) REFERENCES constructeurs (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_607601254ad0cf31') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_607601254ad0cf31 RENAME TO "_ComposantConstructeurs_B_index"';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_60760125d3d99e8b') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_60760125d3d99e8b RENAME TO IDX_5B97D813E8B7BE43';
  END IF;
END $$;
SQL
);
        $this->addSql('ALTER TABLE _MachineConstructeurs DROP CONSTRAINT IF EXISTS FK_E6A040CCD3D99E8B');
        $this->addSql('ALTER TABLE _MachineConstructeurs DROP CONSTRAINT IF EXISTS FK_E6A040CC4AD0CF31');
        $this->addSql('ALTER TABLE _MachineConstructeurs DROP CONSTRAINT IF EXISTS _MachineConstructeurs_pkey');
        $this->addSql('ALTER TABLE _MachineConstructeurs ALTER a TYPE TEXT');
        $this->addSql('ALTER TABLE _MachineConstructeurs ALTER b TYPE TEXT');
        $this->addSql('ALTER TABLE _MachineConstructeurs ADD CONSTRAINT "_MachineConstructeurs_B_fkey" FOREIGN KEY (b) REFERENCES constructeurs (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE _MachineConstructeurs ADD CONSTRAINT "_MachineConstructeurs_A_fkey" FOREIGN KEY (a) REFERENCES machines (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_e6a040cc4ad0cf31') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_e6a040cc4ad0cf31 RENAME TO "_MachineConstructeurs_B_index"';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_e6a040ccd3d99e8b') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_e6a040ccd3d99e8b RENAME TO IDX_4F225B32E8B7BE43';
  END IF;
END $$;
SQL
);
        $this->addSql('ALTER TABLE _PieceConstructeurs DROP CONSTRAINT IF EXISTS FK_E94732E5D3D99E8B');
        $this->addSql('ALTER TABLE _PieceConstructeurs DROP CONSTRAINT IF EXISTS FK_E94732E54AD0CF31');
        $this->addSql('ALTER TABLE _PieceConstructeurs DROP CONSTRAINT IF EXISTS _PieceConstructeurs_pkey');
        $this->addSql('ALTER TABLE _PieceConstructeurs ALTER a TYPE TEXT');
        $this->addSql('ALTER TABLE _PieceConstructeurs ALTER b TYPE TEXT');
        $this->addSql('ALTER TABLE _PieceConstructeurs ADD CONSTRAINT "_PieceConstructeurs_A_fkey" FOREIGN KEY (a) REFERENCES pieces (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE _PieceConstructeurs ADD CONSTRAINT "_PieceConstructeurs_B_fkey" FOREIGN KEY (b) REFERENCES constructeurs (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_e94732e54ad0cf31') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_e94732e54ad0cf31 RENAME TO "_PieceConstructeurs_B_index"';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_e94732e5d3d99e8b') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_e94732e5d3d99e8b RENAME TO IDX_77FC120E8B7BE43';
  END IF;
END $$;
SQL
);
        $this->addSql('ALTER TABLE _ProductConstructeurs DROP CONSTRAINT IF EXISTS FK_CF7403FCD3D99E8B');
        $this->addSql('ALTER TABLE _ProductConstructeurs DROP CONSTRAINT IF EXISTS FK_CF7403FC4AD0CF31');
        $this->addSql('ALTER TABLE _ProductConstructeurs DROP CONSTRAINT IF EXISTS _ProductConstructeurs_pkey');
        $this->addSql('ALTER TABLE _ProductConstructeurs ALTER a TYPE TEXT');
        $this->addSql('ALTER TABLE _ProductConstructeurs ALTER b TYPE TEXT');
        $this->addSql('ALTER TABLE _ProductConstructeurs ADD CONSTRAINT "_ProductConstructeurs_B_fkey" FOREIGN KEY (b) REFERENCES products (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE _ProductConstructeurs ADD CONSTRAINT "_ProductConstructeurs_A_fkey" FOREIGN KEY (a) REFERENCES constructeurs (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_cf7403fc4ad0cf31') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_cf7403fc4ad0cf31 RENAME TO "_ProductConstructeurs_B_index"';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_cf7403fcd3d99e8b') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_cf7403fcd3d99e8b RENAME TO IDX_66F61802E8B7BE43';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_f95a319936799605') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_f95a319936799605 RENAME TO IDX_F95A3199A3FDB2A7';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_f95a3199cc8a4cee') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_f95a3199cc8a4cee RENAME TO IDX_F95A3199DF92E79B';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_6b64d7ff345ee564') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_6b64d7ff345ee564 RENAME TO IDX_6B64D7FFA1DAC1C6';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_6b64d7ff5c4a705f') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_6b64d7ff5c4a705f RENAME TO IDX_6B64D7FF6736D61';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_6b64d7ff633ec4fd') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_6b64d7ff633ec4fd RENAME TO IDX_6B64D7FFF6BAE05F';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_6b64d7ff3c6a9d1') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_6b64d7ff3c6a9d1 RENAME TO IDX_6B64D7FF96428D73';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_6b64d7ff36799605') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_6b64d7ff36799605 RENAME TO IDX_6B64D7FFA3FDB2A7';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_4a48378c57b7763a') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_4a48378c57b7763a RENAME TO IDX_4A48378C40C2D03B';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_4a48378c2f024c2') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_4a48378c2f024c2 RENAME TO IDX_4A48378C158582C3';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_4a48378c169f1cf6') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_4a48378c169f1cf6 RENAME TO IDX_4A48378C4CA601C8';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_4a48378ccc8a4cee') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_4a48378ccc8a4cee RENAME TO IDX_4A48378CDF92E79B';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_a2b07288345ee564') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_a2b07288345ee564 RENAME TO IDX_A2B07288A1DAC1C6';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_a2b07288633ec4fd') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_a2b07288633ec4fd RENAME TO IDX_A2B07288F6BAE05F';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_a2b072886973a4fd') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_a2b072886973a4fd RENAME TO IDX_A2B07288FCF7805F';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_a2b072883c6a9d1') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_a2b072883c6a9d1 RENAME TO IDX_A2B0728896428D73';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_a2b0728836799605') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_a2b0728836799605 RENAME TO IDX_A2B07288A3FDB2A7';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_528efe19345ee564') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_528efe19345ee564 RENAME TO IDX_528EFE19A1DAC1C6';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_528efe19633ec4fd') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_528efe19633ec4fd RENAME TO IDX_528EFE19F6BAE05F';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_528efe19ef6cf34b') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_528efe19ef6cf34b RENAME TO IDX_528EFE197D44D2DF';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_528efe19c44b383c') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_528efe19c44b383c RENAME TO IDX_528EFE19BCCED9E3';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_62941615ef6cf34b') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_62941615ef6cf34b RENAME TO IDX_629416157D44D2DF';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_62941615633ec4fd') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_62941615633ec4fd RENAME TO IDX_62941615F6BAE05F';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_629416153c6a9d1') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_629416153c6a9d1 RENAME TO IDX_6294161596428D73';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_62941615f957d314') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_62941615f957d314 RENAME TO IDX_6294161532C54AAF';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_8cc32259633ec4fd') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_8cc32259633ec4fd RENAME TO "machine_product_links_machineId_idx"';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_8cc3225936799605') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_8cc3225936799605 RENAME TO "machine_product_links_productId_idx"';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_8cc32259ef6cf34b') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_8cc32259ef6cf34b RENAME TO IDX_8CC322597D44D2DF';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_8cc32259b590b209') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_8cc32259b590b209 RENAME TO IDX_8CC32259357FDBFF';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_8cc32259a63ac5dc') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_8cc32259a63ac5dc RENAME TO IDX_8CC32259BCD7DAD6';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_8cc32259937a1d7c') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_8cc32259937a1d7c RENAME TO IDX_8CC3225987CEB33F';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_f1ce8ded2f024c2') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_f1ce8ded2f024c2 RENAME TO IDX_F1CE8DED158582C3';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_f1ce8ded6973a4fd') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_f1ce8ded6973a4fd RENAME TO IDX_F1CE8DEDFCF7805F';
  END IF;
END $$;
SQL
);
        $this->addSql('ALTER TABLE model_types ALTER id TYPE TEXT');
        $this->addSql('ALTER TABLE model_types ALTER category TYPE VARCHAR');
        $this->addSql('ALTER TABLE model_types ALTER componentskeleton TYPE JSONB');
        $this->addSql('ALTER TABLE model_types ALTER pieceskeleton TYPE JSONB');
        $this->addSql('ALTER TABLE model_types ALTER productskeleton TYPE JSONB');
        $this->addSql('ALTER TABLE model_types ALTER createdat SET DEFAULT CURRENT_TIMESTAMP');
        $this->addSql('CREATE UNIQUE INDEX "ModelType_category_name_key" ON model_types (category, name)');
        $this->addSql('CREATE UNIQUE INDEX "ModelType_code_key" ON model_types (code)');
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_b92d7472169f1cf6') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_b92d7472169f1cf6 RENAME TO IDX_B92D74724CA601C8';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_b92d747236799605') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_b92d747236799605 RENAME TO IDX_B92D7472A3FDB2A7';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_b3ba5a5a57b7763a') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_b3ba5a5a57b7763a RENAME TO IDX_B3BA5A5A40C2D03B';
  END IF;
END $$;
SQL
);
        $this->addSql('CREATE UNIQUE INDEX uniq_profiles_email ON profiles (email)');
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_969587902f024c2') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_969587902f024c2 RENAME TO IDX_96958790158582C3';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_96958790cc8a4cee') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_96958790cc8a4cee RENAME TO IDX_96958790DF92E79B';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_f609e59e169f1cf6') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_f609e59e169f1cf6 RENAME TO IDX_F609E59E4CA601C8';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_f609e59e2f024c2') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_f609e59e2f024c2 RENAME TO IDX_F609E59E158582C3';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_29a51f9857b7763a') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_29a51f9857b7763a RENAME TO IDX_29A51F9840C2D03B';
  END IF;
END $$;
SQL
);
        $this->addSql(<<<'SQL'
DO $$ BEGIN
  IF to_regclass('idx_29a51f982f024c2') IS NOT NULL THEN
    EXECUTE 'ALTER INDEX idx_29a51f982f024c2 RENAME TO IDX_29A51F98158582C3';
  END IF;
END $$;
SQL
);
    }
}
