Issue executing doctrine schema update - symfony

I tried to update my database with the command:
php app/console doctrine:schema:update --force
but I got the error:
"No Metadata classes to process"

I had a similar problem and took me a while until I find out how to clear out the cache: Try this:
php app/console cache:clear --env=prod

Related

Symfony 4 doctrine use cache even in development environment

I am in development mode (APP_ENV=dev in .env), and everytime I change entities and run the 'make:migration' command, it returns me that there is no database changes.
After I run the 'cache:clear' command, it takes the changes into account and makes the migration file.
It's quite annoying. Do you have any idea from where it could come ?
I use the 'symfony server:start' to run the dev server, maybe it comes from here ?
If this is an annotation cache from a bundle that causing the issue, simple cache:clear might not help. Did you try do run doctrine:migration:diff?
You can also try to use --flush with your commands:
php bin/console doctrine:cache:clear-query --env=dev --flush
php bin/console doctrine:cache:clear-result --env=dev --flush
php bin/console doctrine:cache:clear-metadata --env=dev --flush
Update after comments:
What I meant, the complete way you use to deploy the entity changes.
As per Symfony 4, an entity update flow might look like below:
Update your entity class - your php/annotation changes
Clearing ALL Metadata cache entries
php bin/console doctrine:cache:clear-metadata
Generate a migration by comparing your current database to your mapping information.
php bin/console doctrine:migrations:diff
View the status of a set of migrations
php bin/console doctrine:migrations:status
Deploy migration
php bin/console doctrine:migrations:migrate --all-or-nothing
using option --all-or-nothing multiple migrations ran at the same time will be wrapped in a single transaction.
If one migration fails, all migrations will be rolled back.
More about migrations from official source: https://symfony.com/doc/master/bundles/DoctrineMigrationsBundle/index.html
Similar problem explained also here: Update an entity in Symfony 4?
Hope this will help and fix your issue.

Schema:update for test environnement

With Symfony 4.2 and Doctrine, I have two .env files :
.env
DATABASE_URL=mysql://me:password#127.0.0.1:3306/base
.env.test
DATABASE_URL=mysql://me:password#127.0.0.1:3306/base_test
If I do the php bin/console doctrine:schema:update --force command : base is updated. ✓
If I do the php bin/console doctrine:schema:update --force --env=test command : base_test is not updated. ✘ I have this message in my console :
[OK] Nothing to update - your database is already in sync with the current entity metadata.
As from the official documentation you should place APP_ENV=test in the .env.test file and run command like so
APP_ENV=test php bin/console command_name

How to configure sonata user bundle to get the result in the documentation

I want to have the same result in documentation Sonata symfony but look what I have after debugging some error. If u have any idea how to solve these errors please help me:
What is the result after clearing the cache and generating assets?
symfony 2 :
php app/console cache:clear
php app/console assets:install --symlink web
php app/console assetic:dump
symfony 3 :
php bin/console cache:clear
php bin/console assets:install --symlink web

Generating proxies with Doctrine

I have cleared my symfony2 application and now cannot run the application because cannot generate proxies for entities from the command line while a few have actually been generated by default.
I have tried to run the command below which usually did the trick in earlier versions of symfony/ doctrine:
php bin/console doctrine:ensure-production-settings --no-debug --env=prod
But this time I only get the following response:
Query Cache uses a non-persistent cache driver, Doctrine\Common\Cache\ArrayCache.
Anyone know how to solve this?
Try
php bin/console cache:warmup --env=prod --no-debug
How ever the command you are trying
php bin/console doctrine:ensure-production-settings --no-debug --env=prod
is not for generating proxies, but for verifying that Doctrine is properly configured for a production environment.
And to actually to make sure you are ready for production , you need to use one of the cache drivers mentioned here
.

Name conflict in Doctrine after changing database name

Since I changed my main database name in Symfony, I cannot get things to work
as some part of Doctrine (I still haven't found out which) is still stuck with
the old name despite all my updates.
Here are the updates I tried :
Using php bin/console doctrine:database:drop --force followed by
php bin/console doctrine:database:create to try to "restart from scratch"
Destroying app/config/parameters.yml.dist and putting the new database
name in app/config/parameters.yml
Invoking php bin/console cache:clear and php bin/console doctrine:cache:clear-metadata and php bin/console doctrine:cache:clear-query and app/console doctrine:cache:clear-result
What did I forget to update ?
UPDATE : the current answer suggests using php bin/console doctrine:schema:create but does not specify when I should do it. A "restart from scratch" procedure would go something like this :
1. php bin/console doctrine:database:drop --force
2. php bin/console doctrine:database:create
3. php bin/console doctrine:generate:entities MyBundle:MyEntity
4. php bin/console doctrine:schema:update --force
5. php bin/console doctrine:schema:validate
Where should I insert php bin/console doctrine:schema:create in this
sequence ?
Create schema using doctrine:schema:create Check for any errors occuring. You need to establish if there is a configuration error or just sync issue
EDIT:
If you have already code with entites you dont need to run step 3,
just create schema instead. Use phpmyadmin to see what is happening on the database side to establis if database/tables are created. As long as you have correct settings on the both sides eg. user set in databse with create db privillages and same user in config file symfony side all should work correctly.

Resources