Sha256: e36217f3854d4075e073fd9eead8dd497f25ad57cd8c37b490caa2bf4ed2a2c6

Contents?: true

Size: 904 Bytes

Versions: 1

Compression:

Stored size: 904 Bytes

Contents

# This migration comes from pageflow (originally 20140624135425)
class MoveCnameFromAccountToTheming < ActiveRecord::Migration
  def up
    add_column :pageflow_themings, :cname, :string, null: false, default: ''
    add_index :pageflow_themings, :cname

    execute("UPDATE pageflow_themings SET cname = (SELECT cname FROM pageflow_accounts WHERE pageflow_accounts.default_theming_id = pageflow_themings.id LIMIT 1);")

    remove_index :pageflow_accounts, :cname
    remove_column :pageflow_accounts, :cname
  end

  def down
    add_column :pageflow_accounts, :cname, :string, null: false, default: ''
    add_index :pageflow_accounts, :cname

    execute("UPDATE pageflow_accounts SET cname = (SELECT cname FROM pageflow_themings WHERE pageflow_themings.id = pageflow_accounts.default_theming_id);")

    remove_index :pageflow_themings, :cname
    remove_column :pageflow_themings, :cname
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pageflow-sitemap-0.1.0 spec/d/r/db/migrate/20150209101547_move_cname_from_account_to_theming.pageflow.rb