-
-
Notifications
You must be signed in to change notification settings - Fork 391
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
migrations:dump-schema loses information #820
Comments
I can confirm that. Workaround is to call: |
By the way, I understand that |
This is a bug. I should be able to fix it in the next bug fix release. |
Just noticed this myself, ran a migrations rollup a couple of days ago and I noticed today that there are no foreign keys defined anymore. If this bug is a bit more complex to resolve I would suggest a warning message to the rollup command and reference this issue in the meantime. |
I agree (my current workaround is to temporarily switch to an empty DB and run |
Same issue here. Any information about a fix release date ? |
See #981 for a simple proposition leveraging the |
Hello. Any feedback about this case :)? Missing foreign keys in migration files seems to be quite a large issue in here. |
This has been fixed in 2.3.0, use |
Still have this problem today on doctrine/migrations (v3.1.2) |
Faced this today with That's rather confusing that I do agree with @jazithedev, it seems like a rather big issue to dump a database schema without foreign keys. Is there a reason to keep the current behavior of (see related issue #1163) |
Bug Report
Refs #689
Summary
The migration generated for the dumped schema is not complete.
Current behavior
The
migrations:dump-schema
command does not handle existing foreign keys, as opposed to themigrations:diff
command.How to reproduce
PHP 7.2, MySQL 5.7
Run
composer create-project symfony/website-skeleton myapp && cd myapp
=> relevant packages installed:
Copy file .env to .env.local and configure the
DATABASE_URL
environment variable (mysql://db_user:db_password@127.0.0.1:3306/db_name
)Run
php bin/console doctrine:database:create
Create two entity files, with an association:
src/Entity/Foo.php:
src/Entity/Bar.php:
Run
php bin/console cache:clear && php bin/console doctrine:migrations:diff
=> generated file (src/Migrations/Version20190511090651.php):
=> correct (notably, the SQL queries in the up() function are the same as output of
php bin/console doctrine:schema:update --dump-sql
[orphp bin/console doctrine:schema:create --dump-sql
here with empty DB])Run
php bin/console doctrine:migrations:migrate --no-interaction
Now that the database schema is in sync with the mapping files (which can be checked with
php bin/console doctrine:schema:validate
),run
rm src/Migrations/* && php bin/console doctrine:migrations:dump-schema
=> generated file (src/Migrations/Version20190511091302.php):
=> problems:
DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci
and columCOLLATE utf8mb4_unicode_ci
instead of tableDEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
(and column implicitly using table options)Expected behavior
Executing
migrations:dump-schema
with an up-to-date DB should generate the same code as executingmigrations:diff
with an empty DB.The text was updated successfully, but these errors were encountered: