Skip to content

Instantly share code, notes, and snippets.

@gregoriokusowski
Created September 14, 2011 19:40
Show Gist options
  • Save gregoriokusowski/1217555 to your computer and use it in GitHub Desktop.
Save gregoriokusowski/1217555 to your computer and use it in GitHub Desktop.
A stupid script that may be used a single time to migrate an old data-base to one of those new rails multi-tenancy(scoped) apps. It's not pretty. Not even safe, so watchout =P
%x[ls -R app/models/].split("\n").each do |w|
begin
w[0...-3].camelize.constantize.unscoped.each{ |u| u.update_attribute(:company_id, Company.unscoped.first.id) }
rescue
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment