Sha256: ce689ac0669bce77102bef331648c98f6116882e95e984f087cda173b6f95785

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 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

2 entries across 2 versions & 1 rubygems

Version Path
landable-1.14.0 db/migrate/20140205193757_fix_status_codes.rb
landable-1.13.2 db/migrate/20140205193757_fix_status_codes.rb