Is there a practical way of migrating from identity columns to hilo keys?

前端 未结 5 1180
面向向阳花
面向向阳花 2021-02-01 08:11

I work with a database that depends heavily on identity columns. However as we have now moved all applications over to NHibernate I wanted to look into using HiLo as seems to be

5条回答
  •  一个人的身影
    2021-02-01 08:44

    If this is a question about migrating an existing application to hilos which previously used auto ids, and has old data in it which needs to be migrated... then this would be my best bet (not tried it though! - comments welcome!) :

    • Change your column types ids to bigints
    • find out highest id value currently in any table.
    • Set your 'next-high' value in the hilo source table to a value higher than you found in the IDs

    If course this only addresses issues with the identity column, not anything else in your schema that might need to change if you are moving an app to NHibernate.

提交回复
热议问题