Sha256: 362e145fc4cb4066c3405f92584ffa90054d9fca6bf00fecf9551365edcc44a6

Contents?: true

Size: 991 Bytes

Versions: 17

Compression:

Stored size: 991 Bytes

Contents

class RenameEnvironments < ActiveRecord::Migration
  RENAMES = {
    "dev" => "staging",
    "master" => "production",
    "PRI" => "Staging",
    "Production" => "Production" }

  class Environment < ActiveRecord::Base; end

  def up
    Environment.all.each do |environment|
      environment.slug = RENAMES[environment.slug] ||
        (raise "Didn't anticipate an environment with the slug \"#{environment.slug}\"")
      environment.name = RENAMES[environment.name] ||
        (raise "Didn't anticipate an environment with the name \"#{environment.name}\"")
      environment.save!
    end
  end

  def down
    Environment.all.each do |environment|
      environment.slug = RENAMES.key(environment.slug) ||
        (raise "Didn't anticipate an environment with the slug \"#{environment.slug}\"")
      environment.name = RENAMES.key(environment.name) ||
        (raise "Didn't anticipate an environment with the name \"#{environment.name}\"")
      environment.save!
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
houston-core-0.8.0.pre db/migrate/20121224212623_rename_environments.rb
houston-core-0.7.0 db/migrate/20121224212623_rename_environments.rb
houston-core-0.7.0.beta4 db/migrate/20121224212623_rename_environments.rb
houston-core-0.7.0.beta3 db/migrate/20121224212623_rename_environments.rb
houston-core-0.7.0.beta2 db/migrate/20121224212623_rename_environments.rb
houston-core-0.7.0.beta db/migrate/20121224212623_rename_environments.rb
houston-core-0.6.3 db/migrate/20121224212623_rename_environments.rb
houston-core-0.6.2 db/migrate/20121224212623_rename_environments.rb
houston-core-0.6.1 db/migrate/20121224212623_rename_environments.rb
houston-core-0.6.0 db/migrate/20121224212623_rename_environments.rb
houston-core-0.5.6 db/migrate/20121224212623_rename_environments.rb
houston-core-0.5.5 db/migrate/20121224212623_rename_environments.rb
houston-core-0.5.4 db/migrate/20121224212623_rename_environments.rb
houston-core-0.5.3 db/migrate/20121224212623_rename_environments.rb
houston-core-0.5.2 db/migrate/20121224212623_rename_environments.rb
houston-core-0.5.1 db/migrate/20121224212623_rename_environments.rb
houston-core-0.5.0 db/migrate/20121224212623_rename_environments.rb