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-5338 Add changeset to create or modify conditions table #2662
Conversation
d9394ce
to
8fc2e69
Compare
@paradisekelechi did you actually test this out by running an instance of openmrs, go through the database setup wizard, complete it, check the database to confirm all is changed as expected? |
@dkayiwa However, I do not know about the database setup wizard. Could you share resources with respect to that? |
In the liquibasechangelog table, delete the row with this changeset id. Then restart openmrs and tell me what you get in the browser. |
About that, I did that a lot of times until I no longer have errors on the console. |
How are you dealing with the data migration? Didn't some columns store data in a different format than that of the old table? |
The only tables that changed are |
What I am presently concerned about is adding foreign key constraints after converting an old conditions table to the new one. . . |
|
<comment> | ||
Modify conditions table to match condition object in the core platform if the conditions table already exists in the database | ||
</comment> | ||
<renameColumn columnDataType="int" newColumnName="previous_version" oldColumnName="previous_condition_id" tableName="conditions"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to have these as separate changesets with their respective comments being explicit about what they do e.g Rename tableA.x column to y
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. Done
<renameColumn columnDataType="varchar(255)" newColumnName="clinical_status" oldColumnName="status" tableName="conditions"/> | ||
<renameColumn columnDataType="int" newColumnName="condition_coded" oldColumnName="concept_id" tableName="conditions"/> | ||
|
||
<addColumn tableName="conditions"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also be a separate changeset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. Noted
<addColumn tableName="conditions"> | ||
<column name="condition_coded_name" type="int"/> | ||
</addColumn> | ||
</changeSet> | ||
<changeSet id="20180214-1000" author="Kelechi+iheanyi"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good to change the id when you change the changeset contents so that this doesn't break other developer's working copies or our CI servers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the change
</preConditions> | ||
<comment> | ||
Add condition table | ||
Add conditions table if the table does not exist in the database |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add conditions table should be enough, you don't have to include the precondition in the comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. Noted
63dd931
to
111a5af
Compare
@paradisekelechi have you tried to run a fresh setup of openmrs with these changes? |
@paradisekelechi if you do, you should get this error: https://pastebin.com/QxxXu5h6 |
@dkayiwa |
Do you have the reference application modules loaded? |
Yes I do have the reference application modules loaded |
That does not look like a fresh setup. For the emrapi module would attempt to create a conditions table which should fail because the core platform already created it. |
@dkayiwa
|
|
@dkayiwa |
What exactly did you do? Can you list the steps here? |
|
As you did that, which version of openmrs-core were you running? |
2.2.0-SNAPSHOT |
And when you run the setup, did you have all the reference application modules loaded from the very start? |
No I did not have them |
@paradisekelechi can you do that? |
@dkayiwa I can do that. I am on it now |
I have added the reference modules |
Now do a fresh setup with those modules installed |
111a5af
to
d08f28c
Compare
Are you still working on this @paradisekelechi ? |
1 similar comment
Are you still working on this @paradisekelechi ? |
I have worked on this. I am waiting for verifications and updates from @dkayiwa |
</preConditions> | ||
<comment> | ||
Add condition table | ||
Rename conditions table to emrapi_conditions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you renaming the table? I thought you should be updating it to match the new design
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wluyima
We are renaming the table because of some edge cases we saw in the implementation.
Assume we are running a fresh instance of the core platform and the emrapi module.
If we update the conditions
table here, the emrapi module tries to create a new conditions
table which throws errors.
However, the following implementation handles that edge case successfully. On the core platform, the conditions table is renamed to emrapi_conditions. Then a conditions table is created and data migrated to it. On the emrapi module, the emrapi_conditions table is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should not be renaming the table, in any case it's no longer going to live in the emrapi module so there if no need to add that prefix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the table exists just do the migration otherwise create it and the name should be and remain conditions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wluyima , wat do u mean if the table exists , just do the migration ..? i think that will be just do the modification. because migration is posiible only after first renaming it.
I have thoroughly tested this @dkayiwa |
Hi @paradisekelechi |
openmrs#2662)" This reverts commit 93f3286.
openmrs#2662)" This reverts commit 93f3286.
Description of what I changed
Added liquibase changeset to add a new conditions table or modify an existing one.
Issue I worked on
see https://issues.openmrs.org/browse/TRUNK-5338
Checklist: I completed these to help reviewers :)
My pull request only contains ONE single commit
(the number above, next to the 'Commits' tab is 1).
No? -> read here on how to squash multiple commits into one
My IDE is configured to follow the code style of this project.
No? Unsure? -> configure your IDE, format the code and add the changes with
git add . && git commit --amend
I have added tests to cover my changes. (If you refactored
existing code that was well tested you do not have to add tests)
No? -> write tests and add them to this commit
git add . && git commit --amend
I ran
mvn clean package
right before creating this pull request andadded all formatting changes to my commit.
No? -> execute above command
All new and existing tests passed.
No? -> figure out why and add the fix to your commit. It is your responsibility to make sure your code works.
My pull request is based on the latest changes of the master branch.
No? Unsure? -> execute command
git pull --rebase upstream master