ruby on rails - Uniqueness with scope in migration -
I'm trying to find a way to get it but I'm not getting any effort, so I think I've been thinking that my attitude is completely wrong, he said, if I want to make the combination of two areas unique, then what should I do in my migration ? Please note that I do not want them to be indexed, just the database field. For example, for the down migration, I I'm not sure that you Please note that I do not want them to be indexed, just the database field. There are additional pieces on the index information that store the database about the column. More importantly, an index is exactly what you need! unique: true on the field, combo?
class CreateSomething & lt; ActiveRecord :: Migration Change Diff change_table: do something | T | T.date: datestamp, cord = & gt; Wrong t.integer: some_number ,: null = & gt; Wrong t.timestamps end end
class CreateSomething & lt; ActiveRecord :: Migration Change Diff change_table: do something | T | T.date: datestamp, cord = & gt; Wrong t.integer: some_number ,: null = & gt; Incorrect t.timestamps end add_index: some, [: datestamp, some_number], unique: right end term
Comments
Post a Comment