Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-3238

database creation data and demo data issue

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Must
    • Resolution: Fixed
    • None
    • None
    • Installation Wizard

    Description

      I am Dileepa Sisila Chandrasekera. I am an undergraduate in Department of Computer Science in Engineering in University of Moratuwa. now i am studing at a final year.

      I like to contribute OPEN Medical Records Projects. But I am a new guy to this OPENmrs system. So first of all I downloaded source code and built it using maven build tool. There were no errors and it was built successfully. Then i put the openmrs.war file to the tomcat webapps directory and run the tomcat server. then i configured installation wizard. i choosed simple installation type and entered mysql server password.

      First 3 tasks were completed successfully. but 4th one was not completed. there was an error

      There was an error while updating the database to the latest. file: liquibase-core-data.xml. Error: Migration failed for change set liquibase-core-data.xml::1226412230538-33::ben (generated): Reason: liquibase.exception.DatabaseException: Error executing SQL INSERT INTO `order_type` (`creator`, `date_created`, `description`, `name`, `order_type_id`, `retired`, `uuid`) VALUES (1, '2008-08-15', 'Order of medications for the patient', 'Drug order', 2, 0, '131168f4-15f5-102d-96e4-000c29c2a5d7'): Duplicate entry '2' for key 'PRIMARY': Caused By: Error executing SQL INSERT INTO `order_type` (`creator`, `date_created`, `description`, `name`, `order_type_id`, `retired`, `uuid`) VALUES (1, '2008-08-15', 'Order of medications for the patient', 'Drug order', 2, 0, '131168f4-15f5-102d-96e4-000c29c2a5d7'): Duplicate entry '2' for key 'PRIMARY': Caused By: Duplicate entry '2' for key 'PRIMARY' See the error log for more details

      So i went to liquibase-core-data.xml file and then i was able to find the error. in this file,

      <changeSet id="20110915-0803" author="sunbiz">
      <insert tableName="order_type">
      <column name="order_type_id" valueNumeric="2"/>
      <column name="name" value="Drug Order"/>
      <column name="description" value="An order for a medication to be given to the patient"/>
      <column name="creator" valueNumeric="1"/>
      <column name="date_created" valueDate="2010-05-12"/>
      <column name="retired" valueBoolean="false"/>
      <column name="date_retired"/>
      <column name="retire_reason"/>
      <column name="uuid" value="131168f4-15f5-102d-96e4-000c29c2a5d7"/>
      </insert>
      </changeSet>

      <changeSet author="ben (generated)" id="1226412230538-33">
      <insert tableName="order_type">
      <column name="order_type_id" valueNumeric="2" />
      <column name="name" value="Drug order" />
      <column name="description" value="Order of medications for the patient" />
      <column name="creator" valueNumeric="1" />
      <column name="date_created" valueDate="2008-08-15" />
      <column name="retired" valueNumeric="0" />
      <column name="uuid" value="131168f4-15f5-102d-96e4-000c29c2a5d7" />
      </insert>
      <insert tableName="order_type">
      <column name="order_type_id" valueNumeric="1" />
      <column name="name" value="Lab test" />
      <column name="description" value="An order by a clinician for a laboratory test" />
      <column name="creator" valueNumeric="1" />
      <column name="date_created" valueDate="2008-08-15" />
      <column name="retired" valueBoolean="false" />
      <column name="uuid" value="AABBCCf4-15f5-102d-96e4-000c29c2aaaa" />
      </insert>
      </changeSet>

      I am bold this error occuring part. column of order_type_id is a primary key. so it should be unique value. two rows has a same value for primary key. this is an error it can't be duplicated. i add 1 and 2 respectively and run it now fixed the error and 4 th step is passed.

      Then another error occurred at the last step.

      There was an error while updating the database to the latest. file: liquibase-update-to-latest.xml. Error: Migration failed for change set liquibase-update-to-latest.xml::20090402-1519-order_type::bwolfe: Reason: liquibase.exception.DatabaseException: Error executing SQL CREATE UNIQUE INDEX `order_type_uuid_index` ON `order_type`(`uuid`): Duplicate entry '131168f4-15f5-102d-96e4-000c29c2a5d7' for key 'order_type_uuid_index': Caused By: Error executing SQL CREATE UNIQUE INDEX `order_type_uuid_index` ON `order_type`(`uuid`): Duplicate entry '131168f4-15f5-102d-96e4-000c29c2a5d7' for key 'order_type_uuid_index': Caused By: Duplicate entry '131168f4-15f5-102d-96e4-000c29c2a5d7' for key 'order_type_uuid_index' Error while trying to update to the latest database version

      then i checked liquibase-update-to-latest.xml file and it has a code for create unique index for uuid in order_type table.

      catalina log says
      Caused by: liquibase.exception.DatabaseException: Error executing SQL CREATE UNIQUE INDEX `order_type_uuid_index` ON `order_type`(`uuid`): Duplicate entry '131168f4-15f5-102d-96e4-000c29c2a5d7' for key 'order_type_uuid_index'

      at liquibase-core-data.xml file, i bolded error occuring line. if uuid is unique index, we can't give same value for two rows. this is the reason for error .

      i change this value and compile and activate server database build and working properly.

      <changeSet id="20110915-0803" author="sunbiz">
      <insert tableName="order_type">
      <column name="order_type_id" valueNumeric="2"/>
      <column name="name" value="Drug Order"/>
      <column name="description" value="An order for a medication to be given to the patient"/>
      <column name="creator" valueNumeric="1"/>
      <column name="date_created" valueDate="2010-05-12"/>
      <column name="retired" valueBoolean="false"/>
      <column name="date_retired"/>
      <column name="retire_reason"/>
      <column name="uuid" value="131168f4-15f5-102d-96e4-000c29c2a5d7"/>
      </insert>
      </changeSet>

      <changeSet author="ben (generated)" id="1226412230538-33">
      <insert tableName="order_type">
      <column name="order_type_id" valueNumeric="2" />
      <column name="name" value="Drug order" />
      <column name="description" value="Order of medications for the patient" />
      <column name="creator" valueNumeric="1" />
      <column name="date_created" valueDate="2008-08-15" />
      <column name="retired" valueNumeric="0" />
      <column name="uuid" value="131168f4-15f5-102d-96e4-000c29c2a5d7" />
      </insert>
      <insert tableName="order_type">
      <column name="order_type_id" valueNumeric="1" />
      <column name="name" value="Lab test" />
      <column name="description" value="An order by a clinician for a laboratory test" />
      <column name="creator" valueNumeric="1" />
      <column name="date_created" valueDate="2008-08-15" />
      <column name="retired" valueBoolean="false" />
      <column name="uuid" value="AABBCCf4-15f5-102d-96e4-000c29c2aaaa" />
      </insert>
      </changeSet>

      So i don't is it a bug or mistake. so i think my work is helpful to work with OPENMRS System.

      Thank you...

      Dileepa Sisila Chandrasekera,
      Department of Computer Science & Engineering
      University of Moratuwa
      Sri Lanka
      dileepasisila@gmail.com
      +94719028959

      Gliffy Diagrams

        Attachments

          1. liquibase-core-data.xml
            98 kB
            Dileepa Chandrasekera

          Issue Links

            Activity

              People

                dileepsisila Dileepa Chandrasekera
                dileepsisila Dileepa Chandrasekera
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: