database - Django south datamigrations not running post saves -
i using django south data-migrations update data in new tables after schema-migrations create new tables. have written post-save methods on existing tables update data on newly created tables. this, using data-migrations , in forward method, saving existing table rows in post-saves, new tables data populated.
however, post saves dont run after running data migrations. 1 way call post-save function directly forward method in datamigrations. south documentations recommends should use orm objects freeze state. in post-save methods, using these models normally. way copy same code in migration way, everytime make changes in post-save method, need update code in datamigration forward method.
what best way achieve this?
migration files python modules. can import code other parts of project hence reusing logic.
that slippery slope because:
lets have migration migrates database state x state y (and backwards). lets migration reuses code foo.py
. after time need change db state state y state z. if again reuse logic foo.py
, can no longer execute first migration on fresh db since logic shared between 2 migrations.
if leave migration code independent, make easier maintain many migrations in long run, though can introduce code duplication.
Comments
Post a Comment