Take the 2-minute tour ×

Database.Persist seems to be index-agnostic. This is okay, I can create my own indices, but generic SQL migration seems to create and drop tables when adding/removing fields. This has the effect of dropping the index as well.

Is there a recommended way to make sure they survive database migrations?

share|improve this question
add comment

1 Answer

Only the SQLite3 backend should be dropping tables, PostgreSQL and MySQL both provide powerful enough ALTER TABLE commands to avoid that. So indices should only be lost for SQLite3. If you're using SQLite3 in production (not really recommended), you have two choices:

  1. Disable automatic migrations and handle the schema yourself.
  2. Add some code after the migrations are run to replace any missing indices.
share|improve this answer
Thank you for the reply. I switched to PostgreSQL, so this issue is resolved. –  Tero Aug 10 '12 at 8:31
add comment

Your Answer


