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 #29498 - improve pending_migrations check #7574

Merged
merged 1 commit into from
Jun 19, 2020

Conversation

ezr-ondrej
Copy link
Member

Check plugins migrations instead of core ones (or should we check both?).
More info in the ticket.

lib/tasks/plugins.rake Outdated Show resolved Hide resolved
@theforeman-bot
Copy link
Member

Issues: #29498

@theforeman-bot

This comment has been minimized.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

No more comments from my side. Would be good to get someone who knows Rails to take a look as well.

rescue NameError => e
Foreman::Logging.exception("Failed to register plugin #{name}", e)
nil
Dir.glob(plugin.engine.root + 'db/seeds.d/*.rb') if plugin.engine
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to add a helper in the plugin itself to return this glob? Like plugin.seeds

Copy link
Member Author

Choose a reason for hiding this comment

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

unsure about this one 🤔 we don't need it anywhere else, and there is the same path for foreman few lines above this one. I don't have preference tho, I can abstract it to the plugin if it makes more sense :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with this the way it is

@tbrisker
Copy link
Member

needs rebase

@adamruzicka
Copy link
Contributor

[test foreman]

Copy link
Contributor

@adamruzicka adamruzicka left a comment

Choose a reason for hiding this comment

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

Test failures seem related

end

def migrations_paths
engine.paths['db/migrate'].existent
Copy link
Contributor

Choose a reason for hiding this comment

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

The test failures seem to be related to the fact that engine can be nil, or at least in tests

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, then skipping the check is a valid option, as without engine, the plugin has no migrations. Done that, by early return.

@ezr-ondrej
Copy link
Member Author

🍏

Copy link
Contributor

@adamruzicka adamruzicka left a comment

Choose a reason for hiding this comment

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

Looks good to me

@adamruzicka adamruzicka merged commit 3a5d416 into theforeman:develop Jun 19, 2020
@adamruzicka
Copy link
Contributor

Thank you @ezr-ondrej and everyone involved in the discussion!

@ezr-ondrej ezr-ondrej deleted the 29491 branch June 19, 2020 12:12

pending_migrations = ActiveRecord::Base.connection.migration_context.needs_migration?
@pending_migrations = ActiveRecord::MigrationContext.new(migrations_paths, ActiveRecord::SchemaMigration).needs_migration?
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this caused https://projects.theforeman.org/issues/30821. If a plugin has no migrations but uses permissions, this fails in packaging. I think it should still take the main DB into account, as well as plugins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants