Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [DPMMA-2252] point groups migration fix #13195

Merged
merged 2 commits into from Jan 12, 2024

Conversation

patrykgruszka
Copy link
Member

Q A
Bug fix? (use the a.b branch) [ Y ]
New feature/enhancement? (use the a.x branch) [ N ]
Deprecations? [ N ]
BC breaks? (use the c.x branch) [ ]
Automated tests included? [ ]
Related user documentation PR URL mautic/mautic-documentation#...
Related developer documentation PR URL mautic/developer-documentation#...
Issue(s) addressed Fixes #12993

Description:

This PR fixes the issue with point groups migration

Steps to test this PR:

  1. Open this PR on Gitpod or pull down for testing locally (see docs on testing PRs here)
  2. Run ddev exec php bin/console doctrine:migrations:migrate

Copy link
Sponsor Member

@escopecz escopecz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! I firstly removed the schema changes added by this migration:

jan@mautic-web:/var/www/html$ php bin/console doctrine:migrations:execute 'Mautic\Migrations\Version20230621074925' --down -vvv

 WARNING! You are about to execute a migration in database "db2" that could result in schema changes and data loss. Are you sure you wish to continue? (yes/no) [yes]:
 > 

[notice] Executing Mautic\Migrations\Version20230621074925 down
[info] ++ reverting Mautic\Migrations\Version20230621074925
[debug] ALTER TABLE `point_group_contact_score` DROP FOREIGN KEY `FK_9D85A703E7A1254A` 
[debug] ALTER TABLE `point_group_contact_score` DROP FOREIGN KEY `FK_9D85A703FE54D947` 
[debug] ALTER TABLE `points` DROP FOREIGN KEY `FK_27BA8E29FE54D947` 
[debug] ALTER TABLE `point_triggers` DROP FOREIGN KEY `FK_9CABD32FFE54D947` 
[debug] ALTER TABLE `lead_points_change_log` DROP FOREIGN KEY `FK_949C2CCCFE54D947` 
[debug] ALTER TABLE `points` DROP group_id 
[debug] ALTER TABLE `point_triggers` DROP group_id 
[debug] ALTER TABLE `lead_points_change_log` DROP group_id 
[debug] DROP TABLE point_group_contact_score 
[debug] DROP TABLE point_groups 
[info] Migration Mautic\Migrations\Version20230621074925 reverted (took 118.2ms, used 22M memory)
[notice] finished in 128.5ms, used 22M memory, 1 migrations executed, 10 sql queries

And then applied again:

jan@mautic-web:/var/www/html$ php bin/console doctrine:migrations:execute 'Mautic\Migrations\Version20230621074925' --up -vvv

 WARNING! You are about to execute a migration in database "db2" that could result in schema changes and data loss. Are you sure you wish to continue? (yes/no) [yes]:
 > 

[notice] Executing Mautic\Migrations\Version20230621074925 up
[info] ++ migrating Mautic\Migrations\Version20230621074925
[debug] CREATE TABLE `point_groups`
(
    `id`                  INT UNSIGNED AUTO_INCREMENT NOT NULL,
    `is_published`        TINYINT(1)                  NOT NULL,
    `date_added`          DATETIME     DEFAULT NULL,
    `created_by`          INT          DEFAULT NULL,
    `created_by_user`     VARCHAR(191) DEFAULT NULL,
    `date_modified`       DATETIME     DEFAULT NULL,
    `modified_by`         INT          DEFAULT NULL,
    `modified_by_user`    VARCHAR(191) DEFAULT NULL,
    `checked_out`         DATETIME     DEFAULT NULL,
    `checked_out_by`      INT          DEFAULT NULL,
    `checked_out_by_user` VARCHAR(191) DEFAULT NULL,
    `name`                VARCHAR(191)                NOT NULL,
    `description`         LONGTEXT     DEFAULT NULL,
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4
  COLLATE `utf8mb4_unicode_ci`
  ENGINE = InnoDB
  ROW_FORMAT = DYNAMIC; 
[debug] CREATE TABLE `point_group_contact_score`
(
    `contact_id`          BIGINT UNSIGNED NOT NULL,
    `group_id`           INT UNSIGNED    NOT NULL,
    `score`               INT             NOT NULL,
    PRIMARY KEY (`contact_id`, `group_id`)
) DEFAULT CHARACTER SET utf8mb4
  COLLATE `utf8mb4_unicode_ci`
  ENGINE = InnoDB
  ROW_FORMAT = DYNAMIC; 
[debug] ALTER TABLE `points` ADD group_id INT UNSIGNED DEFAULT NULL 
[debug] ALTER TABLE `point_triggers` ADD group_id INT UNSIGNED DEFAULT NULL 
[debug] ALTER TABLE `lead_points_change_log` ADD group_id INT UNSIGNED DEFAULT NULL 
[debug] ALTER TABLE `point_group_contact_score` ADD CONSTRAINT `FK_9D85A703E7A1254A` FOREIGN KEY (`contact_id`) REFERENCES `leads` (`id`) ON DELETE CASCADE 
[debug] ALTER TABLE `point_group_contact_score` ADD CONSTRAINT `FK_9D85A703FE54D947` FOREIGN KEY (`group_id`) REFERENCES `point_groups` (`id`) ON DELETE CASCADE 
[debug] ALTER TABLE `points` ADD CONSTRAINT `FK_27BA8E29FE54D947` FOREIGN KEY (`group_id`) REFERENCES `point_groups` (`id`) ON DELETE CASCADE 
[debug] ALTER TABLE `point_triggers` ADD CONSTRAINT `FK_9CABD32FFE54D947` FOREIGN KEY (`group_id`) REFERENCES `point_groups` (`id`) ON DELETE CASCADE 
[debug] ALTER TABLE `lead_points_change_log` ADD CONSTRAINT `FK_949C2CCCFE54D947` FOREIGN KEY (`group_id`) REFERENCES `point_groups` (`id`) ON DELETE CASCADE 
[info] Migration Mautic\Migrations\Version20230621074925 migrated (took 199.5ms, used 26M memory)
[notice] finished in 209.1ms, used 26M memory, 1 migrations executed, 10 sql queries

There were no errors, everything was smooth 👍 Thank you!

@escopecz escopecz added bug Issues or PR's relating to bugs db-migrations labels Jan 10, 2024
@escopecz escopecz added this to the 5.0.2 milestone Jan 10, 2024
@saschafoerster
Copy link

saschafoerster commented Jan 10, 2024

First try: Syntax error or access violation: 1091 Can't DROP FOREIGN KEY `FK_72243719E7A1254A
Second try: [PDOException (42S01)]
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'mau_point_groups' already exists

user@server:/var/www/html/mautic# php bin/console doctrine:migrations:execute 'Mautic\Migrations\Version20230621074925' --down -vvv

 WARNING! You are about to execute a migration in database "mautic_base" that could result in schema changes and data loss. Are you sure you wish to continue? (yes/no) [yes]:
 > yes

[notice] Executing Mautic\Migrations\Version20230621074925 down
[info] ++ reverting Mautic\Migrations\Version20230621074925
[debug] ALTER TABLE `mau_point_group_contact_score` DROP FOREIGN KEY `FK_72243719E7A1254A` 
[error] Migration Mautic\Migrations\Version20230621074925 failed during Execution. Error: "An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP FOREIGN KEY `FK_72243719E7A1254A`; check that it exists"

In ExceptionConverter.php line 117:
                                                                                                                                                                    
  [Doctrine\DBAL\Exception\DriverException (1091)]                                                                                                                  
  An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP FOREIGN KEY `FK_72243719E7A1254A`; check that   
  it exists                                                                                                                                                         
                                                                                                                                                                    

Exception trace:
  at /var/www/html/mautic/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php:117
 Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter->convert() at /var/www/html/mautic/vendor/doctrine/dbal/src/Connection.php:1938
 Doctrine\DBAL\Connection->handleDriverException() at /var/www/html/mautic/vendor/doctrine/dbal/src/Connection.php:1880
 Doctrine\DBAL\Connection->convertExceptionDuringQuery() at /var/www/html/mautic/vendor/doctrine/dbal/src/Connection.php:1105
 Doctrine\DBAL\Connection->executeQuery() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php:273
 Doctrine\Migrations\Version\DbalExecutor->executeResult() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php:150
 Doctrine\Migrations\Version\DbalExecutor->executeMigration() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php:73
 Doctrine\Migrations\Version\DbalExecutor->execute() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php:88
 Doctrine\Migrations\DbalMigrator->executePlan() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php:54
 Doctrine\Migrations\DbalMigrator->executeMigrations() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php:136
 Doctrine\Migrations\DbalMigrator->migrate() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php:157
 Doctrine\Migrations\Tools\Console\Command\ExecuteCommand->execute() at /var/www/html/mautic/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at /var/www/html/mautic/vendor/symfony/console/Application.php:1058
 Symfony\Component\Console\Application->doRunCommand() at /var/www/html/mautic/vendor/symfony/framework-bundle/Console/Application.php:96
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /var/www/html/mautic/vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at /var/www/html/mautic/vendor/symfony/framework-bundle/Console/Application.php:82
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/html/mautic/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at /var/www/html/mautic/bin/console:16

In Exception.php line 28:
                                                                                                                              
  [Doctrine\DBAL\Driver\PDO\Exception (1091)]                                                                                 
  SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP FOREIGN KEY `FK_72243719E7A1254A`; check that it exists  
                                                                                                                              

Exception trace:
  at /var/www/html/mautic/vendor/doctrine/dbal/src/Driver/PDO/Exception.php:28
 Doctrine\DBAL\Driver\PDO\Exception::new() at /var/www/html/mautic/vendor/doctrine/dbal/src/Driver/PDO/Connection.php:76
 Doctrine\DBAL\Driver\PDO\Connection->query() at /var/www/html/mautic/vendor/doctrine/dbal/src/Connection.php:1100
 Doctrine\DBAL\Connection->executeQuery() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php:273
 Doctrine\Migrations\Version\DbalExecutor->executeResult() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php:150
 Doctrine\Migrations\Version\DbalExecutor->executeMigration() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php:73
 Doctrine\Migrations\Version\DbalExecutor->execute() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php:88
 Doctrine\Migrations\DbalMigrator->executePlan() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php:54
 Doctrine\Migrations\DbalMigrator->executeMigrations() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php:136
 Doctrine\Migrations\DbalMigrator->migrate() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php:157
 Doctrine\Migrations\Tools\Console\Command\ExecuteCommand->execute() at /var/www/html/mautic/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at /var/www/html/mautic/vendor/symfony/console/Application.php:1058
 Symfony\Component\Console\Application->doRunCommand() at /var/www/html/mautic/vendor/symfony/framework-bundle/Console/Application.php:96
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /var/www/html/mautic/vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at /var/www/html/mautic/vendor/symfony/framework-bundle/Console/Application.php:82
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/html/mautic/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at /var/www/html/mautic/bin/console:16

In Connection.php line 71:
                                                                                                                              
  [PDOException (42000)]                                                                                                      
  SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP FOREIGN KEY `FK_72243719E7A1254A`; check that it exists  
                                                                                                                              

Exception trace:
  at /var/www/html/mautic/vendor/doctrine/dbal/src/Driver/PDO/Connection.php:71
 PDO->query() at /var/www/html/mautic/vendor/doctrine/dbal/src/Driver/PDO/Connection.php:71
 Doctrine\DBAL\Driver\PDO\Connection->query() at /var/www/html/mautic/vendor/doctrine/dbal/src/Connection.php:1100
 Doctrine\DBAL\Connection->executeQuery() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php:273
 Doctrine\Migrations\Version\DbalExecutor->executeResult() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php:150
 Doctrine\Migrations\Version\DbalExecutor->executeMigration() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php:73
 Doctrine\Migrations\Version\DbalExecutor->execute() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php:88
 Doctrine\Migrations\DbalMigrator->executePlan() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php:54
 Doctrine\Migrations\DbalMigrator->executeMigrations() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php:136
 Doctrine\Migrations\DbalMigrator->migrate() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php:157
 Doctrine\Migrations\Tools\Console\Command\ExecuteCommand->execute() at /var/www/html/mautic/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at /var/www/html/mautic/vendor/symfony/console/Application.php:1058
 Symfony\Component\Console\Application->doRunCommand() at /var/www/html/mautic/vendor/symfony/framework-bundle/Console/Application.php:96
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /var/www/html/mautic/vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at /var/www/html/mautic/vendor/symfony/framework-bundle/Console/Application.php:82
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/html/mautic/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at /var/www/html/mautic/bin/console:16

doctrine:migrations:execute [--write-sql [WRITE-SQL]] [--dry-run] [--up] [--down] [--query-time] [--configuration CONFIGURATION] [--em EM] [--conn CONN] [--] <versions>...
user@server:/var/www/html/mautic# php bin/console doctrine:migrations:execute 'Mautic\Migrations\Version20230621074925' --up -vvv

 WARNING! You are about to execute a migration in database "mautic_base" that could result in schema changes and data loss. Are you sure you wish to continue? (yes/no) [yes]:
 > yes

[notice] Executing Mautic\Migrations\Version20230621074925 up
[notice] Table mau_point_groups already exists
[notice] Table mau_point_group_contact_score already exists
[notice] Column mau_points.group_id already exists
[notice] Column mau_point_triggers.group_id already exists
[notice] Column mau_lead_points_change_log.group_id already exists
[info] ++ migrating Mautic\Migrations\Version20230621074925
[debug] CREATE TABLE `mau_point_groups`
(
    `id`                  INT UNSIGNED AUTO_INCREMENT NOT NULL,
    `is_published`        TINYINT(1)                  NOT NULL,
    `date_added`          DATETIME     DEFAULT NULL,
    `created_by`          INT          DEFAULT NULL,
    `created_by_user`     VARCHAR(191) DEFAULT NULL,
    `date_modified`       DATETIME     DEFAULT NULL,
    `modified_by`         INT          DEFAULT NULL,
    `modified_by_user`    VARCHAR(191) DEFAULT NULL,
    `checked_out`         DATETIME     DEFAULT NULL,
    `checked_out_by`      INT          DEFAULT NULL,
    `checked_out_by_user` VARCHAR(191) DEFAULT NULL,
    `name`                VARCHAR(191)                NOT NULL,
    `description`         LONGTEXT     DEFAULT NULL,
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4
  COLLATE `utf8mb4_unicode_ci`
  ENGINE = InnoDB
  ROW_FORMAT = DYNAMIC; 
[error] Migration Mautic\Migrations\Version20230621074925 failed during Execution. Error: "An exception occurred while executing a query: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'mau_point_groups' already exists"

In ExceptionConverter.php line 45:
                                                                                                                                                   
  [Doctrine\DBAL\Exception\TableExistsException (1050)]                                                                                            
  An exception occurred while executing a query: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'mau_point_groups' already exists  
                                                                                                                                                   

Exception trace:
  at /var/www/html/mautic/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php:45
 Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter->convert() at /var/www/html/mautic/vendor/doctrine/dbal/src/Connection.php:1938
 Doctrine\DBAL\Connection->handleDriverException() at /var/www/html/mautic/vendor/doctrine/dbal/src/Connection.php:1880
 Doctrine\DBAL\Connection->convertExceptionDuringQuery() at /var/www/html/mautic/vendor/doctrine/dbal/src/Connection.php:1105
 Doctrine\DBAL\Connection->executeQuery() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php:273
 Doctrine\Migrations\Version\DbalExecutor->executeResult() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php:150
 Doctrine\Migrations\Version\DbalExecutor->executeMigration() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php:73
 Doctrine\Migrations\Version\DbalExecutor->execute() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php:88
 Doctrine\Migrations\DbalMigrator->executePlan() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php:54
 Doctrine\Migrations\DbalMigrator->executeMigrations() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php:136
 Doctrine\Migrations\DbalMigrator->migrate() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php:157
 Doctrine\Migrations\Tools\Console\Command\ExecuteCommand->execute() at /var/www/html/mautic/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at /var/www/html/mautic/vendor/symfony/console/Application.php:1058
 Symfony\Component\Console\Application->doRunCommand() at /var/www/html/mautic/vendor/symfony/framework-bundle/Console/Application.php:96
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /var/www/html/mautic/vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at /var/www/html/mautic/vendor/symfony/framework-bundle/Console/Application.php:82
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/html/mautic/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at /var/www/html/mautic/bin/console:16

In Exception.php line 28:
                                                                                                    
  [Doctrine\DBAL\Driver\PDO\Exception (1050)]                                                       
  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'mau_point_groups' already exists  
                                                                                                    

Exception trace:
  at /var/www/html/mautic/vendor/doctrine/dbal/src/Driver/PDO/Exception.php:28
 Doctrine\DBAL\Driver\PDO\Exception::new() at /var/www/html/mautic/vendor/doctrine/dbal/src/Driver/PDO/Connection.php:76
 Doctrine\DBAL\Driver\PDO\Connection->query() at /var/www/html/mautic/vendor/doctrine/dbal/src/Connection.php:1100
 Doctrine\DBAL\Connection->executeQuery() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php:273
 Doctrine\Migrations\Version\DbalExecutor->executeResult() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php:150
 Doctrine\Migrations\Version\DbalExecutor->executeMigration() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php:73
 Doctrine\Migrations\Version\DbalExecutor->execute() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php:88
 Doctrine\Migrations\DbalMigrator->executePlan() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php:54
 Doctrine\Migrations\DbalMigrator->executeMigrations() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php:136
 Doctrine\Migrations\DbalMigrator->migrate() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php:157
 Doctrine\Migrations\Tools\Console\Command\ExecuteCommand->execute() at /var/www/html/mautic/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at /var/www/html/mautic/vendor/symfony/console/Application.php:1058
 Symfony\Component\Console\Application->doRunCommand() at /var/www/html/mautic/vendor/symfony/framework-bundle/Console/Application.php:96
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /var/www/html/mautic/vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at /var/www/html/mautic/vendor/symfony/framework-bundle/Console/Application.php:82
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/html/mautic/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at /var/www/html/mautic/bin/console:16

In Connection.php line 71:
                                                                                                    
  [PDOException (42S01)]                                                                            
  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'mau_point_groups' already exists  
                                                                                                    

Exception trace:
  at /var/www/html/mautic/vendor/doctrine/dbal/src/Driver/PDO/Connection.php:71
 PDO->query() at /var/www/html/mautic/vendor/doctrine/dbal/src/Driver/PDO/Connection.php:71
 Doctrine\DBAL\Driver\PDO\Connection->query() at /var/www/html/mautic/vendor/doctrine/dbal/src/Connection.php:1100
 Doctrine\DBAL\Connection->executeQuery() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php:273
 Doctrine\Migrations\Version\DbalExecutor->executeResult() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php:150
 Doctrine\Migrations\Version\DbalExecutor->executeMigration() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php:73
 Doctrine\Migrations\Version\DbalExecutor->execute() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php:88
 Doctrine\Migrations\DbalMigrator->executePlan() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php:54
 Doctrine\Migrations\DbalMigrator->executeMigrations() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php:136
 Doctrine\Migrations\DbalMigrator->migrate() at /var/www/html/mautic/vendor/doctrine/migrations/lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php:157
 Doctrine\Migrations\Tools\Console\Command\ExecuteCommand->execute() at /var/www/html/mautic/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at /var/www/html/mautic/vendor/symfony/console/Application.php:1058
 Symfony\Component\Console\Application->doRunCommand() at /var/www/html/mautic/vendor/symfony/framework-bundle/Console/Application.php:96
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /var/www/html/mautic/vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at /var/www/html/mautic/vendor/symfony/framework-bundle/Console/Application.php:82
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/html/mautic/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at /var/www/html/mautic/bin/console:16

doctrine:migrations:execute [--write-sql [WRITE-SQL]] [--dry-run] [--up] [--down] [--query-time] [--configuration CONFIGURATION] [--em EM] [--conn CONN] [--] <versions>...

@saschafoerster
Copy link

saschafoerster commented Jan 10, 2024

ALTER TABLE mau_point_group_contact_scoreADD CONSTRAINTFK_72243719E7A1254A FOREIGN KEY (contact_id) REFERENCES mau_leads (id) ON DELETE CASCADE

Result:
Query 1 ERROR at Line 1: : Can't create table mautic_base.mau_point_group_contact_score (errno: 150 "Foreign key constraint is incorrectly formed")

@RCheesley RCheesley linked an issue Jan 11, 2024 that may be closed by this pull request
1 task
@mautibot
Copy link

This pull request has been mentioned on Mautic Forums. There might be relevant details there:

https://forum.mautic.org/t/mautic-upgrade-to-4-4-10-5-0-1-breaks/30440/2

@patrykgruszka
Copy link
Member Author

patrykgruszka commented Jan 11, 2024

@saschafoerster I've updated the down procedure, please try the --down and --up again and see if it helps. I think this may be specific to your database, as the previous error was just due to the false negative error during the pre-up checks. The database should be fine in most cases.

@Napsty
Copy link

Napsty commented Jan 12, 2024

LGTM, manually applied patch in app/migrations/Version20230621074925.php and update to 5.0.1 (from 5.0.0-alpha1) worked successfully. Thanks for the fix!

@escopecz escopecz merged commit 5d404f2 into mautic:5.0 Jan 12, 2024
14 checks passed
@mautibot
Copy link

This pull request has been mentioned on Mautic Forums. There might be relevant details there:

https://forum.mautic.org/t/upgrade-from-mautic-4-4-10-5-0-1-problem/30494/4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues or PR's relating to bugs db-migrations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to pass DB migrations: Table 'point_groups' already exists
5 participants