Project

General

Profile

Refactor #14093

Remove unused roles permissions column

Added by Dominic Cleal almost 5 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Database
Target version:
Difficulty:
Triaged:
Bugzilla link:
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

Blocks Foreman - Feature #13244: Upgrade Ruby on Rails to 4.2Closed2016-01-15

Associated revisions

Revision 1657a147 (diff)
Added by Dominic Cleal almost 5 years ago

fixes #14093 - remove unused permissions column from roles

History

#1 Updated by Dominic Cleal almost 5 years ago

#2 Updated by The Foreman Bot almost 5 years ago

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

#3 Updated by Dominic Cleal almost 5 years ago

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

#4 Updated by Dominic Cleal almost 5 years ago

  • Legacy Backlogs Release (now unused) set to 136

Also available in: Atom PDF