I have been wondering about how to write down function in migration file. Ideally, it should be exactly opposite of what we are doing in up method. Now suppose I wrote up function to drop unique constraint on a column, added some new rows(having duplicate data) to a table and now I want to rollback the migration. Ideally, I would write down method to add a unique constraint again on the column but migration would not rollback as a table now contains duplicate data. So my questions are -
- What to do in such a situation?
- How to write
downfunction in migrations? - Can I keep the
downfunction blank in such a situations?
Thanks.
via Harshal Gangurde
No comments:
Post a Comment