Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-1925 Support Multiple Databases in OpenMRS Installation and Update
  3. TRUNK-2631

Allow IDENTITY_INSERT for SQL Server when making liquibase insert statements

    XMLWordPrintable

    Details

    • Complexity:
      Medium

      Description

      Since there are IDENTITY columns in many tables, SQL Server prevents manual entry of ids into such columns. SQL Server provides SET IDENTITY_INSERT <tableName> ON for allowing inserting ids. Thus all insert statements done through liquibase needs to be checked and wrapped between:

      SET IDENTITY_INSERT <tableName> ON;
      insert...;
      SET IDENTITY_INSERT <tableName> OFF;
      

      Care should be taken to first check if there is an identity column in the table or else the SET IDENTITY_INSERT fails with exception.
      This can be implemented through extensions in liquibase 2.0

        Attachments

          Activity

            People

            Assignee:
            sunbiz Saptarshi Purkayastha
            Reporter:
            sunbiz Saptarshi Purkayastha
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: