I was running Symfony 4.4.8, and I wanted to update my project. So I ran:
composer update
It did automatically update the DoctrineMigrationsBundle (https://packagist.org/packages/doctrine/doctrine-migrations-bundle) from 2.1.2 to 3.0.1.
Composer failed at first because doctrine_migrations.yaml was not compatible with the DoctrineMigrationsBundle 3.0.1, so I ran:
composer recipes:install --force -v
composer install
But: it appears that the DoctrineMigrationsBundle v 3 has a totally different configuration and does not use the "migrations_versions" SQL table anymore, but a new "doctrine_migrations_versions"-table and a new migrations directory ('%kernel.project_dir%/migrations' instead of '%kernel.project_dir%/src/Migrations').
This means that every time you do:
php bin/console doctrine:migrations:diff
You will get in the migration:
$this->addSql('DROP TABLE migration_versions');
I read at https://symfony.com/doc/master/bundles/DoctrineMigrationsBundle/index.html that you can set the table name in doctrine_migrations.yaml manually like this:
doctrine_migrations:
storage:
table_storage:
'table_name': 'doctrine_migrations'
But that is of no use, because the v 3 table has an extra column "execution_time" and in the "version" column a namespace is prepended (e.g. "DoctrineMigrations\Version20200702112735.php"). So both tables are incompatible.
I can't find any information anywhere on properly upgrading DoctrineMigrationsBundle from v2 to v3.
I must say I am surprised by this, I thought that "composer update" was to be safe. Appearently, one of the symfony bundles didn't add a version limit automatically where it should if an upgrade is not possible.
So what should I do? Should I just let composer downgrade the DoctrineMigrationsBundle again? Or is there some way to get an upgrade of DoctrineMigrationsBundle from v2 to v3 to work after all?
I think everything is explained here: https://github.com/doctrine/migrations/blob/master/UPGRADE.md
If you have already update the bundle config, just run that command:
bin/console doctrine:migrations:sync-metadata-storage
It should work.
Related
I get this message in red box when I try to run php bin/console doctrine:schema:validate or php bin/console doctrine:schema:update -f:
"Feature was deprecated in doctrine/dbal 2.x and is not supported by installed doctrine/dbal:3.x, please see the doctrine/deprecations logs for new alternative approaches."
Symfony 5.3.12
Doctrine 2.7.1-DEV
Any ideas where and what I should search for this message? Thank you!
I guess these commands were deprecated because of the idea that all schema changes should go through migrations and so - be represented in code and be reviewed before execution. The old approach could not guarantee that data wouldn't be lost (as many of schema:update manipulations allowed removing column and creating a new one to rename it without migrating the values).
The better approach to update DB schema is using maker bundle and migration mechanism.
composer require symfony/maker-bundle --dev
composer require doctrine/doctrine-migrations-bundle
bin/cosnole make:migration will generate migration based on differences of schema in code (annotations, xml or yml) and a current DB schema.
bin/console doctrine:migrations:migrate will execute migration.
As a result you will get same thing as by running bin/console doctrine:schema:update -f.
I recently got this error when running bin/console doctrine:migrations:migrate:
The metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue.
However, running the sync-metadata-storage command yields the same error.
What can I do?
As mentioned in this GitHub issue one possible fix is to specify the MySQL server version in the server URL:
DATABASE_URL=mysql://root:#127.0.0.1:3306/test?serverVersion=mariadb-10.4.11
Then, you should be able to run the bin/console sync-metadata-storage command.
Read more about this configuration option in the doctrine documentation:
[…] you can pass the serverVersion option with a vendor specific version string that matches the database server version you are using […]
If you are running a MariaDB database, you should prefix the serverVersion with mariadb- (ex: mariadb-10.2.12).
I had to downgrade the doctrine/doctrine-migrations-bundle to version "^2.1"
Not sure if that applies here, but I had issues with doctrine lately aswell.
I did a composer update and ever since then, my project wouldn't run anymore. My issue was based on a new version of the following bundle:
https://symfony.com/doc/master/bundles/DoctrineMigrationsBundle/index.html
They restructred the doctrine_migrations.yaml file and I still had the old one. I tried to change the contents to the new 3.0 version but that lead exactly to your error.
Since the bundle comes with the package: symfony/orm-pack you first have to unpack the to be able to manually change the version inside your composer.json: composer unpack symfony/orm-pack
After unpacking you will see the following line inside your composer.json: "doctrine/doctrine-migrations-bundle": "*", which I changed to "doctrine/doctrine-migrations-bundle": "^2.1". Then i ran composer update again. You may specify only the migrations bundle if thats all you want to update.
Hello so i could fixe my issue just by removing (?versionname=5.7) to the database_url and it worked just fine
I am trying working with symfony since past couple of months. Last night I did an auto remove to purge not needed repositories. After that I have not been able to create a new symfony project using the symfony command. When I run Symfony new SecurityDemo 2.8.1 in the terminal,
I get the error
Symfony: command not found
I tried installing the Symfony Installer again as directed in the documentation http://symfony.com/doc/current/setup.html. I went to my root directory and followed the installation procedure as shown in the screenshot
Still I get the same error.
All help is appreciated.
EDIT:
I am working with LAMP and am using PHP 5.6.
When I try to update the symfony Installer using symfony self-update I get the output
// Symfony Installer is already updated to the latest version (1.5.8).
Add the following line to your shell configuration file:
export PATH="$HOME/.symfony/bin:$PATH"
For me the fix was to reinstall symfony:
curl -sS https://get.symfony.com/cli/installer | bash
see here https://symfony.com/download
as far as I experienced, it does not tamper with the environment.
If you're sure you installed the symfony command properly you have to call it with lowercase s and not Symfony.
The correct command is:
$ symfony new SecurityDemo 2.8.1
http://symfony.com/doc/current/setup.html#basing-your-project-on-a-specific-symfony-version
Try call Symfony it in lowercase as example:
>symfony new SecurityDemo 2.8.1
Hope this help
I had the same problem. The right command would be:
php symfony new SecurityDemo 2.8.1
Not sure why it would not work without the word php even though the documentation does not prescribe it.
cd your-project/
composer require symfony/web-server-bundle --dev
php bin/console server:start
Working beautifully for me on Fedora 33 Workstation
base: https://symfony.com/doc/4.0/setup/built_in_web_server.html
Turns out that I cannot use capital 'S' in symfony. using symfony new project_name did the trick.
The Right Command is
symfony new SecurityDemo 2.8.1
If you can’t use the Symfony installer for any reason, you can create Symfony applications with Composer, the dependency manager used by modern PHP applications.
composer create-project symfony/framework-standard-edition SecurityDemo "2.8.1"
make sure you've already install composer.
When you run curl -sS https://get.symfony.com/cli/installer | bash to install Symfony CLI Installer. After installation run either of the next commands:
Use it as a local file:
/root/.symfony5/bin/symfony
Or add the following line to your shell configuration file:
export PATH="$HOME/.symfony5/bin:$PATH"
Or install it globally on your system:
mv /root/.symfony5/bin/symfony /usr/local/bin/symfony
Then start a new shell and run 'symfony'
try this
composer require symfony/flex
composer install
I created a new symfony 2 project using 2.7. When I try to install a plugin using command line "symfony plugin:install sfFormExtraPlugin", I got an error:
"[InvalidArgumentException]
There are no commands defined in the "plugin" namespace.".
When I type "symfony list", I got "
Available commands:
about Symfony Installer Help.
demo Creates a demo Symfony project.
help Displays help for a command
list Lists commands
new Creates a new Symfony project.
self-update Update the installer to the latest version.
selfupdate Update the installer to the latest version.
". no plugin or other command like "cache" etc. What should I do? Thanks!
sfFormExtraPlugin is a plugin for Symfony 1 and won’t work with Symfony 2.*
Also, the symfony command line tool in Symfony 2 is not meant for application commands anymore but for creating new projects/installing Symfony. The new command line tool for application commands is app/console (which you use like php app/console something:something.)
But even then, this command isn’t used for managing dependencies (like plugins) anymore. We use composer for that instead. That’s a powerful package manager for PHP that can install and update the packages you require and also make sure that they are compatible. And it is not limited to the Symfony world.
Is there a way that I can mark a Doctrine migration as "ran" or "executed" in the way that it won't be shown as a migration that needs to be migrated?
app/console doctrine:migrations:migrate --add Version20140409203042
I don't see anything in the --help.
The reason for doing this is my DB is up to date and imported from elsewhere, but this migration is asking to be ran every time I run a doctrine:migrations:migrate.
I found that this functionality falls under the version command:
Use this command to add a single version:
Symfony 2/3
app/console doctrine:migrations:version 20140430223207 --add
Symfony 4
bin/console --env=staging doctrine:migrations:version 'Application\Migrations\Version20220803073040' --add
Use this command to add them all:
app/console doctrine:migrations:version --add --all
In your database is table where stored doctrine migrations. You can just add line with version id (20140409203042). Default name of this table is migration_versions, i think, or you can find name in config (http://symfony.com/doc/current/bundles/DoctrineMigrationsBundle/index.html)
It is one possible solutions for doing migrations wihout running it. But you really should control all queries, if it ok. If one, or more are missing, you should do migrations with queries commented out.
In newer versions of doctrine the migration version name contains a namespace (Skipping Migrations)
Now the command may look like this:
bin/console doctrine:migrations:version 'DoctrineMigrations\Version20220407777666' --add