-
-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disallow deleting pages if still attached to menu node (#2338)
Add foreign key on nodes to restrict on delete page_id and add a warning on delete if a page is still linked to nodes. Closes #2301
- Loading branch information
Showing
7 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
db/migrate/20220514072456_restrict_on_delete_page_id_foreign_key_from_alchemy_nodes.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
class RestrictOnDeletePageIdForeignKeyFromAlchemyNodes < ActiveRecord::Migration[6.0] | ||
def up | ||
remove_foreign_key :alchemy_nodes, :alchemy_pages | ||
add_foreign_key :alchemy_nodes, :alchemy_pages, column: :page_id, on_delete: :restrict | ||
end | ||
|
||
def down | ||
remove_foreign_key :alchemy_nodes, :alchemy_pages | ||
add_foreign_key :alchemy_nodes, :alchemy_pages, column: :page_id, on_delete: :cascade | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...my/db/migrate/20220514072456_restrict_on_delete_page_id_foreign_key_from_alchemy_nodes.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class RestrictOnDeletePageIdForeignKeyFromAlchemyNodes < ActiveRecord::Migration[6.0] | ||
def up | ||
remove_foreign_key :alchemy_nodes, :alchemy_pages | ||
add_foreign_key :alchemy_nodes, :alchemy_pages, column: :page_id, on_delete: :restrict | ||
end | ||
|
||
def down | ||
remove_foreign_key :alchemy_nodes, :alchemy_pages | ||
add_foreign_key :alchemy_nodes, :alchemy_pages, column: :page_id, on_delete: :cascade | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters