Sha256: 92c2ed6614df80668f711448b6973b2ffe7a5216b7ec282c30607d5cd2508cb0

Contents?: true

Size: 1.09 KB

Versions: 16

Compression:

Stored size: 1.09 KB

Contents

class FixStatusCodes < ActiveRecord::Migration
  def up
    execute "DROP TRIGGER #{Landable.configuration.database_schema_prefix}landable_page_revisions__no_update 
              ON #{Landable.configuration.database_schema_prefix}landable.page_revisions"

    # Find Pages with 404s, switch to 410s, publish the page!
    Landable::Page.where(status_code: 404).find_each do |page| 
      page.status_code = 410
      page.save!
    end

    # Find Remaining PageRevisions with 404s, switch to 410s!
    Landable::PageRevision.where(status_code: 404).find_each do |page| 
      page.status_code = 410
      page.save!
    end

    execute "CREATE TRIGGER #{Landable.configuration.database_schema_prefix}landable_page_revisions__no_update
            BEFORE UPDATE OF notes, is_minor, page_id, author_id, created_at, ordinal
              , theme_id, status_code, category_id, redirect_url, body
            ON #{Landable.configuration.database_schema_prefix}landable.page_revisions
            FOR EACH STATEMENT EXECUTE PROCEDURE #{Landable.configuration.database_schema_prefix}landable.tg_disallow();"
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
landable-1.13.1 db/migrate/20140205193757_fix_status_codes.rb
landable-1.12.3 db/migrate/20140205193757_fix_status_codes.rb
landable-1.12.2 db/migrate/20140205193757_fix_status_codes.rb
landable-1.12.1 db/migrate/20140205193757_fix_status_codes.rb
landable-1.11.1 db/migrate/20140205193757_fix_status_codes.rb
landable-1.11.0 db/migrate/20140205193757_fix_status_codes.rb
landable-1.10.0.rc2 db/migrate/20140205193757_fix_status_codes.rb
landable-1.10.0.rc1 db/migrate/20140205193757_fix_status_codes.rb
landable-1.9.2 db/migrate/20140205193757_fix_status_codes.rb
landable-1.9.1 db/migrate/20140205193757_fix_status_codes.rb
landable-1.9.0 db/migrate/20140205193757_fix_status_codes.rb
landable-1.9.0.rc2 db/migrate/20140205193757_fix_status_codes.rb
landable-1.9.0.rc1 db/migrate/20140205193757_fix_status_codes.rb
landable-1.8.0 db/migrate/20140205193757_fix_status_codes.rb
landable-1.7.1.rc1 db/migrate/20140205193757_fix_status_codes.rb
landable-1.7.0 db/migrate/20140205193757_fix_status_codes.rb