mozilla / addons

☂ Umbrella repository for Mozilla Addons ✨
Other
127 stars 41 forks source link

[Bug]: Migrations seem not to be applying data to database in during make up #15153

Closed KevinMind closed 2 hours ago

KevinMind commented 2 weeks ago

What happened?

When you run make up we should:

It seems that after runnning make up in various scenarios, migrations are successfully ran but data introduced in migraitons (Licenses, WaffleFlag/Switch) are not in the DB state.

What did you expect to happen?

Any data that is generated during a migration should be present in the database after running make up. No data added via a migration should be removed automatically at any point.

Is there an existing issue for this?

┆Issue is synchronized with this Jira Task

KevinMind commented 2 weeks ago

@diox I wonder if the problem is that we are running migrate 2 times... we run it on initialize and then if data_seed is called we flush and run again... maybe flush doesn't remove the migration table rows and so when we run migrate the second time.. nothing happens.

I think "flush" is not strong enough for us in general seems kind of shaky. but need to investigate further.

diox commented 2 weeks ago

But the schema is already correct when we reach the seed step, so if the migrations table was empty, migrate would try to apply migrations from the beginning, and fail...

Ultimately I think any data migration we have should be added somehow to the initial data seed.

KevinMind commented 1 week ago

@bakulf and I debugged a scneario and it could be the case that when running migration the first time we get the new data and then run "flush" and when we run the migration again it won't be applied because it already has been run.

KevinMind commented 2 days ago

I think we need to replace flush with https://django-extensions.readthedocs.io/en/latest/reset_db.html