From 1d3dc2ff3e15ec7ef23b1fa0446711c905f99191 Mon Sep 17 00:00:00 2001 From: Jacob Michalskie Date: Sat, 10 Dec 2022 12:34:24 +0100 Subject: [PATCH 1/4] Migrate to audited gem --- Gemfile | 3 +-- Gemfile.lock | 15 +++-------- app/models/budget.rb | 2 +- app/models/event.rb | 2 +- app/models/payment.rb | 2 +- app/models/postal_address.rb | 2 +- app/models/reimbursement.rb | 2 +- app/models/reimbursement_attachment.rb | 2 +- app/models/reimbursement_link.rb | 2 +- app/models/request.rb | 2 +- app/models/request_expense.rb | 2 +- app/models/user_profile.rb | 2 +- ...20221210104059_update_columns_in_audits.rb | 26 +++++++++++++++++++ db/schema.rb | 20 ++++++++------ 14 files changed, 52 insertions(+), 32 deletions(-) create mode 100644 db/migrate/20221210104059_update_columns_in_audits.rb diff --git a/Gemfile b/Gemfile index 0fb9ce5c..2bdc76bb 100644 --- a/Gemfile +++ b/Gemfile @@ -44,6 +44,7 @@ gem 'listen' gem 'byebug', group: %i[development test] gem 'active_hash' +gem 'audited' gem 'cancancan', '~> 1.17' gem 'carrierwave' gem 'caxlsx_rails' @@ -54,8 +55,6 @@ gem 'daemons' gem 'date_validator' gem 'devise' gem 'devise_ichain_authenticatable', '>= 0.3.0' -gem 'espinita', git: 'https://github.com/michelson/espinita.git', - ref: '2dc027edc838ee5de0d68558f1758273ccc01636' gem 'git' gem 'inherited_resources' gem 'kaminari' diff --git a/Gemfile.lock b/Gemfile.lock index f49455f8..3ccede99 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,12 +1,3 @@ -GIT - remote: https://github.com/michelson/espinita.git - revision: 2dc027edc838ee5de0d68558f1758273ccc01636 - ref: 2dc027edc838ee5de0d68558f1758273ccc01636 - specs: - espinita (0.0.9) - rails (>= 4.0) - request_store - GEM remote: https://rubygems.org/ specs: @@ -55,6 +46,8 @@ GEM afm (0.2.2) arel (8.0.0) ast (2.4.2) + audited (5.0.2) + activerecord (>= 5.0, < 7.1) autoprefixer-rails (10.4.7.0) execjs (~> 2) bcrypt (3.1.18) @@ -299,8 +292,6 @@ GEM rdoc (6.3.3) redcarpet (3.5.1) regexp_parser (2.6.1) - request_store (1.5.1) - rack (>= 1.4) responders (3.0.1) actionpack (>= 5.0) railties (>= 5.0) @@ -421,6 +412,7 @@ PLATFORMS DEPENDENCIES active_hash + audited bootstrap-sass byebug cancancan (~> 1.17) @@ -438,7 +430,6 @@ DEPENDENCIES delayed_job_active_record devise devise_ichain_authenticatable (>= 0.3.0) - espinita! exception_notification git haml-rails diff --git a/app/models/budget.rb b/app/models/budget.rb index d7a5dfe1..00813e62 100644 --- a/app/models/budget.rb +++ b/app/models/budget.rb @@ -15,5 +15,5 @@ class Budget < ApplicationRecord validates :name, :amount, :currency, presence: true - auditable + audited end diff --git a/app/models/event.rb b/app/models/event.rb index a8c2fd68..9863c7ed 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -25,7 +25,7 @@ class Event < ApplicationRecord validates :name, :start_date, :end_date, :country_code, presence: true validates :end_date, date: { after_or_equal_to: :start_date } - auditable + audited default_scope { order('name asc') } diff --git a/app/models/payment.rb b/app/models/payment.rb index 3f386c03..560ed495 100644 --- a/app/models/payment.rb +++ b/app/models/payment.rb @@ -11,5 +11,5 @@ class Payment < ApplicationRecord mount_uploader :file, AttachmentUploader - auditable except: [:file] + audited except: [:file] end diff --git a/app/models/postal_address.rb b/app/models/postal_address.rb index 80bd35b5..b83c93e9 100644 --- a/app/models/postal_address.rb +++ b/app/models/postal_address.rb @@ -5,5 +5,5 @@ # Defined as a separate model in the shake of cleanest. # class PostalAddress < ApplicationRecord - auditable + audited end diff --git a/app/models/reimbursement.rb b/app/models/reimbursement.rb index 0f71d7dc..4fd5de7a 100644 --- a/app/models/reimbursement.rb +++ b/app/models/reimbursement.rb @@ -44,7 +44,7 @@ class Reimbursement < ApplicationRecord mount_uploader :acceptance_file, AttachmentUploader - auditable except: [:acceptance_file] + audited except: [:acceptance_file] # Synchronizes user_id and request_id before_validation :set_user_id diff --git a/app/models/reimbursement_attachment.rb b/app/models/reimbursement_attachment.rb index 31a732a2..46cac3cb 100644 --- a/app/models/reimbursement_attachment.rb +++ b/app/models/reimbursement_attachment.rb @@ -11,7 +11,7 @@ class ReimbursementAttachment < ApplicationRecord mount_uploader :file, AttachmentUploader - auditable except: [:file] + audited except: [:file] # Changed is ovewritten to avoid losing the already uploaded file when # saving the reimbursement fails in some very specific situations diff --git a/app/models/reimbursement_link.rb b/app/models/reimbursement_link.rb index 8147a95e..3b521df4 100644 --- a/app/models/reimbursement_link.rb +++ b/app/models/reimbursement_link.rb @@ -9,5 +9,5 @@ class ReimbursementLink < ApplicationRecord validates :reimbursement, :title, :url, presence: true - auditable + audited end diff --git a/app/models/request.rb b/app/models/request.rb index d55bf9a5..3d86c5c4 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -12,5 +12,5 @@ class Request < ApplicationRecord validates :event, presence: true - auditable + audited end diff --git a/app/models/request_expense.rb b/app/models/request_expense.rb index dc781e12..3ddd7452 100644 --- a/app/models/request_expense.rb +++ b/app/models/request_expense.rb @@ -24,7 +24,7 @@ class RequestExpense < ApplicationRecord before_validation :set_authorized_amount - auditable + audited # Scope needed by Request.expenses_sum scope :by_attr_for_requests, lambda { |attr, req_ids| diff --git a/app/models/user_profile.rb b/app/models/user_profile.rb index 4abeec0b..caef8bdd 100644 --- a/app/models/user_profile.rb +++ b/app/models/user_profile.rb @@ -20,7 +20,7 @@ class UserProfile < ApplicationRecord validates :role_id, presence: true - auditable + audited scope :with_role, lambda { |role| if role.is_a?(UserRole) diff --git a/db/migrate/20221210104059_update_columns_in_audits.rb b/db/migrate/20221210104059_update_columns_in_audits.rb new file mode 100644 index 00000000..8cafe2ca --- /dev/null +++ b/db/migrate/20221210104059_update_columns_in_audits.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class UpdateColumnsInAudits < ActiveRecord::Migration[5.1] + def change + add_column :audits, :remote_address, :string + add_column :audits, :username, :string + add_column :audits, :request_uuid, :string + add_column :audits, :association_id, :integer + add_column :audits, :association_type, :string + + change_column_null :audits, :auditable_id, true + change_column_null :audits, :auditable_type, true + change_column_null :audits, :action, true + change_column_null :audits, :created_at, true + + remove_index :audits, name: :auditable_index + + add_index :audits, :request_uuid + add_index :audits, [:auditable_type, :auditable_id, :version], name: :auditable_index + add_index :audits, [:associated_type, :associated_id], name: :associated_index + + remove_column :audits, :owner_id, :integer + remove_column :audits, :owner_type, :string + end +end + diff --git a/db/schema.rb b/db/schema.rb index bd9e38c6..64636a78 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,22 +10,26 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170720113427) do +ActiveRecord::Schema.define(version: 20221210104059) do create_table "audits", force: :cascade do |t| - t.integer "auditable_id", null: false - t.string "auditable_type", null: false - t.integer "owner_id", null: false - t.string "owner_type", null: false + t.integer "auditable_id" + t.string "auditable_type" t.integer "user_id" t.string "user_type" - t.string "action", null: false + t.string "action" t.text "audited_changes" t.integer "version", default: 0 t.text "comment" - t.datetime "created_at", null: false - t.index ["auditable_id", "auditable_type", "version"], name: "auditable_index" + t.datetime "created_at" + t.string "remote_address" + t.string "username" + t.string "request_uuid" + t.integer "association_id" + t.string "association_type" + t.index ["auditable_type", "auditable_id", "version"], name: "auditable_index" t.index ["created_at"], name: "index_audits_on_created_at" + t.index ["request_uuid"], name: "index_audits_on_request_uuid" t.index ["user_id", "user_type"], name: "user_index" end From beef4a3d11655601611686ea91cbda9dec5fec73 Mon Sep 17 00:00:00 2001 From: Jacob Michalskie Date: Sat, 10 Dec 2022 12:43:21 +0100 Subject: [PATCH 2/4] Remove trailing line --- db/migrate/20221210104059_update_columns_in_audits.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/db/migrate/20221210104059_update_columns_in_audits.rb b/db/migrate/20221210104059_update_columns_in_audits.rb index 8cafe2ca..1ad1d0f3 100644 --- a/db/migrate/20221210104059_update_columns_in_audits.rb +++ b/db/migrate/20221210104059_update_columns_in_audits.rb @@ -23,4 +23,3 @@ def change remove_column :audits, :owner_type, :string end end - From ad8eadbf1bfc1ced9e052442ec4e0232faf80287 Mon Sep 17 00:00:00 2001 From: Jacob Michalskie Date: Mon, 30 Jan 2023 10:39:41 +0100 Subject: [PATCH 3/4] Migrate data from the old table to the new one --- Gemfile | 1 + Gemfile.lock | 17 +--- ...20221210104059_update_columns_in_audits.rb | 4 +- .../20230130095633_merge_audit_tables.rb | 12 +++ db/schema.rb | 77 ++++++++++--------- 5 files changed, 57 insertions(+), 54 deletions(-) create mode 100644 db/migrate/20230130095633_merge_audit_tables.rb diff --git a/Gemfile b/Gemfile index 2bdc76bb..e5da3284 100644 --- a/Gemfile +++ b/Gemfile @@ -13,6 +13,7 @@ gem 'sqlite3', '~> 1.6.0' # This can only be removed with Rails 7.0 gem 'psych', '< 4.0' +gem 'mail', '< 2.8.0' # Use SCSS for stylesheets gem 'sass-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 3ccede99..1abcfa96 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -109,7 +109,6 @@ GEM activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) - date (3.3.1) date_validator (0.12.0) activemodel (>= 3) activesupport (>= 3) @@ -196,11 +195,8 @@ GEM loofah (2.19.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.8.0) + mail (2.7.1) mini_mime (>= 0.1.1) - net-imap - net-pop - net-smtp marcel (1.0.2) matrix (0.4.2) method_source (1.0.0) @@ -210,15 +206,6 @@ GEM mini_racer (0.6.3) libv8-node (~> 16.10.0.0) minitest (5.17.0) - net-imap (0.3.2) - date - net-protocol - net-pop (0.1.2) - net-protocol - net-protocol (0.2.1) - timeout - net-smtp (0.3.3) - net-protocol nio4r (2.5.8) nokogiri (1.13.10) mini_portile2 (~> 2.8.0) @@ -385,7 +372,6 @@ GEM thor (1.2.1) thread_safe (0.3.6) tilt (2.0.11) - timeout (0.3.1) ttfunk (1.0.3) tzinfo (1.2.10) thread_safe (~> 0.1) @@ -439,6 +425,7 @@ DEPENDENCIES kaminari letter_opener_web listen + mail (< 2.8.0) mini_racer pdf-reader prawn (~> 0.13.0) diff --git a/db/migrate/20221210104059_update_columns_in_audits.rb b/db/migrate/20221210104059_update_columns_in_audits.rb index 1ad1d0f3..94152acf 100644 --- a/db/migrate/20221210104059_update_columns_in_audits.rb +++ b/db/migrate/20221210104059_update_columns_in_audits.rb @@ -5,8 +5,8 @@ def change add_column :audits, :remote_address, :string add_column :audits, :username, :string add_column :audits, :request_uuid, :string - add_column :audits, :association_id, :integer - add_column :audits, :association_type, :string + add_column :audits, :associated_id, :integer + add_column :audits, :associated_type, :string change_column_null :audits, :auditable_id, true change_column_null :audits, :auditable_type, true diff --git a/db/migrate/20230130095633_merge_audit_tables.rb b/db/migrate/20230130095633_merge_audit_tables.rb new file mode 100644 index 00000000..268547be --- /dev/null +++ b/db/migrate/20230130095633_merge_audit_tables.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class MergeAuditTables < ActiveRecord::Migration[5.1] + def self.up + execute "INSERT INTO audits(auditable_id, auditable_type, user_id, user_type, action, audited_changes, version, comment, remote_address, created_at) SELECT auditable_id, auditable_type, user_id, user_type, action, audited_changes, version, comment, remote_address, created_at FROM espinita_audits;" + drop_table :espinita_audits + end + + def self.down + raise IrreversibleMigration + end +end diff --git a/db/schema.rb b/db/schema.rb index 64636a78..32bbecc2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,9 +10,13 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20221210104059) do +ActiveRecord::Schema.define(version: 20230130095633) do - create_table "audits", force: :cascade do |t| + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + enable_extension "pg_stat_statements" + + create_table "audits", id: :serial, force: :cascade do |t| t.integer "auditable_id" t.string "auditable_type" t.integer "user_id" @@ -25,15 +29,19 @@ t.string "remote_address" t.string "username" t.string "request_uuid" - t.integer "association_id" - t.string "association_type" + t.integer "associated_id" + t.string "associated_type" + t.index ["associated_type", "associated_id"], name: "associated_index" + t.index ["auditable_id", "auditable_type", "version"], name: "idx_27755812_auditable_index" t.index ["auditable_type", "auditable_id", "version"], name: "auditable_index" + t.index ["created_at"], name: "idx_27755812_index_audits_on_created_at" t.index ["created_at"], name: "index_audits_on_created_at" t.index ["request_uuid"], name: "index_audits_on_request_uuid" + t.index ["user_id", "user_type"], name: "idx_27755812_user_index" t.index ["user_id", "user_type"], name: "user_index" end - create_table "bank_accounts", force: :cascade do |t| + create_table "bank_accounts", id: :serial, force: :cascade do |t| t.string "holder" t.string "bank_name" t.string "format" @@ -48,17 +56,18 @@ t.datetime "updated_at" end - create_table "budgets", force: :cascade do |t| + create_table "budgets", id: :serial, force: :cascade do |t| t.string "name" t.string "description" t.decimal "amount", precision: 10, scale: 2 t.string "currency" t.datetime "created_at" t.datetime "updated_at" + t.index ["currency"], name: "idx_27755858_index_budgets_on_currency" t.index ["currency"], name: "index_budgets_on_currency" end - create_table "comments", force: :cascade do |t| + create_table "comments", id: :serial, force: :cascade do |t| t.integer "machine_id" t.string "machine_type" t.text "body" @@ -66,10 +75,11 @@ t.datetime "created_at" t.datetime "updated_at" t.boolean "private" + t.index ["private"], name: "idx_27755803_index_comments_on_private" t.index ["private"], name: "index_comments_on_private" end - create_table "delayed_jobs", force: :cascade do |t| + create_table "delayed_jobs", id: :serial, force: :cascade do |t| t.integer "priority", default: 0 t.integer "attempts", default: 0 t.text "handler" @@ -82,25 +92,10 @@ t.datetime "created_at" t.datetime "updated_at" t.index ["priority", "run_at"], name: "delayed_jobs_priority" + t.index ["priority", "run_at"], name: "idx_27755792_delayed_jobs_priority" end - create_table "espinita_audits", force: :cascade do |t| - t.string "auditable_type" - t.integer "auditable_id" - t.string "user_type" - t.integer "user_id" - t.text "audited_changes" - t.string "comment" - t.integer "version" - t.string "action" - t.string "remote_address" - t.datetime "created_at" - t.datetime "updated_at" - t.index ["auditable_type", "auditable_id"], name: "index_espinita_audits_on_auditable_type_and_auditable_id" - t.index ["user_type", "user_id"], name: "index_espinita_audits_on_user_type_and_user_id" - end - - create_table "event_emails", force: :cascade do |t| + create_table "event_emails", id: :serial, force: :cascade do |t| t.text "to" t.string "subject" t.text "body" @@ -110,12 +105,12 @@ t.datetime "updated_at" end - create_table "event_organizers", force: :cascade do |t| + create_table "event_organizers", id: :serial, force: :cascade do |t| t.integer "event_id" t.integer "user_id" end - create_table "events", force: :cascade do |t| + create_table "events", id: :serial, force: :cascade do |t| t.string "name", null: false t.text "description" t.string "country_code" @@ -130,10 +125,11 @@ t.datetime "reimbursement_creation_deadline" t.integer "budget_id" t.string "shipment_type" + t.index ["budget_id"], name: "idx_27755747_index_events_on_budget_id" t.index ["budget_id"], name: "index_events_on_budget_id" end - create_table "payments", force: :cascade do |t| + create_table "payments", id: :serial, force: :cascade do |t| t.integer "reimbursement_id" t.date "date" t.decimal "amount", precision: 10, scale: 2 @@ -149,7 +145,7 @@ t.datetime "updated_at" end - create_table "postal_addresses", force: :cascade do |t| + create_table "postal_addresses", id: :serial, force: :cascade do |t| t.string "line1" t.string "line2" t.string "city" @@ -161,7 +157,7 @@ t.string "name" end - create_table "reimbursement_attachments", force: :cascade do |t| + create_table "reimbursement_attachments", id: :serial, force: :cascade do |t| t.integer "reimbursement_id" t.string "title", null: false t.string "file", null: false @@ -169,7 +165,7 @@ t.datetime "updated_at" end - create_table "reimbursement_links", force: :cascade do |t| + create_table "reimbursement_links", id: :serial, force: :cascade do |t| t.integer "reimbursement_id" t.string "title", null: false t.string "url", null: false @@ -177,7 +173,7 @@ t.datetime "updated_at" end - create_table "reimbursements", force: :cascade do |t| + create_table "reimbursements", id: :serial, force: :cascade do |t| t.string "state" t.integer "user_id", null: false t.integer "request_id", null: false @@ -188,7 +184,7 @@ t.string "acceptance_file" end - create_table "request_expenses", force: :cascade do |t| + create_table "request_expenses", id: :serial, force: :cascade do |t| t.integer "request_id", null: false t.string "subject" t.string "description" @@ -202,7 +198,7 @@ t.decimal "authorized_amount", precision: 10, scale: 2 end - create_table "requests", force: :cascade do |t| + create_table "requests", id: :serial, force: :cascade do |t| t.string "state" t.integer "user_id", null: false t.integer "event_id", null: false @@ -214,13 +210,17 @@ t.integer "postal_address_id" t.string "contact_phone_number" t.string "type" + t.index ["event_id"], name: "idx_27755783_index_requests_on_event_id" t.index ["event_id"], name: "index_requests_on_event_id" + t.index ["postal_address_id"], name: "idx_27755783_index_requests_on_postal_address_id" t.index ["postal_address_id"], name: "index_requests_on_postal_address_id" + t.index ["type"], name: "idx_27755783_index_requests_on_type" t.index ["type"], name: "index_requests_on_type" + t.index ["user_id"], name: "idx_27755783_index_requests_on_user_id" t.index ["user_id"], name: "index_requests_on_user_id" end - create_table "state_changes", force: :cascade do |t| + create_table "state_changes", id: :serial, force: :cascade do |t| t.integer "machine_id", null: false t.string "machine_type", null: false t.string "state_event" @@ -231,10 +231,11 @@ t.datetime "created_at" t.datetime "updated_at" t.string "type" + t.index ["type"], name: "idx_27755849_index_state_changes_on_type" t.index ["type"], name: "index_state_changes_on_type" end - create_table "user_profiles", force: :cascade do |t| + create_table "user_profiles", id: :serial, force: :cascade do |t| t.integer "user_id", null: false t.integer "role_id", null: false t.string "full_name" @@ -254,7 +255,7 @@ t.string "postal_address" end - create_table "users", force: :cascade do |t| + create_table "users", id: :serial, force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false t.string "reset_password_token" @@ -269,7 +270,9 @@ t.string "locale", default: "en", null: false t.datetime "created_at" t.datetime "updated_at" + t.index ["email"], name: "idx_27755725_index_users_on_email", unique: true t.index ["email"], name: "index_users_on_email", unique: true + t.index ["reset_password_token"], name: "idx_27755725_index_users_on_reset_password_token", unique: true t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end From d9b64d1542dc0ace9fc417ace8d3a2fa53bfd3e8 Mon Sep 17 00:00:00 2001 From: Jacob Michalskie Date: Mon, 30 Jan 2023 10:52:41 +0100 Subject: [PATCH 4/4] Address lints --- Gemfile | 2 +- db/migrate/20221210104059_update_columns_in_audits.rb | 4 ++-- db/migrate/20230130095633_merge_audit_tables.rb | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index e5da3284..31243d2a 100644 --- a/Gemfile +++ b/Gemfile @@ -12,8 +12,8 @@ gem 'sqlite3', '~> 1.6.0' # gem 'mysql2', '~> 0.4.10' # This can only be removed with Rails 7.0 -gem 'psych', '< 4.0' gem 'mail', '< 2.8.0' +gem 'psych', '< 4.0' # Use SCSS for stylesheets gem 'sass-rails' diff --git a/db/migrate/20221210104059_update_columns_in_audits.rb b/db/migrate/20221210104059_update_columns_in_audits.rb index 94152acf..bf5bad9b 100644 --- a/db/migrate/20221210104059_update_columns_in_audits.rb +++ b/db/migrate/20221210104059_update_columns_in_audits.rb @@ -16,8 +16,8 @@ def change remove_index :audits, name: :auditable_index add_index :audits, :request_uuid - add_index :audits, [:auditable_type, :auditable_id, :version], name: :auditable_index - add_index :audits, [:associated_type, :associated_id], name: :associated_index + add_index :audits, %i[auditable_type auditable_id version], name: :auditable_index + add_index :audits, %i[associated_type associated_id], name: :associated_index remove_column :audits, :owner_id, :integer remove_column :audits, :owner_type, :string diff --git a/db/migrate/20230130095633_merge_audit_tables.rb b/db/migrate/20230130095633_merge_audit_tables.rb index 268547be..b46c0b2e 100644 --- a/db/migrate/20230130095633_merge_audit_tables.rb +++ b/db/migrate/20230130095633_merge_audit_tables.rb @@ -2,7 +2,8 @@ class MergeAuditTables < ActiveRecord::Migration[5.1] def self.up - execute "INSERT INTO audits(auditable_id, auditable_type, user_id, user_type, action, audited_changes, version, comment, remote_address, created_at) SELECT auditable_id, auditable_type, user_id, user_type, action, audited_changes, version, comment, remote_address, created_at FROM espinita_audits;" + execute 'INSERT INTO audits(auditable_id, auditable_type, user_id, user_type, action, audited_changes, version, comment, remote_address, created_at) ' \ + 'SELECT auditable_id, auditable_type, user_id, user_type, action, audited_changes, version, comment, remote_address, created_at FROM espinita_audits;' drop_table :espinita_audits end