audited 4.9.0 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of audited might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +115 -0
- data/.standard.yml +5 -0
- data/Appraisals +22 -16
- data/CHANGELOG.md +68 -1
- data/Gemfile +1 -1
- data/README.md +49 -11
- data/Rakefile +6 -6
- data/gemfiles/rails60.gemfile +1 -1
- data/gemfiles/rails61.gemfile +10 -0
- data/gemfiles/rails70.gemfile +10 -0
- data/lib/audited/audit.rb +36 -28
- data/lib/audited/auditor.rb +69 -43
- data/lib/audited/railtie.rb +16 -0
- data/lib/audited/rspec_matchers.rb +5 -3
- data/lib/audited/sweeper.rb +3 -10
- data/lib/audited/version.rb +3 -1
- data/lib/audited-rspec.rb +3 -1
- data/lib/audited.rb +25 -8
- data/lib/generators/audited/install_generator.rb +9 -7
- data/lib/generators/audited/migration.rb +2 -0
- data/lib/generators/audited/migration_helper.rb +3 -1
- data/lib/generators/audited/templates/add_association_to_audits.rb +2 -0
- data/lib/generators/audited/templates/add_comment_to_audits.rb +2 -0
- data/lib/generators/audited/templates/add_remote_address_to_audits.rb +2 -0
- data/lib/generators/audited/templates/add_request_uuid_to_audits.rb +2 -0
- data/lib/generators/audited/templates/add_version_to_auditable_index.rb +2 -0
- data/lib/generators/audited/templates/install.rb +2 -0
- data/lib/generators/audited/templates/rename_association_to_associated.rb +2 -0
- data/lib/generators/audited/templates/rename_changes_to_audited_changes.rb +2 -0
- data/lib/generators/audited/templates/rename_parent_to_association.rb +2 -0
- data/lib/generators/audited/templates/revert_polymorphic_indexes_order.rb +2 -0
- data/lib/generators/audited/upgrade_generator.rb +16 -14
- data/spec/audited/audit_spec.rb +69 -47
- data/spec/audited/auditor_spec.rb +310 -246
- data/spec/audited/sweeper_spec.rb +19 -18
- data/spec/audited_spec.rb +18 -0
- data/spec/audited_spec_helpers.rb +7 -7
- data/spec/rails_app/app/assets/config/manifest.js +2 -0
- data/spec/rails_app/config/application.rb +3 -3
- data/spec/rails_app/config/database.yml +3 -2
- data/spec/rails_app/config/environment.rb +1 -1
- data/spec/rails_app/config/environments/test.rb +5 -5
- data/spec/rails_app/config/initializers/secret_token.rb +2 -2
- data/spec/spec_helper.rb +14 -14
- data/spec/support/active_record/models.rb +31 -12
- data/spec/support/active_record/postgres/1_change_audited_changes_type_to_json.rb +1 -2
- data/spec/support/active_record/postgres/2_change_audited_changes_type_to_jsonb.rb +1 -2
- data/spec/support/active_record/schema.rb +26 -19
- data/test/db/version_1.rb +2 -2
- data/test/db/version_2.rb +2 -2
- data/test/db/version_3.rb +2 -3
- data/test/db/version_4.rb +2 -3
- data/test/db/version_5.rb +0 -1
- data/test/db/version_6.rb +1 -1
- data/test/install_generator_test.rb +18 -19
- data/test/test_helper.rb +5 -5
- data/test/upgrade_generator_test.rb +13 -18
- metadata +31 -30
- data/.rubocop.yml +0 -25
- data/.travis.yml +0 -58
- data/gemfiles/rails42.gemfile +0 -11
- data/spec/rails_app/app/controllers/application_controller.rb +0 -2
- data/spec/rails_app/config/environments/development.rb +0 -21
- data/spec/rails_app/config/environments/production.rb +0 -35
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
SingleCov.covered!
|
3
|
+
SingleCov.covered!
|
4
4
|
|
5
5
|
class AuditsController < ActionController::Base
|
6
6
|
before_action :populate_user
|
@@ -13,7 +13,7 @@ class AuditsController < ActionController::Base
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def update
|
16
|
-
current_user.update!(password:
|
16
|
+
current_user.update!(password: "foo")
|
17
17
|
head :ok
|
18
18
|
end
|
19
19
|
|
@@ -22,7 +22,8 @@ class AuditsController < ActionController::Base
|
|
22
22
|
attr_accessor :current_user
|
23
23
|
attr_accessor :custom_user
|
24
24
|
|
25
|
-
def populate_user
|
25
|
+
def populate_user
|
26
|
+
end
|
26
27
|
end
|
27
28
|
|
28
29
|
describe AuditsController do
|
@@ -30,6 +31,7 @@ describe AuditsController do
|
|
30
31
|
render_views
|
31
32
|
|
32
33
|
before do
|
34
|
+
Audited::Railtie.initializers.each(&:run)
|
33
35
|
Audited.current_user_method = :current_user
|
34
36
|
end
|
35
37
|
|
@@ -40,7 +42,7 @@ describe AuditsController do
|
|
40
42
|
controller.send(:current_user=, user)
|
41
43
|
expect {
|
42
44
|
post :create
|
43
|
-
}.to change(
|
45
|
+
}.to change(Audited::Audit, :count)
|
44
46
|
|
45
47
|
expect(controller.company.audits.last.user).to eq(user)
|
46
48
|
end
|
@@ -50,7 +52,7 @@ describe AuditsController do
|
|
50
52
|
Audited.current_user_method = :nope
|
51
53
|
expect {
|
52
54
|
post :create
|
53
|
-
}.to change(
|
55
|
+
}.to change(Audited::Audit, :count)
|
54
56
|
expect(controller.company.audits.last.user).to eq(nil)
|
55
57
|
end
|
56
58
|
|
@@ -60,18 +62,18 @@ describe AuditsController do
|
|
60
62
|
|
61
63
|
expect {
|
62
64
|
post :create
|
63
|
-
}.to change(
|
65
|
+
}.to change(Audited::Audit, :count)
|
64
66
|
|
65
67
|
expect(controller.company.audits.last.user).to eq(user)
|
66
68
|
end
|
67
69
|
|
68
70
|
it "should record the remote address responsible for the change" do
|
69
|
-
request.env[
|
71
|
+
request.env["REMOTE_ADDR"] = "1.2.3.4"
|
70
72
|
controller.send(:current_user=, user)
|
71
73
|
|
72
74
|
post :create
|
73
75
|
|
74
|
-
expect(controller.company.audits.last.remote_address).to eq(
|
76
|
+
expect(controller.company.audits.last.remote_address).to eq("1.2.3.4")
|
75
77
|
end
|
76
78
|
|
77
79
|
it "should record a UUID for the web request responsible for the change" do
|
@@ -90,7 +92,7 @@ describe AuditsController do
|
|
90
92
|
|
91
93
|
expect {
|
92
94
|
post :create
|
93
|
-
}.to change(
|
95
|
+
}.to change(Audited::Audit, :count)
|
94
96
|
|
95
97
|
expect(controller.company.audits.last.user).to eq(user)
|
96
98
|
end
|
@@ -101,32 +103,31 @@ describe AuditsController do
|
|
101
103
|
controller.send(:current_user=, user)
|
102
104
|
|
103
105
|
expect {
|
104
|
-
put :update,
|
105
|
-
}.to_not change(
|
106
|
+
put :update, params: {id: 123}
|
107
|
+
}.to_not change(Audited::Audit, :count)
|
106
108
|
end
|
107
109
|
end
|
108
110
|
end
|
109
111
|
|
110
112
|
describe Audited::Sweeper do
|
111
|
-
|
112
113
|
it "should be thread-safe" do
|
113
114
|
instance = Audited::Sweeper.new
|
114
115
|
|
115
116
|
t1 = Thread.new do
|
116
117
|
sleep 0.5
|
117
|
-
instance.controller =
|
118
|
-
expect(instance.controller).to eq(
|
118
|
+
instance.controller = "thread1 controller instance"
|
119
|
+
expect(instance.controller).to eq("thread1 controller instance")
|
119
120
|
end
|
120
121
|
|
121
122
|
t2 = Thread.new do
|
122
|
-
instance.controller =
|
123
|
+
instance.controller = "thread2 controller instance"
|
123
124
|
sleep 1
|
124
|
-
expect(instance.controller).to eq(
|
125
|
+
expect(instance.controller).to eq("thread2 controller instance")
|
125
126
|
end
|
126
127
|
|
127
|
-
t1.join
|
128
|
+
t1.join
|
129
|
+
t2.join
|
128
130
|
|
129
131
|
expect(instance.controller).to be_nil
|
130
132
|
end
|
131
|
-
|
132
133
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Audited do
|
4
|
+
describe "#store" do
|
5
|
+
describe "maintains state of store" do
|
6
|
+
let(:current_user) { "current_user" }
|
7
|
+
before { Audited.store[:current_user] = current_user }
|
8
|
+
|
9
|
+
it "when executed without fibers" do
|
10
|
+
expect(Audited.store[:current_user]).to eq(current_user)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "when executed with Fibers" do
|
14
|
+
Fiber.new { expect(Audited.store[:current_user]).to eq(current_user) }.resume
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,15 +1,14 @@
|
|
1
1
|
module AuditedSpecHelpers
|
2
|
-
|
3
2
|
def create_user(attrs = {})
|
4
|
-
Models::ActiveRecord::User.create({name:
|
3
|
+
Models::ActiveRecord::User.create({name: "Brandon", username: "brandon", password: "password", favourite_device: "Android Phone"}.merge(attrs))
|
5
4
|
end
|
6
5
|
|
7
6
|
def build_user(attrs = {})
|
8
|
-
Models::ActiveRecord::User.new({name:
|
7
|
+
Models::ActiveRecord::User.new({name: "darth", username: "darth", password: "noooooooo"}.merge(attrs))
|
9
8
|
end
|
10
9
|
|
11
10
|
def create_versions(n = 2, attrs = {})
|
12
|
-
Models::ActiveRecord::User.create(name:
|
11
|
+
Models::ActiveRecord::User.create(name: "Foobar 1", **attrs).tap do |u|
|
13
12
|
(n - 1).times do |i|
|
14
13
|
u.update_attribute :name, "Foobar #{i + 2}"
|
15
14
|
end
|
@@ -18,15 +17,16 @@ module AuditedSpecHelpers
|
|
18
17
|
end
|
19
18
|
|
20
19
|
def run_migrations(direction, migrations_paths, target_version = nil)
|
21
|
-
if rails_below?(
|
20
|
+
if rails_below?("5.2.0.rc1")
|
22
21
|
ActiveRecord::Migrator.send(direction, migrations_paths, target_version)
|
23
|
-
|
22
|
+
elsif rails_below?("6.0.0.rc1")
|
24
23
|
ActiveRecord::MigrationContext.new(migrations_paths).send(direction, target_version)
|
24
|
+
else
|
25
|
+
ActiveRecord::MigrationContext.new(migrations_paths, ActiveRecord::SchemaMigration).send(direction, target_version)
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
29
|
def rails_below?(rails_version)
|
29
30
|
Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new(rails_version)
|
30
31
|
end
|
31
|
-
|
32
32
|
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
require
|
1
|
+
require "active_record/railtie"
|
2
2
|
|
3
3
|
module RailsApp
|
4
4
|
class Application < Rails::Application
|
5
|
-
config.root = File.expand_path(
|
5
|
+
config.root = File.expand_path("../../", __FILE__)
|
6
6
|
config.i18n.enforce_available_locales = true
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
require
|
10
|
+
require "active_record/connection_adapters/sqlite3_adapter"
|
11
11
|
if ActiveRecord::ConnectionAdapters::SQLite3Adapter.respond_to?(:represent_boolean_as_integer)
|
12
12
|
ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer = true
|
13
13
|
end
|
@@ -9,7 +9,8 @@ sqlite3: &SQLITE
|
|
9
9
|
postgresql: &POSTGRES
|
10
10
|
adapter: postgresql
|
11
11
|
username: postgres
|
12
|
-
password:
|
12
|
+
password: postgres
|
13
|
+
host: localhost
|
13
14
|
database: audited_test
|
14
15
|
min_messages: ERROR
|
15
16
|
|
@@ -17,7 +18,7 @@ mysql: &MYSQL
|
|
17
18
|
adapter: mysql2
|
18
19
|
host: localhost
|
19
20
|
username: root
|
20
|
-
password:
|
21
|
+
password: root
|
21
22
|
database: audited_test
|
22
23
|
charset: utf8
|
23
24
|
|
@@ -15,14 +15,14 @@ RailsApp::Application.configure do
|
|
15
15
|
# Configure static file server for tests with Cache-Control for performance.
|
16
16
|
if config.respond_to?(:public_file_server)
|
17
17
|
config.public_file_server.enabled = true
|
18
|
-
config.public_file_server.headers = {
|
18
|
+
config.public_file_server.headers = {"Cache-Control" => "public, max-age=3600"}
|
19
19
|
else
|
20
|
-
config.static_cache_control =
|
21
|
-
config.serve_static_files
|
20
|
+
config.static_cache_control = "public, max-age=3600"
|
21
|
+
config.serve_static_files = true
|
22
22
|
end
|
23
23
|
|
24
24
|
# Show full error reports and disable caching.
|
25
|
-
config.consider_all_requests_local
|
25
|
+
config.consider_all_requests_local = true
|
26
26
|
# config.action_controller.perform_caching = false
|
27
27
|
|
28
28
|
# Raise exceptions instead of rendering exception templates.
|
@@ -34,7 +34,7 @@ RailsApp::Application.configure do
|
|
34
34
|
# Tell Action Mailer not to deliver emails to the real world.
|
35
35
|
# The :test delivery method accumulates sent emails in the
|
36
36
|
# ActionMailer::Base.deliveries array.
|
37
|
-
config.action_mailer.delivery_method = :test
|
37
|
+
# config.action_mailer.delivery_method = :test
|
38
38
|
|
39
39
|
# Randomize the order test cases are executed.
|
40
40
|
config.active_support.test_order = :random
|
@@ -1,3 +1,3 @@
|
|
1
|
-
Rails.application.config.secret_token =
|
1
|
+
Rails.application.config.secret_token = "ea942c41850d502f2c8283e26bdc57829f471bb18224ddff0a192c4f32cdf6cb5aa0d82b3a7a7adbeb640c4b06f3aa1cd5f098162d8240f669b39d6b49680571"
|
2
2
|
Rails.application.config.session_store :cookie_store, key: "_my_app"
|
3
|
-
Rails.application.config.secret_key_base =
|
3
|
+
Rails.application.config.secret_key_base = "secret value"
|
data/spec/spec_helper.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
ENV[
|
2
|
-
require
|
3
|
-
require
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
|
+
require "bundler/setup"
|
3
|
+
require "single_cov"
|
4
4
|
SingleCov.setup :rspec
|
5
5
|
|
6
|
-
if Bundler.definition.dependencies.map(&:name).include?(
|
7
|
-
require
|
6
|
+
if Bundler.definition.dependencies.map(&:name).include?("protected_attributes")
|
7
|
+
require "protected_attributes"
|
8
8
|
end
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
9
|
+
require "rails_app/config/environment"
|
10
|
+
require "rspec/rails"
|
11
|
+
require "audited"
|
12
|
+
require "audited-rspec"
|
13
|
+
require "audited_spec_helpers"
|
14
|
+
require "support/active_record/models"
|
15
15
|
|
16
|
-
SPEC_ROOT = Pathname.new(File.expand_path(
|
16
|
+
SPEC_ROOT = Pathname.new(File.expand_path("../", __FILE__))
|
17
17
|
|
18
|
-
Dir[SPEC_ROOT.join(
|
18
|
+
Dir[SPEC_ROOT.join("support/*.rb")].sort.each { |f| require f }
|
19
19
|
|
20
20
|
RSpec.configure do |config|
|
21
21
|
config.include AuditedSpecHelpers
|
22
|
-
config.use_transactional_fixtures = false if Rails.version.start_with?(
|
22
|
+
config.use_transactional_fixtures = false if Rails.version.start_with?("4.")
|
23
23
|
config.use_transactional_tests = false if config.respond_to?(:use_transactional_tests=)
|
24
24
|
end
|
@@ -1,13 +1,14 @@
|
|
1
|
-
require
|
2
|
-
require File.expand_path(
|
1
|
+
require "cgi"
|
2
|
+
require File.expand_path("../schema", __FILE__)
|
3
3
|
|
4
4
|
module Models
|
5
5
|
module ActiveRecord
|
6
6
|
class User < ::ActiveRecord::Base
|
7
7
|
audited except: :password
|
8
|
-
attribute :non_column_attr if Rails.version >=
|
8
|
+
attribute :non_column_attr if Rails.version >= "5.1"
|
9
9
|
attr_protected :logins if respond_to?(:attr_protected)
|
10
|
-
enum status: {
|
10
|
+
enum status: {active: 0, reliable: 1, banned: 2}
|
11
|
+
serialize :phone_numbers, Array
|
11
12
|
|
12
13
|
def name=(val)
|
13
14
|
write_attribute(:name, CGI.escapeHTML(val))
|
@@ -21,13 +22,28 @@ module Models
|
|
21
22
|
|
22
23
|
class UserOnlyPassword < ::ActiveRecord::Base
|
23
24
|
self.table_name = :users
|
24
|
-
attribute :non_column_attr if Rails.version >=
|
25
|
+
attribute :non_column_attr if Rails.version >= "5.1"
|
25
26
|
audited only: :password
|
26
27
|
end
|
27
28
|
|
29
|
+
class UserRedactedPassword < ::ActiveRecord::Base
|
30
|
+
self.table_name = :users
|
31
|
+
audited redacted: :password
|
32
|
+
end
|
33
|
+
|
34
|
+
class UserMultipleRedactedAttributes < ::ActiveRecord::Base
|
35
|
+
self.table_name = :users
|
36
|
+
audited redacted: [:password, :ssn]
|
37
|
+
end
|
38
|
+
|
39
|
+
class UserRedactedPasswordCustomRedaction < ::ActiveRecord::Base
|
40
|
+
self.table_name = :users
|
41
|
+
audited redacted: :password, redaction_value: ["My", "Custom", "Value", 7]
|
42
|
+
end
|
43
|
+
|
28
44
|
class CommentRequiredUser < ::ActiveRecord::Base
|
29
45
|
self.table_name = :users
|
30
|
-
audited comment_required: true
|
46
|
+
audited except: :password, comment_required: true
|
31
47
|
end
|
32
48
|
|
33
49
|
class OnCreateCommentRequiredUser < ::ActiveRecord::Base
|
@@ -96,36 +112,39 @@ module Models
|
|
96
112
|
end
|
97
113
|
|
98
114
|
class Owner < ::ActiveRecord::Base
|
99
|
-
self.table_name =
|
115
|
+
self.table_name = "users"
|
100
116
|
audited
|
101
117
|
has_associated_audits
|
102
118
|
has_many :companies, class_name: "OwnedCompany", dependent: :destroy
|
103
119
|
end
|
104
120
|
|
105
121
|
class OwnedCompany < ::ActiveRecord::Base
|
106
|
-
self.table_name =
|
122
|
+
self.table_name = "companies"
|
107
123
|
belongs_to :owner, class_name: "Owner"
|
108
124
|
attr_accessible :name, :owner if respond_to?(:attr_accessible) # declare attr_accessible before calling aaa
|
109
125
|
audited associated_with: :owner
|
110
126
|
end
|
111
127
|
|
128
|
+
class OwnedCompany::STICompany < OwnedCompany
|
129
|
+
end
|
130
|
+
|
112
131
|
class OnUpdateDestroy < ::ActiveRecord::Base
|
113
|
-
self.table_name =
|
132
|
+
self.table_name = "companies"
|
114
133
|
audited on: [:update, :destroy]
|
115
134
|
end
|
116
135
|
|
117
136
|
class OnCreateDestroy < ::ActiveRecord::Base
|
118
|
-
self.table_name =
|
137
|
+
self.table_name = "companies"
|
119
138
|
audited on: [:create, :destroy]
|
120
139
|
end
|
121
140
|
|
122
141
|
class OnCreateDestroyExceptName < ::ActiveRecord::Base
|
123
|
-
self.table_name =
|
142
|
+
self.table_name = "companies"
|
124
143
|
audited except: :name, on: [:create, :destroy]
|
125
144
|
end
|
126
145
|
|
127
146
|
class OnCreateUpdate < ::ActiveRecord::Base
|
128
|
-
self.table_name =
|
147
|
+
self.table_name = "companies"
|
129
148
|
audited on: [:create, :update]
|
130
149
|
end
|
131
150
|
end
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
class ChangeAuditedChangesTypeToJson < parent
|
1
|
+
class ChangeAuditedChangesTypeToJson < ActiveRecord::Migration[5.0]
|
3
2
|
def self.up
|
4
3
|
remove_column :audits, :audited_changes
|
5
4
|
add_column :audits, :audited_changes, :json
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
class ChangeAuditedChangesTypeToJsonb < parent
|
1
|
+
class ChangeAuditedChangesTypeToJsonb < ActiveRecord::Migration[5.0]
|
3
2
|
def self.up
|
4
3
|
remove_column :audits, :audited_changes
|
5
4
|
add_column :audits, :audited_changes, :jsonb
|
@@ -1,28 +1,33 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "active_record"
|
2
|
+
require "logger"
|
3
3
|
|
4
4
|
begin
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
raise Exception.new('No database name specified.') if db_name.blank?
|
9
|
-
if db_type == 'sqlite3'
|
10
|
-
db_file = Pathname.new(__FILE__).dirname.join(db_name)
|
11
|
-
db_file.unlink if db_file.file?
|
5
|
+
if ActiveRecord.version >= Gem::Version.new("6.1.0")
|
6
|
+
db_config = ActiveRecord::Base.configurations.configs_for(env_name: Rails.env).first
|
7
|
+
ActiveRecord::Tasks::DatabaseTasks.create(db_config)
|
12
8
|
else
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
db_config = ActiveRecord::Base.configurations[Rails.env].clone
|
10
|
+
db_type = db_config["adapter"]
|
11
|
+
db_name = db_config.delete("database")
|
12
|
+
raise StandardError.new("No database name specified.") if db_name.blank?
|
13
|
+
if db_type == "sqlite3"
|
14
|
+
db_file = Pathname.new(__FILE__).dirname.join(db_name)
|
15
|
+
db_file.unlink if db_file.file?
|
16
|
+
else
|
17
|
+
if defined?(JRUBY_VERSION)
|
18
|
+
db_config.symbolize_keys!
|
19
|
+
db_config[:configure_connection] = false
|
20
|
+
end
|
21
|
+
adapter = ActiveRecord::Base.send("#{db_type}_connection", db_config)
|
22
|
+
adapter.recreate_database db_name, db_config.slice("charset").symbolize_keys
|
23
|
+
adapter.disconnect!
|
16
24
|
end
|
17
|
-
adapter = ActiveRecord::Base.send("#{db_type}_connection", db_config)
|
18
|
-
adapter.recreate_database db_name, db_config.slice('charset').symbolize_keys
|
19
|
-
adapter.disconnect!
|
20
25
|
end
|
21
26
|
rescue => e
|
22
27
|
Kernel.warn e
|
23
28
|
end
|
24
29
|
|
25
|
-
logfile = Pathname.new(__FILE__).dirname.join(
|
30
|
+
logfile = Pathname.new(__FILE__).dirname.join("debug.log")
|
26
31
|
logfile.unlink if logfile.file?
|
27
32
|
ActiveRecord::Base.logger = Logger.new(logfile)
|
28
33
|
|
@@ -41,6 +46,8 @@ ActiveRecord::Schema.define do
|
|
41
46
|
t.column :created_at, :datetime
|
42
47
|
t.column :updated_at, :datetime
|
43
48
|
t.column :favourite_device, :string
|
49
|
+
t.column :ssn, :integer
|
50
|
+
t.column :phone_numbers, :string
|
44
51
|
end
|
45
52
|
|
46
53
|
create_table :companies do |t|
|
@@ -75,9 +82,9 @@ ActiveRecord::Schema.define do
|
|
75
82
|
t.column :created_at, :datetime
|
76
83
|
end
|
77
84
|
|
78
|
-
add_index :audits, [:auditable_id, :auditable_type], name:
|
79
|
-
add_index :audits, [:associated_id, :associated_type], name:
|
80
|
-
add_index :audits, [:user_id, :user_type], name:
|
85
|
+
add_index :audits, [:auditable_id, :auditable_type], name: "auditable_index"
|
86
|
+
add_index :audits, [:associated_id, :associated_type], name: "associated_index"
|
87
|
+
add_index :audits, [:user_id, :user_type], name: "user_index"
|
81
88
|
add_index :audits, :request_uuid
|
82
89
|
add_index :audits, :created_at
|
83
90
|
end
|