4 ms·
Most of my migrations with Django are column renames, column adds, deletions, etc., which seem to fit nicely with this tool, but there are some cases where I wa
by emptysea 8y ago
Most of my migrations with Django are column renames, column adds, deletions, etc., which seem to fit nicely with this tool, but there are some cases where I want to do some more complex transformation which require running a function using Django's `RunPython()`[0]. For example, combining `firstName` and `lastName` columns into a single `name` column.
How would these changes be accomplished?
[0]: https://docs.djangoproject.com/en/2.1/ref/migration-operations/#django.db.migrations.operations.RunPython https://docs.djangoproject.com/en/2.1/ref/migration-operatio...
- djrobstep 8y agoJust create a migration script that mixes (autogenerated) sql and the python you need.
- paulryanrogers 8y agoI thought that was the point of migrations in Ruby for Rails, PHP for Laravel, etc. Because raw SQL often lacks the tools to express and coordinate the changes.