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

Fixes #9045 - added reschedule_migrations seed script #2098

Closed
wants to merge 1 commit into from

Conversation

lzap
Copy link
Member

@lzap lzap commented Jan 20, 2015

This fixes the issue, but the drawback is it reschedules the puppetclass
correction after every single seed.

Alternative solution would be to create the anonymous admin if it's not present
directly in the codebase.

if User.anonymous_admin(false) && Puppetclass.count > 0
User.current = User.anonymous_admin
Puppetclass.all.each(&:update_total_hosts)
else
Copy link
Member

Choose a reason for hiding this comment

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

Why not leave a message for the user with puts?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure but it will end up in the Rails log. I think it's kinda useless. Do you happen to know how to display a nice message to the user?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added the puts anyway, won't hurt...

@dLobatog
Copy link
Member

@lzap Rubocop is complaining, after that (and possibly the info message) 👍

@domcleal
Copy link
Contributor

Would it be better to move the code somewhere common (like app/services/) instead of calling migrations from seeds?

@lzap
Copy link
Member Author

lzap commented Jan 26, 2015

Which code? The three lines hack? Do you think it is worth a new service file? I don't think so. There is zero reusability there.

@lzap
Copy link
Member Author

lzap commented Jan 26, 2015

Fixed Rubocop warning.

@domcleal
Copy link
Contributor

I meant the contents of the rake task, but never mind, I thought you were calling that from db:seed, I see what's happening now.

I'm really against merging this chaining of DB migrations from DB seeds. The upgrades that introduced the anonymous admin were back around Foreman 1.5/1.6, and the Puppet classes fix was around 1.7, so to merge this hack that's going to fire on every seed run is really not worth it at this point in time...

@tbrisker
Copy link
Member

@lzap ,
Thank you very much for your efforts!
This PR has been open for a very long time with no activity.
Please indicate if you plan to continue working on it or not; if not, feel free to close it.
If you do not respond either way within a couple of weeks, I will assume this PR is abandoned and will go ahead and close it for you.

@lzap
Copy link
Member Author

lzap commented Mar 23, 2016

This is not outdated. Closing.

@lzap lzap closed this Mar 23, 2016
@lzap lzap deleted the migration-puppet-9045 branch March 23, 2016 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants