Redo all the migrations on symfony

After I had a bug in php my admin I deleted all the tables from it to solve it.

Now I want to rebuild my database using doctrine migrations (but not the very last migration as it is the one which caused the bug).

How can I make a migration at an previous state?

Edit : by doing the migrate command it recreates my table however everytime I try a new

php bin/console doctrine:migrations:migrate

I get the following error messages :

[notice] Migrating up to DoctrineMigrationsVersion20201124181841
[error] Migration DoctrineMigrationsVersion20201124174448 failed
during Execution. Error: "An exception occurred while executing
‘CREATE TABLE publishers (id INT AUTO_INCREMENT NOT NULL, name
VARCHAR(255) NOT NULL, contact_firstname VARCHAR(255) NOT NULL,
contact_lastname VARCHAR(255) NOT NULL, contact_email VARCHAR(255) NOT
NULL, contact_phonecode VARCHAR(255) NOT NULL, contact_phone
VARCHAR(255) NOT NULL, public_phonecode VARCHAR(255) DEFAULT NULL,
public_phone VARCHAR(255) DEFAULT NULL, public_email VARCHAR(255)
DEFAULT NULL, website VARCHAR(255) DEFAULT NULL, logo VARCHAR(255)
DEFAULT NULL, facebook VARCHAR(255) DEFAULT NULL, twitter VARCHAR(255)
DEFAULT NULL, instagram VARCHAR(255) DEFAULT NULL, address
VARCHAR(255) DEFAULT NULL, city VARCHAR(255) DEFAULT NULL, zip
VARCHAR(255) DEFAULT NULL, country VARCHAR(255) NOT NULL,
company_number VARCHAR(255) NOT NULL, registration_date DATETIME NOT
NULL, modification_date DATETIME DEFAULT NULL, description LONGTEXT
DEFAULT NULL, tagline VARCHAR(255) DEFAULT NULL, slug VARCHAR(255) NOT
NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE
utf8mb4_unicode_ci ENGINE = InnoDB’:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table
‘publishers’ already exists"

In AbstractMySQLDriver.php line 57:

An exception occurred while executing ‘CREATE TABLE publishers (id
INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) N OT NULL,
contact_firstname VARCHAR(255) NOT NULL, contact_lastname VARCHAR(255)
NOT NULL, contact_email VARCHAR(255 ) NOT NULL, contact_phonecode
VARCHAR(255) NOT NULL, contact_phone VARCHAR(255) NOT NULL,
public_phonecode VARCHAR( 255) DEFAULT NULL, public_phone
VARCHAR(255) DEFAULT NULL, public_email VARCHAR(255) DEFAULT NULL,
website VARCHAR( 255) DEFAULT NULL, logo VARCHAR(255) DEFAULT NULL,
facebook VARCHAR(255) DEFAULT NULL, twitter VARCHAR(255) DEFAULT
NULL, instagram VARCHAR(255) DEFAULT NULL, address VARCHAR(255)
DEFAULT NULL, city VARCHAR(255) DEFAULT NULL, zip VARCHAR(255)
DEFAULT NULL, country VARCHAR(255) NOT NULL, company_number
VARCHAR(255) NOT NULL, registration_date D ATETIME NOT NULL,
modification_date DATETIME DEFAULT NULL, description LONGTEXT DEFAULT
NULL, tagline VARCHAR(255) DEFAULT NULL, slug VARCHAR(255) NOT NULL,
PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE
utf8mb4_unicode_c i ENGINE = InnoDB’:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table
‘publishers’ already exists

In Exception.php line 18:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table
‘publishers’ already exists

In PDOConnection.php line 52:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table
‘publishers’ already exists

doctrine:migrations:migrate [–write-sql [WRITE-SQL]] [–dry-run] [–query-time] [–allow-no-migration] [–all-or-nothing
[ALL-OR-NOTHING]] [–configuration CONFIGURATION] [–db-configuration
DB-CONFIGURATION] [-h|–help] [-q|–quiet] [-v|vv|vvv|–verbose] [-V|–version] [–ansi] [–no-ansi] [-n|–no-interaction] [-e|–env
ENV] [–no-debug] [–] []

How can I fix this?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *