Doctrine outline Create only one set.

How do I tell Symfony to create tables for only one package?

Every time I create a package and run it:

php app/console doctrine:schema:create 

It creates on my current database (specific package) ALL tables from ALL my packages. And I don’t need it.

+4
source share
4 answers

When you create a new package, just use

 app/console doctrine:schema:update 

Because your circuit already exists.

+2
source

Sometimes using php app/console doctrine:schema:update --force does not solve the problem, so you can just comment on other packages from AppKernel.php in $ bundles, and then use php app/console doctrine:schema:update --force It should work.

Remember to uncomment the commented packages.

+2
source

If your packages are mapped to different entity managers, you can (or should) use the -em entity_manager_name argument for the schema update command.

Example:

 app/console doctrine:schema:update --em my_own_entity_manager_name 
+1
source

Suppose you have a Bundle that uses a MySQL database, which is located inside a folder in the src directory, for example:

 src/Folder/BundleFolder/ 

And another Bundle that uses the Postgresql database, which is in your src directory, say:

 src/OtherBundle 

To map the doctrine to a specific entity manager, use this conf in the app / config / config.yml file:

 orm: #auto_mapping: true #default_entity_manager: default entity_managers: default: connection: mysql mappings: FolderBundleFolder : ~ other: connection: pgsql mappings: OtherBundle : ~ 

Then, as user 3580495, use the command:

 php app/console doctrine:schema:create --em=other --dump-sql 

to find out what happens in the postgresql database.

 php app/console doctrine:schema:update --em=default --dump-sql 

will show you the SQL commands that will be executed in the MySQL database.

In the conf conf file, don't forget the comment as follows:

 #auto_mapping: true #default_entity_manager: default 

It also means that when you use this doctrine update command, you will need to refine your entity manager each time, which gives you more control over what you are doing as a whole.

Remember that the -help option is always your friend for symfony commands, and you will also find a lot of information in the docs:

http://symfony.com/doc/current/cookbook/doctrine/multiple_entity_managers.html

+1
source

Source: https://habr.com/ru/post/1394041/


All Articles