Can I flush Redis without wiping user sessions? - symfony

I recently updated my schema in Symphony 2.7 project with Doctrine, but I was still getting an error. It turned out that I had to run:
app/console redis:flushall
In order for the schema to update accordingly and not be mapped incorrectly.
Is there a way for me to implement schema changes without having to kill user sessions when I run redis:flushall?
It's very inconvenient when deploying code to a production server to have to kill user sessions.
Thanks for your help!

Related

Zenstruck Foundry Bundle | Reset Database does not work with session table

I use Symfony 6.1 , Doctrine, Fixtures, phpunit and Zenstruck Foundry Bundle.
The session is kept in the database.
In a WebTestCase I want to reset the test database and use the ResetDatabase trait for this.
But that doesn't work because the session table isn't deleted with doctrine:schema:drop
As soon as doctrine:schema:create is executed, there is an exception because the session table already exists.
I found out that the session table is on the blacklist and must not be deleted. It also doesn't work with "--full-database".
How do I have to configure the Foundry Bundle or Doctrine to make it work?
Please excuse my bad English
I found this, but unfortunately it doesn't offer a solution.
https://github.com/doctrine/orm/issues/8976
I guess I found the mistake.
Someone created a session entity. :(
This seems to affect the behavior of doctrine:schema:create.

EF Core lock the database during migration

Is it possible lock the database from any other connections when running the migrations through Database.Migrate()?
We have multiple service instances running the same code (on AWS Lambda), and do the migrations on startup. Now we have to manually make sure that only one instance is running when we want to apply some migrations, otherwise they can both try to do it and break things bad.
Is there a database level solution to this?
ef-core 2.1
Not really sure if this is what you are looking for, but if you are willing to add plain SQL to your migration you could set database to single user mode: Read more

Should I clear/warm cache after doctrine migrations?

I would like to know about how symfony2 console commands cache:clear and cache:warmup works in regards to changes in doctrine entities.
I've read this http://blog.whiteoctober.co.uk/2014/02/25/symfony2-cache-warmup-explained/ and this https://stackoverflow.com/a/17787070/779320. There it is stated that symfony2 warm-up generates Doctrine proxies.
Thing is, I frequently have a situation after application deploy using capifony where I must run doctrine migrations. After that I always run cache:clear and cache:warmup.
According to the links above (if I understand correctly), if there is any entity addition/deletion, I should run cache:warmup. But what if there is only entity's fields changes. Should I run both cache:clear and cache:warmup commands necessary to be run or just one? Or, which one is necessary? Or, not at all?
Migrations are responsible for persistence layer only. It has nothing to do with EntityProxies, it only makes Database in sync with Model - that's all.
In production, during deployment, you probably run git pull and composer install, which clears the cache, so migrations shoud run just after that.
Reason - after composer install your new code and Model itself is ready to use new fields/entities, but the Database still falls behind, so migrations keeps it in sync.

Beginner questions on deployment and migrations

I'm working on a Symfony 2-application and I use Doctrine migrations to create the database. Now it is time to deploy my application to the production server, and I need some guidance on how to manage migrations. First, how can I get console access to my live server to run the migration command? If I can´t run migrations, can I import my local database to the new server, or will this break the application´s mapping structure, so it won´t work? I´m sorry if this seems like a silly question, but I really can´t find much information about this. I have searched for it a lot.
Several options:
A terminal connection to your deployment server to run the app/console there
Execute the migration in your local terminal, with env=prod, and with a parameters.yml file that points to your prod database
Export data from your local database, and import it in your remote one
Take care when doing these, and make proper backups to avoid data losses

Symfony 2 Project Receiving [PDOException] General Error: 2050

[PDOException]
SQLSTATE[HY000]: General error: 2050
example:dbextra:install [--drop]
Database is setup properly, pdo is up and running, pdo_mysql is up and running, redis is up and running, elasticsearch is up and running...
If I look in my parameters.ini or I load the page and look under db in Symfony2 it tells me that everything is running fine. But I can't get dbextra:install to work and my app simply will not write to the database even though all the logs are saying that it IS writing to the database.
My app has a user name and password login and the ability to create new users. It correctly loads the forms and allows you to create a new user... but never actually writes that info to the database (even though it's saying it IS writing it to the database.)
Checked all the settings and all the servers are functioning normally (otherwise the app wouldn't run at all.)
The only error message I can get is that one.
Any ideas?
Someone using Ubuntu with Symfony2 will ABSOLUTELY run into this problem. So I thought I´d take a moment to explain the solution.
Symfony2 requires PDO... and it requires MySQL... but you can get pretty damned far without actually having pdo_mysql. If you just have PDO and MySQL installed... your application will probably run... but it will never write to the database.
And if you do a search for PDO_MySQL Ubuntu... you'll find a lot of outdated links to old versions of pdo_mysql that won't function properly with MySQL 5.5.
The solution is to run:
apt-get install php5-mysql
And then just restart apache and that will get rid of the error.

Resources