Sha256: 0ef9966ac773d5dcb3c7f0dbe0c83e53ed14ef5860421e2a398ae55cebbd49d2

Contents?: true

Size: 1.13 KB

Versions: 16

Compression:

Stored size: 1.13 KB

Contents

class AddLanguageIdToPages < ActiveRecord::Migration
  def self.up
    add_column :pages, :language_id, :integer
    rename_column :pages, :language, :language_code
    rename_column :pages, :language_root_for, :language_root
    # PostgreSQL does not support changing string columns to boolean.
    # We do not have existing Alchemy installations running on postgresql to support anyway,
    # so it's not critical to recreate the column.
    if ActiveRecord::Base.connection_config[:adapter] == "postgresql"
      remove_column :pages, :language_root
      add_column :pages, :language_root, :boolean
    else
      change_column :pages, :language_root, :boolean
      execute("UPDATE pages SET language_root = 1 WHERE language_root IS NOT NULL")
    end
    add_index :pages, :language_id
  end

  def self.down
    remove_index :pages, :language_id
    change_column :pages, :language_root, :string
    rename_column :pages, :language_root, :language_root_for
    execute("UPDATE pages SET language_root_for = 1 WHERE language_root_for IS NOT NULL")
    rename_column :pages, :language_code, :language
    remove_column :pages, :language_id
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
alchemy_cms-2.3.2 db/migrate/20101216151419_add_language_id_to_pages.rb
alchemy_cms-2.2.4 db/migrate/20101216151419_add_language_id_to_pages.rb
alchemy_cms-2.3.1 db/migrate/20101216151419_add_language_id_to_pages.rb
alchemy_cms-2.2.3.2 db/migrate/20101216151419_add_language_id_to_pages.rb
alchemy_cms-2.2.3.1 db/migrate/20101216151419_add_language_id_to_pages.rb
alchemy_cms-2.3.0 db/migrate/20101216151419_add_language_id_to_pages.rb
alchemy_cms-2.3.rc5 db/migrate/20101216151419_add_language_id_to_pages.rb
alchemy_cms-2.2.2 db/migrate/20101216151419_add_language_id_to_pages.rb
alchemy_cms-2.2.1 db/migrate/20101216151419_add_language_id_to_pages.rb
alchemy_cms-2.2.0 db/migrate/20101216151419_add_language_id_to_pages.rb
alchemy_cms-2.2.rc15 db/migrate/20101216151419_add_language_id_to_pages.rb
alchemy_cms-2.2.rc14 db/migrate/20101216151419_add_language_id_to_pages.rb
alchemy_cms-2.2.rc13 db/migrate/20101216151419_add_language_id_to_pages.rb
alchemy_cms-2.2.rc11 db/migrate/20101216151419_add_language_id_to_pages.rb
alchemy_cms-2.2.rc8 db/migrate/20101216151419_add_language_id_to_pages.rb
alchemy_cms-2.2.rc7 db/migrate/20101216151419_add_language_id_to_pages.rb