Project

General

Profile

Actions

Refactor #14093

closed

Remove unused roles permissions column

Added by Dominic Cleal almost 9 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Database
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

The roles table has a permissions text column that pre-#812 was a serialised list of permissions assigned to the role. #812 changed this so that permissions are associated via filters, and permissions is now an has_many association through filters, but the column wasn't removed in that patch.


The presence of the column was causing a test failure on Rails 4.2 because it has the same name as the association.

--- expected
+++ actual
@@ -1 +1 @@
-#<ActiveRecord::Associations::CollectionProxy []>
+#<ActiveRecord::Associations::CollectionProxy [#<Permission id: 769440046, name: "view_ptables", resource_type: "Ptable", created_at: "2013-12-04 08:41:05", updated_at: "2013-12-04 08:41:05">]>
 (Minitest::Assertion)
/var/lib/workspace/workspace/test_develop_pr_core/database/mysql/label/fast/ruby/2.2/test/functional/roles_controller_test.rb:82

Under MySQL, the column has a limit of 64k characters, which validates_lengths_from_database enforces. In the, it created a Role then called #add_permissions! on it, but calling .permissions after would return an empty array on MySQL (not other DBs).

The length validation on the permissions field was called when the role was first created, and this caused the permissions association to be cached by Rails. Reloading the association worked, but also removing the identically named and unused attribute also prevents the validation messing with the association.


Related issues 1 (0 open1 closed)

Blocks Foreman - Feature #13244: Upgrade Ruby on Rails to 4.2ClosedDominic Cleal01/15/2016Actions
Actions #1

Updated by Dominic Cleal almost 9 years ago

Actions #2

Updated by The Foreman Bot almost 9 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/3289 added
Actions #3

Updated by Dominic Cleal almost 9 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions #4

Updated by Dominic Cleal almost 9 years ago

  • Translation missing: en.field_release set to 136
Actions

Also available in: Atom PDF