Skip to content
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

Replay migrations on the created schema before copying data #30643

Merged
merged 3 commits into from
May 31, 2019
Merged

Conversation

VicDeo
Copy link
Member

@VicDeo VicDeo commented Feb 27, 2018

Ref #27075 (comment)
some more fixes:

  • answer 'n' to the 'continue' question was ignored
  • added a new line after progressbar completion. Because this sucks:
oc_account_terms
    0 [>---------------------------]oc_accounts
 1/1 [============================] 100%oc_addressbookchanges

now it looks like this:

oc_account_terms
    0 [>---------------------------]
oc_accounts
 1/1 [============================] 100%
oc_addressbookchanges

@codecov
Copy link

codecov bot commented Feb 27, 2018

Codecov Report

Merging #30643 into master will increase coverage by 0.09%.
The diff coverage is 37.09%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #30643      +/-   ##
============================================
+ Coverage     65.53%   65.63%   +0.09%     
- Complexity    18648    18663      +15     
============================================
  Files          1218     1218              
  Lines         70549    70588      +39     
  Branches       1288     1288              
============================================
+ Hits          46236    46331      +95     
+ Misses        23936    23880      -56     
  Partials        377      377
Flag Coverage Δ Complexity Δ
#javascript 53.69% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 67% <37.09%> (+0.1%) 18663 <37> (+15) ⬆️
Impacted Files Coverage Δ Complexity Δ
core/register_command.php 0% <0%> (ø) 0 <0> (ø) ⬇️
apps/files_external/appinfo/app.php 0% <0%> (ø) 0 <0> (ø) ⬇️
core/Command/Db/ConvertType.php 38.27% <36.69%> (+38.27%) 56 <37> (+15) ⬆️
apps/systemtags/appinfo/app.php 14.28% <75%> (-0.35%) 0 <0> (ø)
lib/private/DB/Connection.php 67.64% <0%> (+1.47%) 49% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5f787f9...8552b8a. Read the comment docs.

@VicDeo VicDeo changed the title Replay migrations after the schema is created and before copying data Replay migrations on the created schema before copying data Feb 28, 2018
@VicDeo VicDeo changed the title Replay migrations on the created schema before copying data [WIP] Replay migrations on the created schema before copying data Feb 28, 2018
@VicDeo
Copy link
Member Author

VicDeo commented Feb 28, 2018

@PVince81 it fixes the conversion but it needs to be polished and covered with tests

@@ -35,7 +35,7 @@
$appContainer = \OC_Mount_Config::$app->getContainer();

$config = \OC::$server->getConfig();
if ($config->getAppValue('core', 'enable_external_storage', 'no') === 'yes') {
if (class_exists('OCA\Files\App') && $config->getAppValue('core', 'enable_external_storage', 'no') === 'yes') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated ? can you submit this as a separate tech debt PR ?

Copy link
Member Author

@VicDeo VicDeo Feb 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PVince81
Related due to a cross-app dependency which is not a subject of this PR. I need to load app to read its migrations.
If files app is not loaded (it doesn't use migrations) - result of loading files_external (using migrations) is 💥

@VicDeo VicDeo self-assigned this Feb 28, 2018
@VicDeo VicDeo force-pushed the fix-27075 branch 6 times, most recently from bb54729 to fb5489b Compare March 5, 2018 21:54
@VicDeo VicDeo changed the title [WIP] Replay migrations on the created schema before copying data Replay migrations on the created schema before copying data Mar 5, 2018
@VicDeo VicDeo force-pushed the fix-27075 branch 2 times, most recently from 5b03d29 to 8ea2f87 Compare March 6, 2018 21:33
$apps = $input->getOption('all-apps') ? \OC_App::getAllApps() : \OC_App::getEnabledApps();
$this->replayMigrations($fromDB, $toDB, 'core');

$apps = $input->getOption('all-apps') ? $this->appManager->getAllApps() : $this->appManager->getInstalledApps();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getAllApps is not what we need here

$sourceMigrationService = new MigrationService($app, $fromDB);
$currentMigration = $sourceMigrationService->getMigration('current');
if ($currentMigration !== '0') {
$targetMigrationService = new MigrationService($app, $toDB);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you not filtering migrations by "SQL" only ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider that some migrations are operating on data, for example making some conversion.

When converting the DB we don't need to re-process the data as it was already processed.

This only works if all migrations work correctly with already converted data and have no side effect.
We should likely make it a requirement that every migration must be "replayable" in a way that it doesn't break if the prerequisite was already been resolved before (ex: already migrated data)

@DeepDiver1975

Copy link
Member Author

@VicDeo VicDeo Mar 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PVince81 target migrations table will not have these migrations if I skip them. As the target DB is a bare structure with no data we need to replay everything on it.
Otherwise these migrations can be reapplied after the data is copied = applied twice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. In any case it seems sensible to make sure that non-schema migrations work correctly when replayed

@PVince81
Copy link
Contributor

PVince81 commented Apr 3, 2018

what's left to do ?

@VicDeo
Copy link
Member Author

VicDeo commented Feb 12, 2019

@PVince81

would this be safe to merge and doesn't affect other code paths?

No, it doesn't affect other code paths.

@PVince81
Copy link
Contributor

PVince81 commented Mar 7, 2019

I'm merging this as it would bring the command in a more usable state, potentially with remaining bugs to uncover. We should advertise this as beta / experimental for now until more testing is done.

@pmaier1 FYI

@PVince81
Copy link
Contributor

PVince81 commented Mar 7, 2019

@VicDeo can you add a note on the CLI help / output that this is currently experimental ?

@TobeStokes
Copy link

I'm trying to follow this and figure out what the status is for the database conversion tool... I have OC 10.0.10.4 installed but unfortunately using SQLite and want to convert to MariaDB. I found out the hard way about the table limit in SQLite last December. Managed to recover and stabilize everything, but really want to get away from SQLite.

Is the DB conversion tool usable in 10.0.10 yet?

@VicDeo
Copy link
Member Author

VicDeo commented Apr 5, 2019

@PVince81

can you add a note on the CLI help / output that this is currently experimental ?

done

@TobeStokes

Is the DB conversion tool usable in 10.0.10 yet?

No, it isn't

core/Command/Db/ConvertType.php Outdated Show resolved Hide resolved
core/Command/Db/ConvertType.php Show resolved Hide resolved
core/Command/Db/ConvertType.php Outdated Show resolved Hide resolved
@VicDeo
Copy link
Member Author

VicDeo commented Apr 5, 2019

@jvillafanez thanks for your efforts but I have no plans to invest more time into this 1 year old PR until it will be planned for the sprint.
Reason: any conceptual change will take too much time for manual testing.

@jvillafanez
Copy link
Member

I think you're using the class as a data holder (for the DB parameters)... not sure if we have time to improve that.

@PVince81
Copy link
Contributor

PVince81 commented Apr 5, 2019

we should at least finish and ship as beta. for that we need a review.
if it turns out that adjusting it takes more time, we can schedule this again.

@pmaier1
Copy link
Contributor

pmaier1 commented May 6, 2019

we should at least finish and ship as beta.

Yes, if you feel confident now, let's include it in the next minor and mention that it's beta / waiting for feedback.

@VicDeo
Copy link
Member Author

VicDeo commented May 13, 2019

@jvillafanez please rereview

@jvillafanez
Copy link
Member

How much time do we have or do we want to invest here? There are several changes we should consider to improve the code quality, but those will take some time.
I haven't checked in depth the possibilities of unittests in the command, but I'm pretty sure it isn't fully covered with just 3 tests, plus the tests aren't isolated: the MDB2SchemaManager and MigrationService classes aren't mocked.

@michaelstingl
Copy link

michaelstingl commented May 23, 2019

@micbar @pmaier1 Change milestone to 10.3 development?

@pmaier1
Copy link
Contributor

pmaier1 commented May 23, 2019

How much time do we have or do we want to invest here?

It should work and not cause issues, of course. Anything else is out-of-scope here right now. If that's satisfied here, let's ship this with the next minor release and let people try and get feedback.

@micbar can you take this into your scope for the next release, please? THX.

Copy link
Member

@jvillafanez jvillafanez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the code works properly.
There are several code changes we should do, but we can't in the allocated time

@VicDeo
Copy link
Member Author

VicDeo commented May 30, 2019

brifly retested and rebased once again

@VicDeo VicDeo merged commit 731b269 into master May 31, 2019
@delete-merged-branch delete-merged-branch bot deleted the fix-27075 branch May 31, 2019 08:31
@VicDeo
Copy link
Member Author

VicDeo commented May 31, 2019

stable10: #35390

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.