Sha256: 00b39173d66f35218a576350835ad9f752d1067a4c54730c8f70f8c90bb2f3cf

Contents?: true

Size: 1.11 KB

Versions: 40

Compression:

Stored size: 1.11 KB

Contents

class CreateThemingsForExistingAccounts < ActiveRecord::Migration
  def up
    # For each account create a theming. Copy link attributes from
    # theme to theming. Store account_id on theming so we can identify
    # it as the accounts default_theming later on.
    execute(<<-SQL)
      INSERT INTO pageflow_themings
        (account_id, theme_id, imprint_link_label, imprint_link_url, copyright_link_label, copyright_link_url, created_at, updated_at)
        SELECT a.id, default_theme_id, imprint_link_label, imprint_link_url, copyright_link_label, copyright_link_url, a.created_at, a.updated_at
          FROM pageflow_accounts AS a
          LEFT JOIN pageflow_themes AS t ON t.id = a.default_theme_id;
    SQL
  end

  def down
    # Copy link attributes back to themes.
    execute(<<-SQL)
      UPDATE pageflow_themes AS t
        LEFT JOIN pageflow_themings AS g ON g.theme_id = t.id
        SET t.imprint_link_label = g.imprint_link_label,
            t.imprint_link_url = g.imprint_link_url,
            t.copyright_link_label = g.copyright_link_label,
            t.copyright_link_url = g.copyright_link_url
    SQL
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
pageflow-12.6.0 db/migrate/20140624135421_create_themings_for_existing_accounts.rb
pageflow-12.5.0 db/migrate/20140624135421_create_themings_for_existing_accounts.rb
pageflow-12.4.1 db/migrate/20140624135421_create_themings_for_existing_accounts.rb
pageflow-12.4.0 db/migrate/20140624135421_create_themings_for_existing_accounts.rb
pageflow-12.3.0 db/migrate/20140624135421_create_themings_for_existing_accounts.rb
pageflow-12.2.0 db/migrate/20140624135421_create_themings_for_existing_accounts.rb
pageflow-12.1.0 db/migrate/20140624135421_create_themings_for_existing_accounts.rb
pageflow-12.0.4 db/migrate/20140624135421_create_themings_for_existing_accounts.rb
pageflow-12.0.3 db/migrate/20140624135421_create_themings_for_existing_accounts.rb
pageflow-12.0.2 db/migrate/20140624135421_create_themings_for_existing_accounts.rb
pageflow-12.0.1 db/migrate/20140624135421_create_themings_for_existing_accounts.rb
pageflow-12.0.0 db/migrate/20140624135421_create_themings_for_existing_accounts.rb
pageflow-12.0.0.rc7 db/migrate/20140624135421_create_themings_for_existing_accounts.rb
pageflow-12.0.0.rc6 db/migrate/20140624135421_create_themings_for_existing_accounts.rb
pageflow-0.11.4 db/migrate/20140624135421_create_themings_for_existing_accounts.rb
pageflow-12.0.0.rc5 db/migrate/20140624135421_create_themings_for_existing_accounts.rb
pageflow-12.0.0.rc4 db/migrate/20140624135421_create_themings_for_existing_accounts.rb
pageflow-12.0.0.rc3 db/migrate/20140624135421_create_themings_for_existing_accounts.rb
pageflow-12.0.0.rc2 db/migrate/20140624135421_create_themings_for_existing_accounts.rb
pageflow-12.0.0.rc1 db/migrate/20140624135421_create_themings_for_existing_accounts.rb