Skip to content

Commit

Permalink
Remove visible from existing pages
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdeyen committed Jun 5, 2020
1 parent e5eabe1 commit cb7de34
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
24 changes: 24 additions & 0 deletions db/migrate/20200519073500_remove_visible_from_alchemy_pages.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true
class RemoveVisibleFromAlchemyPages < ActiveRecord::Migration[5.2]
class LocalPage < ActiveRecord::Base
self.table_name = "alchemy_pages"

scope :invisible, -> { where(visible: [false, nil]) }
scope :contentpages, -> { where(layoutpage: [false, nil]) }
end

def up
if LocalPage.invisible.contentpages.where.not(parent_id: nil).any?
abort "You have invisible pages in your database! " \
"Please re-structure your page tree before running this migration. " \
"You might also downgrade to Alchemy 4.6 and " \
"run the `alchemy:upgrade:4.6:restructure_page_tree` rake task."
end

remove_column :alchemy_pages, :visible
end

def down
add_column :alchemy_pages, :visible, :boolean, default: false
end
end
3 changes: 1 addition & 2 deletions spec/dummy/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2020_05_14_091507) do
ActiveRecord::Schema.define(version: 2020_05_19_073500) do

create_table "alchemy_attachments", force: :cascade do |t|
t.string "name"
Expand Down Expand Up @@ -216,7 +216,6 @@
t.integer "rgt"
t.integer "parent_id"
t.integer "depth"
t.boolean "visible", default: false
t.integer "locked_by"
t.boolean "restricted", default: false
t.boolean "robot_index", default: true
Expand Down

0 comments on commit cb7de34

Please sign in to comment.