Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRUNK-3638 Separate liquibase file into separate files per version #1841

Merged
merged 1 commit into from Nov 14, 2016

Conversation

WolfSchlegel
Copy link
Contributor

Description

This pull request implements most of your feedback on #1804.

The following feedback still needs to be resolved:

"To me it seems that all those changes happened in 2.0 and not 2.1. It's what the pull request title suggests (I may be wrong here so please reassure me). Since 2.0 has been released in beta already we cannot move those changesets out of liquibase-update-to-latest.xml. This file should really contain only changesets introduced in 2.1 (probably none at the moment). ... Actually let me answer myself. They happened in 1.12.x and have been released in 1.12.0. It means we cannot move them out of liquibase-update-to-latest.xml and this file should be empty initially."

Could you please provide some guidance which changes to put into which liquibase files?

Related Issue

see https://issues.openmrs.org/browse/TRUNK-3638

Checklist:

  • My pull request only contains one single commit.
  • My pull request is based on the latest master branch
    git pull --rebase upstream master.
  • I ran mvn clean package right before creating this pull request and
    added all formatting changes to my commit.
  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

…to liquibase-update-2.1.xml

@mention-bot
Copy link

@WolfSchlegel, thanks for your PR! By analyzing the annotation information on this pull request, we identified @bmamlin, @wluyima and @suniala to be potential reviewers

@dkayiwa
Copy link
Member

dkayiwa commented Sep 22, 2016

@WolfSchlegel since you opened this new pull request, should we close the other one? #1804

@WolfSchlegel
Copy link
Contributor Author

Yes, this pull request supersedes #1804.

@dkayiwa
Copy link
Member

dkayiwa commented Sep 27, 2016

@WolfSchlegel because all the 2.1 changes, so far, are also in 2.0, you are correct to say that for now, liquibase-update-2.1.xml will be empty. So yes none is moving out of liquibase-update-to-latest.xml
Therefore, create liquibase-master.xml and in it, reference these two files.
Is this enough for you to finish this up? :)

I also somehow think that we need to do something about liquibase-schema-only.xml along the same lines as we are doing for liquibase-update-to-latest.xml

@@ -58,7 +58,7 @@
/**
* This class uses Liquibase to update the database. <br>
* <br>
* See /metadata/model/liquibase-update-to-latest.xml for the changes. This class will also run
* See /metadata/model/liquibase-master.xml for the changes. This class will also run
Copy link
Member

@dkayiwa dkayiwa Sep 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The folder containing this is no longer metadata/model :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

<include file="liquibase-update-2.1.xml"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this order be reversed? What is the order of execution of the files listed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite right, given that the liquibase-update-2.1.xml file is currently empty. I renamed the files to

  • liquibase-update-baseline.xml - contains the historic baseline
  • liquibase-update-to-latest.xml - starts as an empty file. At some point in time you would close the baseline and add any changes either to this file or to another file referring to a particular version.

Please let me know if that makes sense.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 55.13% when pulling 29882a5 on WolfSchlegel:TRUNK-3638-B into 1f3727b on openmrs:master.

@WolfSchlegel
Copy link
Contributor Author

Regarding liquibase-schema-only.xml, please let me know your requirements. Would it be the same exercise, i.e. introduce a master file that includes multiple files?

<?xml version="1.0" encoding="UTF-8"?>
<!--

This Source Code Form is subject to the terms of the Mozilla Public License,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file name correct? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends, please have a look at my other comment on renaming files.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WolfSchlegel i looked at the comments but i still do not yet understand the need to have "update" twice in the file name. :)

@@ -68,7 +68,7 @@

private static final Log log = LogFactory.getLog(DatabaseUpdater.class);

private static final String CHANGE_LOG_FILE = "liquibase-update-to-latest.xml";
private static final String CHANGE_LOG_FILE = "liquibase-master.xml";
Copy link
Member

@wluyima wluyima Oct 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is really still an update file, it would be nice for it to contain the word update,
how about liquibase-update-to-latest-master.xml? I'll update the ticket

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the ticket description, we don't need to rename the liquibase-update-to-lastest.xml fie

http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

<include file="liquibase-update-baseline.xml"/>
<include file="liquibase-update-to-latest.xml"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought this was renamed

xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

<include file="liquibase-update-baseline.xml"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're doing this in 2.1, this should be probably named liquibase-update-2.0.xml

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 55.407% when pulling 111d8a7 on WolfSchlegel:TRUNK-3638-B into 1f3727b on openmrs:master.

@dkayiwa
Copy link
Member

dkayiwa commented Oct 28, 2016

@WolfSchlegel did you pull the latest upstream changes before making another commit for this? :)

@WolfSchlegel
Copy link
Contributor Author

  • The files containing change sets have been renamed
  • liquibase-update-to-2.0.xml contains the bulk of the changes that were previously in liquibase-update-to-latest.xml
  • liquibase-update-to-2.1.xml contains a single changeset

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 55.635% when pulling a34a020 on WolfSchlegel:TRUNK-3638-B into 17c22ce on openmrs:master.

@dkayiwa
Copy link
Member

dkayiwa commented Nov 14, 2016

@WolfSchlegel i tried testing your changes by doing a fresh openmrs setup but got the error message below:

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-2.0.xml::20090225-1551::dthomas: Reason: liquibase.exception.DatabaseException: Error executing SQL ALTER TABLE location_tag CHANGE retired_reason retire_reason varchar(255): Unknown column 'retired_reason' in 'location_tag': Caused By: Error executing SQL ALTER TABLE location_tag CHANGE retired_reason retire_reason varchar(255): Unknown column 'retired_reason' in 'location_tag': Caused By: Unknown column 'retired_reason' in 'location_tag' Error while trying to update to the latest database version

Does it work on your side?

@dkayiwa
Copy link
Member

dkayiwa commented Nov 14, 2016

Since your changes look obviously correct, i tried to look into the cause of this failure. I discovered that the changeset id is inserted in liquibase-schema-only.sql and hence is supposed to be marked as run. This was not the case and i found out that it's because liquibase does not use the changeset id alone to skip a changeset, but also the name of the file in which the changeset belongs. So this https://github.com/openmrs/openmrs-core/blob/master/api/src/main/resources/liquibase-schema-only.xml#L3455 needs to be changed to the name of the file where the changeset currently resides, and that is, liquibase-update-to-2.0.xml

@dkayiwa dkayiwa merged commit 9a05f6c into openmrs:master Nov 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants