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 #3752 - move data population from migrations into seed script #1065

Closed
wants to merge 1 commit into from

Conversation

domcleal
Copy link
Contributor

This looks more severe than it is I think.

  1. all data removed from migrations, moved into seeds.rb
  2. templates under app/views/unattended/ all rearranged to fit the community-templates layout. All moved into community-templates and refreshed from there.
  3. as such, I removed the unattended controller feature of hardocded names (like "pxe_kickstart_config") and so it now only works with template kinds. The tests + fixtures needed a few updates. I'll update the release notes.
  4. templates were also renamed so they're standardised, spelling mistakes corrected etc.
  5. the spec file runs the db:seed on every installation/upgrade. Installer PR's in, will do a deb one shortly.

I think this is more reliable than the DB migrations. I was beginning to implement improved admin account initialisation and the use of DB migrations was hampering me, as they have to support both upgrades and initial installations - they're quite fragile as a result.

@domcleal
Copy link
Contributor Author

Looks like I've got some tests to fix, but otherwise open for review. Probably won't get to that until next week now.


def up
CONFIG_RENAMES.each do |old,new|
ConfigTemplate.find_by_name(old).try(:update_attributes, :name => new)
Copy link
Member

Choose a reason for hiding this comment

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

I assume that try does not fail when update fails. Nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

update_attributes will simply return false if update fails

@domcleal
Copy link
Contributor Author

domcleal commented Dec 5, 2013

Thanks for the previous review comments, PR's updated for review.

@lzap
Copy link
Member

lzap commented Dec 5, 2013

LGTM Nice work.

@domcleal
Copy link
Contributor Author

domcleal commented Dec 5, 2013

Thanks, rebased so hopefully the tests pass.

@@ -12,7 +12,7 @@ def self.up
updated = []
email = SETTINGS[:administrator] || "root@#{Facter.domain}"
owner = User.find_by_mail email
owner ||= User.find_or_create_by_login(:login => "admin", :admin => true, :firstname => "Admin", :lastname => "User", :mail => email)
owner ||= User.where(:admin => true).first
Copy link
Member

Choose a reason for hiding this comment

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

there is a User.admin scope

Copy link
Member

Choose a reason for hiding this comment

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

nm, i see you re-defined user.

@ohadlevy
Copy link
Member

merged as 0fa5d14 thanks @domcleal !

@ohadlevy ohadlevy closed this Dec 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants