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

Upgrade From 2.x to 3.0.0 #329

Closed
tarlepp opened this issue Jun 15, 2020 · 34 comments
Closed

Upgrade From 2.x to 3.0.0 #329

tarlepp opened this issue Jun 15, 2020 · 34 comments

Comments

@tarlepp
Copy link
Contributor

tarlepp commented Jun 15, 2020

Currently UPGRADE.md doesn't mention that ./bin/console doctrine:migrations:sync-metadata-storage command should be executed - is there some reason for this or is the documention just missing this part?

@corlanalexandru
Copy link

For me, it doesn't work to run the command php bin/console doctrine:migrations:sync-metadata-storage

@tarlepp
Copy link
Contributor Author

tarlepp commented Jun 15, 2020

For me, it doesn't work to run the command php bin/console doctrine:migrations:sync-metadata-storage

weird, that did the trick for my application - do you get some error from that command?

@corlanalexandru
Copy link

I updated the configuration file
doctrine_migrations:
migrations_paths:
'DoctrineMigrations': '%kernel.project_dir%/src/Migrations'
storage:
table_storage:
table_name: 'migration_versions'
version_column_name: 'version'
version_column_length: 1024
executed_at_column_name: 'executed_at'

@corlanalexandru
Copy link

But i get the same error to run the sync-metadata-storage

@corlanalexandru
Copy link

Can you share your doctrine_migrations.yaml file?

@tarlepp
Copy link
Contributor Author

tarlepp commented Jun 15, 2020

what is the actual error?

@corlanalexandru
Copy link

The metadata storage is not up to date, please run the sync-meta
data-storage command to fix this issue.

@tarlepp
Copy link
Contributor Author

tarlepp commented Jun 15, 2020

Can you share your doctrine_migrations.yaml file?

sure,

doctrine_migrations:
    migrations_paths:
        'DoctrineMigrations': '%kernel.project_dir%/src/Migrations'
    storage:
        table_storage:
            table_name: 'migration_versions'
            version_column_name: 'version'
            version_column_length: 512
            executed_at_column_name: 'executed_at'

I needed to adjust that version_column_length from 1024 to 512 just because I'm using MySQL 5.7 which have known problem with index sizes.

Also note that you could get more information about that error if you add -vvv option to that command.

@goetas
Copy link
Member

goetas commented Jun 15, 2020

@corlanalexandru do you have some custom type mappings on the datetime type?

@corlanalexandru
Copy link

corlanalexandru commented Jun 15, 2020

I deleted the migration_version table, then i ran php bin/console doctrine:migrations:sync-metadata-storage and when I ran php bin/console doctrine:migrations:migrate i still get the same error

@corlanalexandru
Copy link

New
CREATE TABLE migration_versions(versionvarchar(512) COLLATE utf8_unicode_ci NOT NULL,executed_atdatetime DEFAULT NULL,execution_timeint(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
OLD
CREATE TABLEmigration_versions(versionvarchar(14) COLLATE utf8mb4_unicode_ci NOT NULL,executed_at datetime NOT NULL COMMENT '(DC2Type:datetime_immutable)' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

@goetas
Copy link
Member

goetas commented Jun 15, 2020

can you please answer to #329 (comment) ?

@corlanalexandru
Copy link

can you please answer to #329 (comment) ?

I don't have. All entities were generated from command line with basic types

@goetas
Copy link
Member

goetas commented Jun 15, 2020

@tarlepp the doc does not mention that becase if you run just /bin/console doctrine:migrations:migrate, it should be executed automatically. (for the other commands as show/version` that is not the case)

but maybe adding a note on the upgrading guide will no hurt

@tarlepp
Copy link
Contributor Author

tarlepp commented Jun 15, 2020

@goetas I'm just thinking people who will migrate their current production application to use this - and specially with use case that there isn't new migration file to run.

@goetas
Copy link
Member

goetas commented Jun 15, 2020

@tarlepp who has some CI, and runs bin/console doctrine:migrations:migrate on each deploy, there is nothing to update

@inverse
Copy link

inverse commented Jun 15, 2020

When I just tried this I

  • Modified my configs are per the documentation.
  • Ran the ./bin/console doctrine:migrations:sync-metadata-storage command
  • Then trying to run the migrate command and got
 [ERROR] The version "latest" couldn't be reached, you are at version "DoctrineMigrations\Version20200517201357"        

@goetas
Copy link
Member

goetas commented Jun 15, 2020

@inverse the wording of that message is misleading, but that just means that you are already at the latest version, it will be improved by doctrine/migrations#988

@tarlepp
Copy link
Contributor Author

tarlepp commented Jun 15, 2020

@tarlepp who has some CI, and runs bin/console doctrine:migrations:migrate on each deploy, there is nothing to update

This is something that I didn't know - that I need to run that command. Is there some doc about that?

@inverse
Copy link

inverse commented Jun 15, 2020

Okays - so it's not an error - but considering that it returns non 0 that's quite a breaking issue.

Can confirm also that the sync command is not needed - just verified locally

@goetas
Copy link
Member

goetas commented Jun 15, 2020

there is --allow-no-migration to have it returning 0

@goetas
Copy link
Member

goetas commented Jun 15, 2020

@inverse
Copy link

inverse commented Jun 15, 2020

@goetas the problem is that when you run migrate on 2.x it returns 0 even when there is no migrations to be ran. To me this feels like quite a BC since on CI it'll fail the deployment since the migrations were not deemed success.

malachi@vagrant:/var/www/xxxxx/current$ ./bin/console doctrine:migrations:migrate
                                                              
                    Application Migrations                    
                                                              

WARNING! You are about to execute a database migration that could result in schema changes and data loss. Are you sure you wish to continue? (y/n)yes
No migrations to execute.
malachi@vagrant:/var/www/xxxxx/current$ $?
-bash: 0: command not found

@corlanalexandru
Copy link

image

Any idea ? :D

@tarlepp
Copy link
Contributor Author

tarlepp commented Jun 15, 2020

@corlanalexandru you could add that -vvv option to that command and then share that stacktrace of that, it would help to spot the actual issue here.

@corlanalexandru
Copy link

image

@pawellen
Copy link

I am running this:
php bin/console make:migration
php bin/console doctrine:migrations:sync-metadata-storage
php bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration

I am getting:
obraz

@VincentLanglet
Copy link
Contributor

@goetas the problem is that when you run migrate on 2.x it returns 0 even when there is no migrations to be ran. To me this feels like quite a BC since on CI it'll fail the deployment since the migrations were not deemed success.

I agree.
It took me some time to understand why my deployment wasn't working anymore.

This should be in the upgrade note.

@goetas
Copy link
Member

goetas commented Jun 16, 2020

updated doc in doctrine/migrations#993

@goetas
Copy link
Member

goetas commented Jun 16, 2020

@pawellen can you please check #329 (comment) ?

@pawellen
Copy link

@pawellen can you please check #329 (comment) ?

@goetas I don't have any. Maybe one of those causes problem:
@Orm\Column(type="text", length=4294967292, nullable=true)
@Orm\Table(name="range")

I am not sure if this can help somehow. Those are all my mappings lines: report.txt I don't know what to look for, there is no mention in doc how this new "sync-metadata-storage" command works.

@k00ni
Copy link
Contributor

k00ni commented Jun 16, 2020

Maybe its helpful to someone: If you use orm-pack as a normal dependency it will automatically upgrade DoctrineMigrationsBundle from 2.1.x to 3.0, which might lead to an exception because your configuration became "invalid". My mistake

Ref: symfony/orm-pack#24

@LuigiCardamone
Copy link

Is there any reason why the suggested value for "version_column_length" is 1024?
Like @tarlepp I had to put 512 to avoid this error on MySql:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 3072 bytes

@tarlepp
Copy link
Contributor Author

tarlepp commented Jun 17, 2020

@tarlepp the doc does not mention that becase if you run just /bin/console doctrine:migrations:migrate, it should be executed automatically. (for the other commands as show/version` that is not the case)

but maybe adding a note on the upgrading guide will no hurt

I think we can close this issue, and continue those other problems with separated issues - so it's easier to keep things together.

@tarlepp tarlepp closed this as completed Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants