From 065a6a4473fba774b54531304ec0e0313a3fa074 Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Tue, 2 Jan 2024 14:18:02 +0900 Subject: [PATCH 1/2] Add not null constraints to lft, rgt, and root_id in issues table --- ...40102042920_add_not_null_constraint_to_issues.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 db/migrate/20240102042920_add_not_null_constraint_to_issues.rb diff --git a/db/migrate/20240102042920_add_not_null_constraint_to_issues.rb b/db/migrate/20240102042920_add_not_null_constraint_to_issues.rb new file mode 100644 index 000000000..7f74581ce --- /dev/null +++ b/db/migrate/20240102042920_add_not_null_constraint_to_issues.rb @@ -0,0 +1,13 @@ +class AddNotNullConstraintToIssues < ActiveRecord::Migration[7.1] + def change + change_column_null :issues, :lft, false + change_column_null :issues, :rgt, false + change_column_null :issues, :root_id, false + rescue => e + # The migration may fail if there are NULL values in the columns + warn "\n\n********************" + warn "Migration failed.\nRunning `bin/rails r 'Issue.rebuild_tree!'` may fix the issue." + warn "********************\n\n" + raise + end +end -- 2.42.0