Bug #10740
closedAudits created during DB migration of ptables to templates
Description
When migrating over #7096, audits are created due to the update of ptable_id on hosts and host groups.
2015-06-09T14:47:28 [sql] [I] Migrating to MigratePtablesToTemplates (20150514114044) -- migrating partition table Kickstart default ... 2015-06-09T14:47:30 [sql] [D] Host::Managed Load (0.2ms) SELECT "hosts".* FROM "hosts" WHERE "hosts"."type" IN ('Host::Managed') AND "hosts"."id" = 168 LIMIT 1 2015-06-09T14:47:30 [sql] [D] (0.1ms) SELECT MAX("audits"."version") AS max_id FROM "audits" WHERE "audits"."auditable_id" = 168 AND "audits"."auditable_type" = 'Host' 2015-06-09T14:47:30 [sql] [D] SQL (0.3ms) INSERT INTO "audits" ("action", "associated_id", "associated_name", "associated_type", "auditable_id", "auditable_name", "auditable_type", "audited_changes", "comment", "created_at", "remote_address", "request_uuid", "user_id", "user_type", "username", "version") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["action", "update"], ["associated_id", nil], ["associated_name", nil], ["associated_type", nil], ["auditable_id", 168], ["auditable_name", "test.example.com"], ["auditable_type ", "Host"], ["audited_changes", "---\nptable_id:\n- 12\n- 86\n"], ["comment", nil], ["created_at", Tue, 09 Jun 2015 13:47:30 UTC +00:00], ["remote_address", nil], ["request_uuid", nil], ["user_id", nil], ["user_type", nil], ["username", nil], ["version", 7]]
Updated by Dominic Cleal over 9 years ago
- Related to Feature #7096: Partition Tables should just be a kind of Provisioning Templates added
Updated by Dominic Cleal over 9 years ago
I wonder if we ought to use this more:
self.auditing_enabled = !Foreman.in_rake?('db:migrate')
Used today in a few models such as provisioning template.
Updated by The Foreman Bot over 9 years ago
- Status changed from Assigned to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/2447 added
- Pull request deleted (
)
Updated by Marek Hulán over 9 years ago
I didn't find an easy way how to hook into audited so it would set auditing_enabled = !Foreman.in_rake?('db:migrate') for all audited models. I could go through all such models and add it manually if you want. For new audited models I'm afraid we'll forget to add to though. Maybe some global auditing switch in audited gem would help.
Updated by Ohad Levy over 9 years ago
Marek Hulán wrote:
I didn't find an easy way how to hook into audited so it would set auditing_enabled = !Foreman.in_rake?('db:migrate') for all audited models. I could go through all such models and add it manually if you want. For new audited models I'm afraid we'll forget to add to though. Maybe some global auditing switch in audited gem would help.
cant you change the base class? or even in the audit initializer, as you init the whole app as rake?
Updated by Marek Hulán over 9 years ago
This accessor is defined by calling audited so it's not present in ActiveRecord::Base I could monkey patch it but it seems a bit weird that models that are not audited would have this method defined. Hopefully it won't do any harm later, so far I like it the most. I'm not sure what exactly do you mean by audit initializer, creating a new initializer that would change the auditing flag? If we define this method in ActiveRecord::Base then I think it's sufficient to check there.
EDIT: oh I didn't realize that audited
call will override the accessor value so we can't simply set it in ActiveRecord::Base
Updated by Marek Hulán over 9 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset 68bf0c89303d197b91cab358344c93d693bc93ee.
Updated by Martin Bacovsky over 8 years ago
- Related to Bug #14965: Migration error in foreman_bootdisk upgrading from 6.1 to 6.2 added