Please read for an updated status on RailsCasts:
Learn more or hide this
GitHub User: omarqureshi
The example I have is something like:
I re-use the same function for inserts that i do for updates and just call it differently inside the trigger. The only real bit of duplication is the refresh function - which i have for existing content only.
you shouldn't need pg_restore
psql has a -f switch that takes a file as an argument
As an aside, a tend to create a tsv column for any models that I'm going to be having a full text search on and using before update / insert triggers for maintenance.
This way, the expense of the to_tsvector happens only on writes and I don't need to have multiple indexes, just the one index on the whole vector.
Obviously this is not the solution for a volatile schema as you'll need to recreate the triggers and recreate the tsv column if you want to search for more things, but one where the schema and search is fairly stable its ideal.