-
Notifications
You must be signed in to change notification settings - Fork 536
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
Fix data_seed migration data being skipped #22860
Conversation
13d0ce2
to
e7014fe
Compare
5aad855
to
698b4de
Compare
8d183b8
to
6acbd8e
Compare
@@ -98,6 +99,26 @@ def static_check(app_configs, **kwargs): | |||
return errors | |||
|
|||
|
|||
@register(CustomTags.custom_setup) | |||
def db_charset_check(app_configs, **kwargs): |
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.
Not that this is a bad check to have, but I can't tell how it's connected to the issue?
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.
Because we are now using reset_db
we rely on django-extensions to create the Database. This ensures that when that happens, it has the correct charset.
call_command('migrate', '--noinput') | ||
|
||
self.logger.info('Loading initial data...') | ||
call_command('loaddata', 'initial.json') | ||
call_command('import_prod_versions') | ||
call_command('import_licenses') |
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.
Can you link to the pr/issue where we made this command redundant? (I thought Baku's work was still in progress)
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.
@KevinMind this is the patch that added the line, 2 days ago. How is it redundant after 2 days - it's not even be deployed to stage yet?
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.
@bakulf and I discovered the bug in parallel. His patch fixed the issue without needing to wait for my patch. But my patch fixes the underlying issue by making sure that data added during migrations is not erased.
These both are local dev patches that won't impact any prod like environment
Fixes: mozilla/addons#15153
Description
Makes sure if we are going to run
data_seed
in the initialize command that we do not pre migrate the database as this could lead to data being dropped post migration.Additionally, use
reset_db
instead offlush
as this will ensure the entire DB is dropped/created ensuring migrations actually run afterward.Minor cleanup removing redundant uneeded code.
Context
When running
data_seed
there are 2 issues. 1) migrations have already been run byinitialize
this can lead to migrations that should run not being run again after flushing the db 2) flushing the db does not reset migrations so if they already ran, will not run again.This can lead to a scenario where the database migrates data and then removes it, and the second migration does not reintroduce the data.
Testing
Run clean up
Now in a shell run
Expect this output including waffle switches generated during migrations.
You can verify other data created during migrations like
License.objects.count()
should return 26 licenses.Checklist
#ISSUENUM
at the top of your PR to an existing open issue in the mozilla/addons repository.