From 54478591b36102fc3c70c1f1a2920e92c58695f5 Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Tue, 2 Jan 2024 14:18:41 +0900 Subject: [PATCH 2/2] Add not null constraints to lft and rgt in issues table --- ...0102042936_add_not_null_constraint_to_projects.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 db/migrate/20240102042936_add_not_null_constraint_to_projects.rb diff --git a/db/migrate/20240102042936_add_not_null_constraint_to_projects.rb b/db/migrate/20240102042936_add_not_null_constraint_to_projects.rb new file mode 100644 index 000000000..3b81c455b --- /dev/null +++ b/db/migrate/20240102042936_add_not_null_constraint_to_projects.rb @@ -0,0 +1,12 @@ +class AddNotNullConstraintToProjects < ActiveRecord::Migration[7.1] + def change + change_column_null :projects, :lft, false + change_column_null :projects, :rgt, 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 'Project.rebuild_tree!'` may fix the issue." + warn "********************\n\n" + raise + end +end -- 2.42.0