Browse Source

Follow up 58da12c - Feature: Desktop view - Implement Token Access personal setting section.

Mantas Masalskis 10 months ago
parent
commit
60f0059559
1 changed files with 8 additions and 2 deletions
  1. 8 2
      app/models/permission.rb

+ 8 - 2
app/models/permission.rb

@@ -9,8 +9,14 @@ class Permission < ApplicationModel
   store                   :preferences
 
   validates :name, presence: true
-  validates :label, length: { maximum: 255 }
-  validates :description, length: { maximum: 500 }
+
+  # This is added to handle migrations from before the columns were modified.
+  # For example when upgrading from pre-6.4.
+  # Otherwise older migrations fail since those columnsa are not yet available.
+  with_options if: -> { respond_to?(:label) && respond_to?(:description) } do
+    validates :label, length: { maximum: 255 }
+    validates :description, length: { maximum: 500 }
+  end
 
   sanitized_html :description