Reputation: 7017
I have an old Django project which has been poorly maintained with a lot of functionality which is not needed anymore. There is a function called create_account
which is no longer needed, but it's used in an old migration file.
Since it's bad practice to modify or remove old migration files, I wonder what would happen if I were to remove the use of that function and then remove the function itself. Could it cause problems in production or when a new developer joins the project and runs migrate
to initialize their database?
Upvotes: 0
Views: 488
Reputation: 77952
Just move the function to the migration that uses it.
Modifying old migrations is only an issue if they are still needed, that is if there are (non-disposable) projects instances that still haven't been migrated, and even then only if the modification impacts the result of the migration. Just moving a function from one module to the migration itself is idempotent as far as the migration is concerned - it will work just the same.
Upvotes: 4