Orchard Migration Add_Index to an existing table to make it a unique constraint

大兔子大兔子 提交于 2019-12-24 00:25:05

问题


Looking at Q A migration to add unique constraint to a combination of columns

In my migration file I already have a 'MobileDeviceRecord' table with an 'ActivationCode' which is created in code from a GUID class when a new record is created. I want to ensure the new 'ActivationCode' is unique to the existing 'ActivationCodes' in the table. Do I need to remove the 'ActivationCode' column and re-add it with a constraint or can I use an add_index...Also what is the proper way to use it??

public int UpdateFrom82()
    {
        add_index :MobileDeviceRecord, [:ActivationCode], :unique => true
        return 83;
    }

来源:https://stackoverflow.com/questions/23115558/orchard-migration-add-index-to-an-existing-table-to-make-it-a-unique-constraint

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!