K
K
Kristina87872020-06-28 15:18:08
symfony
Kristina8787, 2020-06-28 15:18:08

Why does not add a table to the database after migration?

In symphony, I created entities, difila and migrated them, as a result, tables were created in the database, but for some reason with the last entity it gives such an error, the entity and repository were created, but the table was not.

[notice] Migrating up to DoctrineMigrations\Version20200628105302
[error] Migration DoctrineMigrations\Version20200628093518 failed during Execution. Error: "An exception occurred while executing 'ALTER TABLE comment ADD is_published TINYINT(1) NOT N
ULL':

SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'is_published'"

In AbstractMySQLDriver.php line 65:

  An exception occurred while executing 'ALTER TABLE comment ADD is_published TINYINT(1) NOT NULL':

  SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'is_published'


In PDOConnection.php line 43:

  SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'is_published'


In PDOConnection.php line 41:

  SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'is_published'


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


I did this, created a new Category entity, and then updated the Post entity by adding the category property to it, then entering php bin/console doctrine:migrations:diff, and then php bin/console doctrine:migrations:migrate. As a result, such an error here, changed the data types of the columns indicated in the error to just INT, the error was not corrected.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2020-06-28
@Kristina8787

Error in Version20200628093518 migration
It fails because its instructions describe adding a field that is already in the database...

[error] Migration DoctrineMigrations\Version20200628093518 failed during...

It is not known whether your table is added in the same migration or in the following ones, but this error stops further instructions (including the creation of your table
) which are in the table with marked migrations

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question