-
Notifications
You must be signed in to change notification settings - Fork 125
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
Create migrations to add resource_type row #302
Create migrations to add resource_type row #302
Conversation
29bfbe0
to
a061d31
Compare
@juliancheal how hard is it to get all the callers to use the new column? If we merge this, they'll be looking for
Thoughts? |
Is a great idea. Apart from tests for this PR and adding that above line, I think in the core and ui repos i've removed all the callers (that i know of) to This sounds like a good way to proceed. |
@juliancheal just remind people on the PRs, the order of the PRs and why you're doing it in that order. It's an abnormal procedure so forgetful me or others might question it. |
Created an issue to list the order ManageIQ/manageiq#18222 |
a81d116
to
2b9aca7
Compare
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 only have a few minor comments. 🇺🇸
|
||
def up | ||
say_with_time("Moving MiqPolicy towhat to resource type") do | ||
MiqPolicy.all.each do |policy| |
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 dont think there's too many, but maybe we want find_each
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.
or eventually one sql query MiqPolicy.update_all('resource_type = resource_type')
say_with_time("Moving MiqPolicy towhat to resource type") do | ||
MiqPolicy.all.each do |policy| | ||
policy.resource_type = policy.towhat | ||
policy.save |
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.
policy.update(:resource_type => policy.towhat)
say_with_time("Moving MiqPolicy resource type to towhat") do | ||
MiqPolicy.all.each do |policy| | ||
policy.towhat = policy.resource_type | ||
policy.save |
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.
same as above
say_with_time("Moving Condition towhat to resource type") do | ||
Condition.all.each do |condition| | ||
condition.resource_type = condition.towhat | ||
condition.save |
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.
same as above
say_with_time("Moving Condition resource type to towhat") do | ||
Condition.all.each do |condition| | ||
condition.towhat = condition.resource_type | ||
condition.save |
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.
ditto
|
||
migrate | ||
|
||
expect(miq_policy.reload).to eq(:resource_type => "ContainerImage") |
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.
expect(miq_policy.reload.resource_type).to eq("ContainerImage")
|
||
migrate | ||
|
||
expect(miq_policy.reload).to eq(:resource_type => "ContainerImage") |
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.
same as above
|
||
migrate | ||
|
||
expect(condition.reload).to eq(:resource_type => "ContainerImage") |
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.
same
|
||
migrate | ||
|
||
expect(condition.reload).to eq(:resource_type => "ContainerImage") |
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.
same
9616d6a
to
fd8b0bf
Compare
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.
LGTM.
@@ -0,0 +1,21 @@ | |||
class MigrateMiqPolicyTowhatToResourceType < ActiveRecord::Migration[5.0] | |||
class MiqPolicy < ActiveRecord::Base | |||
self.inheritance_column = :_type_disabled |
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 is not needed for MiqPolicy
as there is no MiqPolicy#type
column, see: #4 (comment)
@@ -0,0 +1,21 @@ | |||
class MigrateConditionsTowHatToResourceType < ActiveRecord::Migration[5.0] | |||
class Condition < ActiveRecord::Base | |||
self.inheritance_column = :_type_disabled |
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.
same here , it is not needed #4 (comment)
LGTM and I had also some minor comments 🇨🇿 😄 |
Adds new row Migrates existing data to the new row
fd8b0bf
to
ae1f208
Compare
@jrafanie seeing as you're off next week, shall we put a pin in this until you return? |
LGTM, I can't merge here but it looks good. @juliancheal you can work with @bdunne or @carbonin, I believe if they're good with the approach, it will be fine to do while I'm away. |
Checked commit juliancheal@ae1f208 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
Migration of data already happend in PR ManageIQ#302
@miq-bot add_label technical debt |
Any reason not to |
The only reason is that we can't rename the column and change the caller code in core and ui-classic all in one PR. The core and ui-classic PRs depend on the |
The idea was to:
|
My concerns about doing it the proposed way are:
|
The intent is to create the column, leave it unused, get the 3 co-dependent PRs to use/migrate to the new column merged together, then drop the column. I'm not sure how to do rename column with two other repos needing to use the new or old column based on the schema version. How do you suggest we do that? The core and ui-classic PRs can't become green until the column is renamed so you can't time them to use the correct column until they're green and merged. |
Closing in favour of #312 |
Adds new row
Migrates existing data to the new row
This PR needs to be merged in order see issue for ordering ManageIQ/manageiq#18222