Skip to content

OBPIH-6327 Data model should support "to pick" and "picked" stages#4612

Merged
awalkowiak merged 3 commits intofeature/upgrade-to-grails-3.3.10from
OBPIH-6327-3
May 8, 2024
Merged

OBPIH-6327 Data model should support "to pick" and "picked" stages#4612
awalkowiak merged 3 commits intofeature/upgrade-to-grails-3.3.10from
OBPIH-6327-3

Conversation

@alannadolny
Copy link
Collaborator

No description provided.

Copy link
Collaborator

@awalkowiak awalkowiak left a comment

Choose a reason for hiding this comment

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

You changed the database column name, but you forgot to change the name of it in the domain also


changeSet(author: "anadolny", id: "080520241110-0", objectQuotingStrategy: "LEGACY") {
preConditions(onError: "HALT", onFail: "MARK_RAN", onSqlOutput: "IGNORE") {
columnExists(columnName: "picker_id", tableName: "picklist_item")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would add also a precondition to check that picked_by_id does not exist.

}

renameColumn(
newColumnName: "pickedBy_id",
Copy link
Collaborator

Choose a reason for hiding this comment

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

picked_by_id

changeSet(author: "anadolny", id: "080520241110-2", objectQuotingStrategy: "LEGACY") {
preConditions(onError: "HALT", onFail: "MARK_RAN", onSqlOutput: "IGNORE") {
not {
foreignKeyConstraintExists(foreignKeyName: "fk_picklist_item_pickedBy_id_person")
Copy link
Collaborator

Choose a reason for hiding this comment

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

fk_picklist_item_picked_by_id_person

@alannadolny alannadolny requested a review from awalkowiak May 8, 2024 10:51
@awalkowiak awalkowiak merged commit 0d6dca2 into feature/upgrade-to-grails-3.3.10 May 8, 2024
@awalkowiak awalkowiak deleted the OBPIH-6327-3 branch May 8, 2024 12:33
Copy link
Member

@jmiranda jmiranda left a comment

Choose a reason for hiding this comment

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

Apologies for the confusion on this. I didn't realize you guys were going to take my comment and run with it. We should discuss this on Monday's tech huddle if there are ideas or questions on how to proceed.

}
}

renameColumn(
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I didn't get a chance to review this until today.

The rename column feature might be a bad idea as it probably isn't supported by all versions of MySQL/MariaDB causing potential community support issue. In fact, I've encountered issues with MySQL 5.7 where the rename doesn't work if there's a foreign key on the column. Which is exactly what we have here.

Fwiw, I was not actually expecting you to go through with the change based on my second thoughts. So apologies for creating more work. A day after I made that comment about picker -> pickedBy, I realized that either or both columns could exist alone or together.

Picker vs picked by represents different users at different points in the pick task state machine. A picker generally represents the original person assigned to the pick task and pickedBy could be assigned the same value when the pick task is completed. But there's also a use case where the two values are different in the case of some other user taking over the task and doing it themselves. In either case, picker or pickedBy would be fine. But I did realize that picker alone or with pickedBy does make sense.

So we have a few options here:

  1. Leave it as-is
    a. Deal with bugs and community support if/when they surface
  2. Use both picker_id and picked_by_id
    a. Remove the rename column changeset in favor of adding both columns.
    a. Create a new changeset for adding picked_by_id, so we have both.
    a. Manually remove the invalid changelog executions from dev servers (OBDEV3)
  3. Use just picker_id as originally designed
    a. Remove the rename column changeset to leave just the picker_id column.

cc @alannadolny @awalkowiak

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jmiranda as it was discussed on the tech huddle channel, if this is related to MySQL 5.6, let's leave it as is. However, if we'd like to be safe here, there might be a 4th option (easier than 2nd and 3rd) - we could move out the drop foreign key changeset to a separate changelog file and run it before this rename (to be sure it will be run first).

)
}

changeSet(author: "anadolny", id: "080520241110-1", objectQuotingStrategy: "LEGACY") {
Copy link
Member

Choose a reason for hiding this comment

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

@alannadolny Can you explain what objectQuotingStrategy does and why we should use it? This would be good to add to database migration guide.

@awalkowiak I could have sworn you wrote a best practices guide for generating changelogs using Liquibase / Database Migration plugin, but I cannot find it anywhere.

This might be the ticket which looks like it's still in-progress.
https://pihemr.atlassian.net/browse/OBGM-90

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I used the dbm-changelog-to-groovy command to create a groovy changelog from XML changelog. This is the exact output from this command, so all of the options are probably defaults from XMLs.
objectQuotingStrategy:
image

onSqlOutput:
image
image

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jmiranda I was working on a guide for generating changelogs using Liquibase / Database Migration plugin in one of other tickets, or rather I had to try to do it automatically and document the process around it (scope of OBGM-90 as a part of the OBPIH-6114). However, I ran into some issues, and it was not working as smooth as expected, and I decided to unblock the OBPIH ticket and I dropped this scope from the feature ticket and move it to the OBGM-90. I think I marked it as in progress, because I wanted to add some more thoughts and comments in there and the ticket itself got lost in the backlog

}

changeSet(author: "anadolny", id: "080520241110-1", objectQuotingStrategy: "LEGACY") {
preConditions(onError: "HALT", onFail: "MARK_RAN", onSqlOutput: "IGNORE") {
Copy link
Member

Choose a reason for hiding this comment

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

Same question for onSqlOutput.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants