I need to add a FULLTEXT index to one of the areas of my Django model and it needs to be understood that There is no functionality for this and that such an index should be manually added to mysql (our back end db).
I want this index to be created in every environment. I understand that model changes can be introduced with the DEGENGO SOUTH MIGRATION, but is there a way to add such a complete index as part of the migration?
In general, if there is a custom SQL that needs to be run, how can I make it a part of the migration?
Thank you.
You can write anything as a migration. this is the matter!
Once you go to Migration can look something like this: south , type
dragon manage.py schemamigration myapp --empty my_custom_migration to create an empty migration That you can customize. Open
XXXX_my_custom_migration.py file in
myapp / migrations / and type your custom SQL migration into the
forward method For example you can use
class migration: def further (self, or): db .EXecute ("Create FULLTEXT INDEX foo ON bar" foobar "print" just made an integer index ... "print" and calculation {answer} ". Format (answer = 40 + 2) def backwards ( Or,): Increase RuntimeError ("This migration can not be reversed.") # Or you have $ python to manage / migrate myapp XXXX # or just python manage.py migrate. "Just set the integer index. ... "and calculation of 42"
Comments
Post a Comment