Wednesday, April 23, 2008

Adding Data Through Migrations

one of the points i am always faced with while adding some migrations, is my need to add some system data as a static group for Administrators or any other.

so simply i create a new migration and add the following

and it simply works fine, until someone later one adds a new column
in another new migration and adds validation on that column in the Model

and here the problem occurs
my old migration throws exception because of validation added on a new column added later in another migration but Model carries code validating it

how to solve these problems?

i suggest not using create at all
but rather use new and set our attributes
then save without validations

No comments: