-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate db tool and db backup/restore services for version 2.x #398
Conversation
446f9af
to
02e3518
Compare
@alexislefebvre |
There is a conflict since #393 has been merged, sorry. Thanks for the amazing work, it looks really nice! I think that we can drop |
|
||
$executor->getReferenceRepository()->save($this->getBackupName()); | ||
|
||
exec("mysqldump -h $dbHost -u $dbUser -p$dbPass $dbName > {$this->getBackupName()}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the MySQL database is in a Docker container, this command won't work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use docker too, it will works fine if you install mysql-client in container with symfony app :)
I'll resolve conflicts in this weekend |
…ichenkov/LiipFunctionalTestBundle into db_tools_from_2.x # Conflicts: # src/Test/WebTestCase.php
@alexislefebvre done :) |
Can you please explain why you call Otherwise, this PR is really good. @Jean85 @lsmith77 Could you please give your opinion about this PR ? Thanks. |
I use |
I think that the backup is done with the
Here is the method: https://github.com/doctrine/data-fixtures/blob/318df610720a7a7de0add8b27107654877642ac4/lib/Doctrine/Common/DataFixtures/ProxyReferenceRepository.php#L115 There is a reference to LiipFunctionalTestBundle in the documentation of this class: https://github.com/doctrine/data-fixtures/blob/318df610720a7a7de0add8b27107654877642ac4/lib/Doctrine/Common/DataFixtures/ProxyReferenceRepository.php#L115 |
README.md
Outdated
# app/config/config_test.yml | ||
liip_functional_test: | ||
cache_db: | ||
sqlite: liip_functional_test.database_backup.sqllite |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sqlite
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's typo
@@ -31,6 +31,15 @@ public function getConfigTreeBuilder(): TreeBuilder | |||
$rootNode | |||
->children() | |||
->booleanNode('cache_sqlite_db')->defaultFalse()->end() | |||
->arrayNode('cache_db') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we then remove cache_sqlite_db
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'll remove it.
#398 (comment)
$em = $executor->getReferenceRepository()->getManager(); | ||
self::$metadata = $em->getMetadataFactory()->getLoadedMetadata(); | ||
|
||
exec("mysqldump -h $dbHost -u $dbUser -p$dbPass --no-create-db $dbName > {$this->getBackupName()}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexislefebvre @lsmith77
About #398 (comment), it's not suit, this method save only reference data, but I need save database data (sql with inserts data per each table)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed ..
Generally I think if we have to use a CLI command, then its not really a good fit for this Bundle, since it will not be applicable in too many cases.
This library here might help however https://github.com/portphp/doctrine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... I added mysql class just for example
I can use portphp/doctrine
or something else, it will be interesting for me, but I have fears about performance and additional vendor...
Currently I rename service mysql_custom
-> mysql_example
and add attention block from readme
As a proposal, mysql (and other) can be implemented by a separate repo in github, what do you think about it? @alexislefebvre @lsmith77
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About #398 (comment), it's not suit, this method save only reference data, but I need save database data (sql with inserts data per each table)
The method works on the current version of this bundle. I'm sorry but I don't understand why you don't use it in this PR. Could you please explain why you chose to perform a full export instead of using only the reference data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexislefebvre I save reference too
https://github.com/liip/LiipFunctionalTestBundle/pull/398/files#diff-f2e540017ed6e7479f8d4a4b1e17a480R82
But it's not enough, I need backup both, DB and reference.
In case of SQLite, to copy DB enough copy just file, in case of MySql we can't just copy files, need make backup, for make backup I use mysqldump
because Doctrine can't do it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lsmith77 about https://github.com/portphp/doctrine
This lib really cool, but still not suitable, this lib saves only entities, but I need dump full db.
For example, after loading fixtures I can have some additional data, by reason to Doctrine lifecycle methods or DB triggers
I found some PHP libs to make backup like https://github.com/backup-manager/backup-manager or https://github.com/spatie/db-dumper
But they all use mysqldump
too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your explanation, I was confused by the fact that SQLite and MySQL need different ways to perform backups. I understand now. Thanks.
didn't do a detailed code review .. but yes splitting this out is very good and fits our goals from #392 |
update readme fix sqlite typo rename mysql_custom -> mysql_example
It looks like mysql dumps are causing headaches: https://github.com/liip/LiipFunctionalTestBundle/pull/398/files/831b101c3d9f752c5dfa3eb38799e7d5cf260fb2#r169751346 We may merge this PR without the MySQL backup and add it later in another PR? Do you agree @alekseytupichenkov? If it's OK for you, you can finalize this PR, move the changes to another branch and open another PR. |
@alexislefebvre Yeah, it's ok, I'll make new PR soon |
rename method getBackupName -> getBackupFilePath update readme
@alexislefebvre done, also made same in #397 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the amazing work!
92ae157
to
b919a90
Compare
Added separate PRs with database cache services (mysql and mongodb) |
only did a very quick review but looks great! one thing to note in general, we probably should create an UPGRADING.md file to document all the BC breaks and how to migrate existing code to the new version. |
ah .. totally overlooked we already have such a file. thank you for adding .. all good from my side then. |
really awesome work .. and thank you very much for being so receptive on the feedback you got. |
Thanks @alekseytupichenkov for the amazing work and @lsmith77 for the review and merge. 🎉 I published a new release with these changes: https://github.com/liip/LiipFunctionalTestBundle/releases/tag/2.0.0-alpha4 |
This PR cause troubles on some configurations. Please see #423. |
Provide services for backup/restore different database and refactoring code