I'm new to migrations, and I'm trying to stick to the automatically generated ones:
$ php app/console doctrine:migrations:diff
$ php app/console doctrine:migrations:migrate
The problem is that this drops my sessions table. What can I do to avoid that?
Another option is simply to tell Doctrine to ignore the table. You can use the schema_filter
option as described in this SO post.
So, if your table is called sessions
, add the following to config.yml (Symfony < 4) or doctrine.yaml (Symfony >=4 ):
doctrine:
dbal:
# standard database config here
schema_filter: ~^(?!sessions)~
We had a large number of tables to ignore, so we took the opposite approach - we told Doctrine to only consider tables which began with a certain prefix, and set up listeners to ensure all our Doctrine-managed tables had a prefix. The use of listeners for table prefixes is documented at http://docs.doctrine-project.org/en/latest/cookbook/sql-table-prefixes.html and there's a SO post about the Symfony side of it here.
I know I am late to this question, but figured i would offer a suggestion.
import the session tables into your entities. even if you don't use it through the interfaces it creates, it will allow Doctrine to keep track of the tables, so that it knows they are ment to be there.
see: http://symfony.com/doc/current/cookbook/doctrine/reverse_engineering.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With