Skip to content

Commit

Permalink
Merge pull request solidusio#5833 from MadelineCollier/add-role-colum…
Browse files Browse the repository at this point in the history
…ns-validations

[Admin] Add new migrations and validations in `core` to support new `admin` `Spree::Role` interface
  • Loading branch information
MadelineCollier authored Aug 29, 2024
2 parents 99e69db + 1aa18ee commit 630f1ef
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/app/models/spree/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Role < Spree::Base
has_many :role_users, class_name: "Spree::RoleUser", dependent: :destroy
has_many :users, through: :role_users

validates_uniqueness_of :name, case_sensitive: true
validates :name, presence: true, uniqueness: { case_sensitive: true, allow_blank: true }

def admin?
name == "admin"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateSpreePermissionSetsInCore < ActiveRecord::Migration[7.0]
def change
create_table :spree_permission_sets, if_not_exists: true do |t|
t.string :name
t.string :set
t.timestamps null: false
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateSpreeRolesPermissionsInCore < ActiveRecord::Migration[7.0]
def change
create_table :spree_role_permissions, if_not_exists: true do |t|
t.references :role
t.references :permission_set
t.timestamps null: false
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddDescriptionToSpreeRoles < ActiveRecord::Migration[7.0]
def change
add_column :spree_roles, :description, :text
end
end

0 comments on commit 630f1ef

Please sign in to comment.