1

I have followed this tutorial and added the PostgreSQL FTS capability to one of the tables of my Django (I'm using 1.8.1) project.

Basically, I have an extra fts_document field in my table my_table of the my_app app.

I'd like to keep the databases up-to-date without having to manually copy and paste commands in PostgreSQL shell on each machine. Unlike the tutorial, I didn't implement the South part, as I got South conflicting with the current implementation and also found out that Django no has a native way to do these migrations.

I wasn't able to find any example code, so I am stuck and need help. I don't post an example code cause I followed the exact structure and steps like in the tutorial.

gevra
  • 737
  • 2
  • 14
  • 26

1 Answers1

1

You can implement the equivalent of the south migrations using the RunSQL operation. Just create an empty migration using manage.py makemigration <app_label> --empty, then add it to the operations in the new migration file:

operations = [
    migrations.RunSQL("CREATE FUNCTION etc.")
]

See the documentation for full details.

knbk
  • 52,111
  • 9
  • 124
  • 122
  • 1
    thanks @knbk! It says *if you are manually creating a column, you should pass in a list containing an AddField operation here so that the autodetector still has an up-to-date state of the model (otherwise, when you next run makemigrations, it won’t see any operation that adds that field and so will try to run it again)* How do I declare the new column to be `tsvector` type? p.s. you have a typo, it's `makemigrations` – gevra Jul 16 '15 at 18:30