stateful_models 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -1
- data/lib/generators/has_states/install/install_generator.rb +27 -9
- data/lib/generators/has_states/install/templates/create_has_states_states.rb.erb +1 -1
- data/lib/generators/has_states/install/templates/create_indexes_on_has_states_states.rb.erb +11 -0
- data/lib/has_states/configuration/model_configuration.rb +16 -0
- data/lib/has_states/state.rb +1 -2
- data/lib/has_states/stateable.rb +11 -8
- data/lib/has_states/version.rb +1 -1
- data/spec/dummy/Gemfile.lock +1 -1
- data/spec/dummy/config/initializers/has_states.rb +42 -39
- data/spec/dummy/db/migrate/20250114175939_create_indexes_on_has_states_states.rb +10 -0
- data/spec/dummy/db/schema.rb +5 -1
- data/spec/dummy/log/development.log +86 -0
- data/spec/dummy/log/test.log +5654 -0
- data/spec/dummy/storage/development.sqlite3 +0 -0
- data/spec/dummy/storage/test.sqlite3 +0 -0
- data/spec/generators/tmp/db/migrate/{20241223213845_create_has_states_states.rb → 20250114180401_create_has_states_states.rb} +1 -1
- data/spec/generators/tmp/db/migrate/20250114180401_create_indexes_on_has_states_states.rb +11 -0
- data/spec/has_states/state_spec.rb +34 -12
- data/spec/has_states/stateable_spec.rb +184 -0
- data/spec/rails_helper.rb +1 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8eb127e7632f183232f299936b44df5fc17f3208decb1da2863c802e8f4f2b69
|
4
|
+
data.tar.gz: bb6062a0184b16afa0a933f8e9c35fd9ca90ad1e8129b6de95ce6d1c1433ffb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b254a3c531422e64ec011fae308ab9999b812f1b85fea61bceb159656091ac9d9fab2723b5b0e8e0802944a1c92d29d3c94822e89f5cbc772cbf06218487f903
|
7
|
+
data.tar.gz: d27742123bce580f7813de17adcee9c5485d5bfc60e2a628fa8f068ce3a6874af8a0e372127b89b86454263738a8563c22e2fb8455fa2c3dda75ef6a6b5d33df
|
data/CHANGELOG.md
CHANGED
@@ -13,7 +13,18 @@
|
|
13
13
|
- Updated `add_state` method to support custom state classes
|
14
14
|
- Improved test coverage for inheritance and custom state types
|
15
15
|
|
16
|
-
## [0.
|
16
|
+
## [0.0.3] - 2024-01-14
|
17
|
+
|
18
|
+
- Adding current_state method
|
19
|
+
- Adding DB indexes for state lookups
|
20
|
+
- Adding query methods for state types on stateable (`stateable.state_type` and `stateable.state_types`)
|
21
|
+
|
22
|
+
## [0.0.2] - 2024-12-23
|
23
|
+
|
24
|
+
- Added test coverage
|
25
|
+
- Refactor of State model into a inheritable Base class
|
26
|
+
|
27
|
+
## [0.0.1] - 2024-12-21
|
17
28
|
|
18
29
|
- Initial release
|
19
30
|
- See READme.md
|
@@ -6,20 +6,38 @@ module HasStates
|
|
6
6
|
class InstallGenerator < Rails::Generators::Base
|
7
7
|
source_root File.expand_path('templates', __dir__)
|
8
8
|
|
9
|
+
TEMPLATES = [
|
10
|
+
{
|
11
|
+
source: 'create_has_states_states.rb.erb',
|
12
|
+
destination: "db/migrate/%s_create_has_states_states.rb"
|
13
|
+
},
|
14
|
+
{
|
15
|
+
source: 'create_indexes_on_has_states_states.rb.erb',
|
16
|
+
destination: "db/migrate/%s_create_indexes_on_has_states_states.rb"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
source: 'initializer.rb.erb',
|
20
|
+
destination: "config/initializers/has_states.rb"
|
21
|
+
}
|
22
|
+
].freeze
|
23
|
+
|
9
24
|
def install
|
10
25
|
puts 'Installing HasStates...'
|
11
26
|
|
12
|
-
template
|
13
|
-
|
14
|
-
|
15
|
-
)
|
16
|
-
|
17
|
-
template(
|
18
|
-
'initializer.rb.erb',
|
19
|
-
'config/initializers/has_states.rb'
|
20
|
-
)
|
27
|
+
TEMPLATES.each do |template|
|
28
|
+
make_template(**template)
|
29
|
+
end
|
21
30
|
|
22
31
|
puts 'HasStates installed successfully!'
|
23
32
|
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def make_template(source:, destination:)
|
37
|
+
timestamp = Time.now.utc.strftime('%Y%m%d%H%M%S')
|
38
|
+
destination = destination % timestamp if destination.include?('%s')
|
39
|
+
|
40
|
+
template(source, destination)
|
41
|
+
end
|
24
42
|
end
|
25
43
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
class CreateHasStatesStates < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
|
2
2
|
def change
|
3
3
|
create_table :has_states_states do |t|
|
4
4
|
t.string :type, null: false
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class CreateIndexesOnHasStatesStates < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
|
2
|
+
def change
|
3
|
+
change_table :has_states_states do |t|
|
4
|
+
t.index %i[stateable_id state_type]
|
5
|
+
t.index %i[stateable_id state_type status]
|
6
|
+
t.index %i[stateable_id state_type created_at]
|
7
|
+
t.index %i[stateable_id state_type status created_at]
|
8
|
+
t.index %i[stateable_type stateable_id]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -17,8 +17,12 @@ module HasStates
|
|
17
17
|
|
18
18
|
@state_types[name.to_s] = type
|
19
19
|
|
20
|
+
# HasStates::State model method generators
|
20
21
|
generate_state_type_scope(name)
|
21
22
|
generate_status_predicates(type.statuses)
|
23
|
+
|
24
|
+
# Included model method generators
|
25
|
+
generate_state_type_queries(name)
|
22
26
|
generate_state_type_status_predicates(name, type.statuses)
|
23
27
|
end
|
24
28
|
|
@@ -36,6 +40,18 @@ module HasStates
|
|
36
40
|
end
|
37
41
|
end
|
38
42
|
|
43
|
+
def generate_state_type_queries(state_type)
|
44
|
+
# Singular for finding the most recent state of a given type and status
|
45
|
+
@model_class.define_method(:"#{state_type}") do
|
46
|
+
states.where(state_type: state_type).order(created_at: :desc).first
|
47
|
+
end
|
48
|
+
|
49
|
+
# Plural for finding all states of a given type and status
|
50
|
+
@model_class.define_method(:"#{ActiveSupport::Inflector.pluralize(state_type)}") do
|
51
|
+
states.where(state_type: state_type).order(created_at: :desc)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
39
55
|
def generate_state_type_status_predicates(state_type, statuses)
|
40
56
|
statuses.each do |status_name|
|
41
57
|
@model_class.define_method(:"#{state_type}_#{status_name}?") do
|
data/lib/has_states/state.rb
CHANGED
data/lib/has_states/stateable.rb
CHANGED
@@ -6,18 +6,21 @@ module HasStates
|
|
6
6
|
|
7
7
|
included do
|
8
8
|
has_many :states, class_name: 'HasStates::Base',
|
9
|
-
|
10
|
-
|
9
|
+
as: :stateable,
|
10
|
+
dependent: :destroy
|
11
11
|
end
|
12
12
|
|
13
13
|
# Instance methods for managing states
|
14
14
|
def add_state(type, status: 'pending', metadata: {}, state_class: HasStates::State)
|
15
|
-
states.create!(
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
states.create!(type: state_class.name, state_type: type, status: status, metadata: metadata)
|
16
|
+
end
|
17
|
+
|
18
|
+
def current_state(type)
|
19
|
+
states.where(state_type: type).order(created_at: :desc).first
|
20
|
+
end
|
21
|
+
|
22
|
+
def current_states(type)
|
23
|
+
states.where(state_type: type).order(created_at: :desc)
|
21
24
|
end
|
22
25
|
end
|
23
26
|
end
|
data/lib/has_states/version.rb
CHANGED
data/spec/dummy/Gemfile.lock
CHANGED
@@ -1,42 +1,45 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
3
|
+
# Configure after the application is initialized
|
4
|
+
Rails.application.config.after_initialize do
|
5
|
+
HasStates.configure do |config|
|
6
|
+
# Configure your models and their state types below
|
7
|
+
#
|
8
|
+
# Example configuration:
|
9
|
+
#
|
10
|
+
config.configure_model User do |model|
|
11
|
+
# KYC state type with its allowed statuses
|
12
|
+
model.state_type :kyc do |type|
|
13
|
+
type.statuses = [
|
14
|
+
'pending', # Initial state
|
15
|
+
'documents_required', # Waiting for user documents
|
16
|
+
'under_review', # Documents being reviewed
|
17
|
+
'approved', # KYC process completed successfully
|
18
|
+
'rejected' # KYC process failed
|
19
|
+
]
|
20
|
+
end
|
21
|
+
|
22
|
+
# Onboarding state type with different statuses
|
23
|
+
model.state_type :onboarding do |type|
|
24
|
+
type.statuses = [
|
25
|
+
'pending', # Just started
|
26
|
+
'email_verified', # Email verification complete
|
27
|
+
'profile_complete', # User filled all required fields
|
28
|
+
'completed' # Onboarding finished
|
29
|
+
]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
#
|
33
|
+
# config.configure_model Company do |model|
|
34
|
+
# model.state_type :verification do |type|
|
35
|
+
# type.statuses = [
|
36
|
+
# 'pending',
|
37
|
+
# 'documents_submitted',
|
38
|
+
# 'under_review',
|
39
|
+
# 'verified',
|
40
|
+
# 'rejected'
|
41
|
+
# ]
|
42
|
+
# end
|
43
|
+
# end
|
44
|
+
end
|
42
45
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class CreateIndexesOnHasStatesStates < ActiveRecord::Migration[8.0]
|
2
|
+
def change
|
3
|
+
change_table :has_states_states do |t|
|
4
|
+
t.index %i[stateable_id state_type]
|
5
|
+
t.index %i[stateable_id state_type status]
|
6
|
+
t.index %i[stateable_id state_type created_at]
|
7
|
+
t.index %i[stateable_id state_type status created_at]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
#
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
12
12
|
|
13
|
-
ActiveRecord::Schema[8.0].define(version:
|
13
|
+
ActiveRecord::Schema[8.0].define(version: 2025_01_14_175939) do
|
14
14
|
create_table "companies", force: :cascade do |t|
|
15
15
|
t.string "name"
|
16
16
|
t.datetime "created_at", null: false
|
@@ -27,6 +27,10 @@ ActiveRecord::Schema[8.0].define(version: 2024_12_23_212128) do
|
|
27
27
|
t.datetime "completed_at"
|
28
28
|
t.datetime "created_at", null: false
|
29
29
|
t.datetime "updated_at", null: false
|
30
|
+
t.index ["stateable_id", "state_type", "created_at"], name: "idx_on_stateable_id_state_type_created_at_b5d09fb6ee"
|
31
|
+
t.index ["stateable_id", "state_type", "status", "created_at"], name: "idx_on_stateable_id_state_type_status_created_at_19e1cf37c2"
|
32
|
+
t.index ["stateable_id", "state_type", "status"], name: "idx_on_stateable_id_state_type_status_6d3d026e4d"
|
33
|
+
t.index ["stateable_id", "state_type"], name: "index_has_states_states_on_stateable_id_and_state_type"
|
30
34
|
t.index ["stateable_type", "stateable_id"], name: "index_has_states_states_on_stateable"
|
31
35
|
t.index ["stateable_type", "stateable_id"], name: "index_has_states_states_on_stateable_type_and_stateable_id"
|
32
36
|
t.index ["type", "stateable_id"], name: "index_has_states_states_on_type_and_stateable_id"
|
@@ -257,3 +257,89 @@ Migrating to CreateHasStatesStates (20241223212128)
|
|
257
257
|
[1m[36mTRANSACTION (0.1ms)[0m [1m[35mBEGIN immediate TRANSACTION /*application='Dummy'*/[0m
|
258
258
|
[1m[36mKYCState Create (0.6ms)[0m [1m[32mINSERT INTO "has_states_states" ("type", "state_type", "status", "metadata", "stateable_type", "stateable_id", "completed_at", "created_at", "updated_at") VALUES ('KYCState', 'kyc', 'pending', '{"document_type":"passport"}', 'User', 1, NULL, '2024-12-23 21:38:20.849253', '2024-12-23 21:38:20.849253') RETURNING "id" /*application='Dummy'*/[0m
|
259
259
|
[1m[36mTRANSACTION (14.6ms)[0m [1m[35mCOMMIT TRANSACTION /*application='Dummy'*/[0m
|
260
|
+
[1m[36mUser Load (0.1ms)[0m [1m[34mSELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/[0m
|
261
|
+
[1m[36mUser Load (0.3ms)[0m [1m[34mSELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/[0m
|
262
|
+
[1m[36mUser Load (0.1ms)[0m [1m[34mSELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/[0m
|
263
|
+
[1m[36mHasStates::Base Load (0.2ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'kyc' ORDER BY "has_states_states"."created_at" DESC LIMIT 1 /*application='Dummy'*/[0m
|
264
|
+
[1m[36mHasStates::Base Load (0.4ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'kyc' /* loading for pp */ ORDER BY "has_states_states"."created_at" DESC LIMIT 11 /*application='Dummy'*/[0m
|
265
|
+
[1m[36mHasStates::Base Load (0.1ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for inspect */ LIMIT 11 /*application='Dummy'*/[0m
|
266
|
+
[1m[36mHasStates::State Load (0.3ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."type" = 'HasStates::State' /* loading for pp */ LIMIT 11 /*application='Dummy'*/[0m
|
267
|
+
[1m[36mHasStates::Base Exists? (0.2ms)[0m [1m[34mSELECT 1 AS one FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'onboarding' AND "has_states_states"."status" = 'pending' LIMIT 1 /*application='Dummy'*/[0m
|
268
|
+
[1m[36mHasStates::Base Exists? (0.3ms)[0m [1m[34mSELECT 1 AS one FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'onboarding' AND "has_states_states"."status" = 'email_verified' LIMIT 1 /*application='Dummy'*/[0m
|
269
|
+
[1m[36mHasStates::Base Load (0.3ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for pp */ LIMIT 11 /*application='Dummy'*/[0m
|
270
|
+
[1m[36mHasStates::Base Load (0.1ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for inspect */ LIMIT 11 /*application='Dummy'*/[0m
|
271
|
+
[1m[36mHasStates::State Pluck (0.2ms)[0m [1m[34mSELECT "has_states_states"."type" FROM "has_states_states" WHERE "has_states_states"."type" = 'HasStates::State' /*application='Dummy'*/[0m
|
272
|
+
[1m[36mHasStates::State Load (0.3ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."type" = 'HasStates::State' /*application='Dummy'*/[0m
|
273
|
+
[1m[36mHasStates::Base Load (0.3ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for pp */ LIMIT 11 /*application='Dummy'*/[0m
|
274
|
+
[1m[36mHasStates::Base Load (0.2ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for inspect */ LIMIT 11 /*application='Dummy'*/[0m
|
275
|
+
[1m[36mHasStates::State Update All (0.2ms)[0m [1m[33mUPDATE "has_states_states" SET "type" = 'HasStates::State' WHERE "has_states_states"."type" = 'HasStates::State' AND "has_states_states"."type" = 'TestState' /*application='Dummy'*/[0m
|
276
|
+
[1m[36mHasStates::Base Load (0.2ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for pp */ LIMIT 11 /*application='Dummy'*/[0m
|
277
|
+
[1m[36mHasStates::Base Load (0.2ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for inspect */ LIMIT 11 /*application='Dummy'*/[0m
|
278
|
+
[1m[36mUser Load (0.1ms)[0m [1m[34mSELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/[0m
|
279
|
+
[1m[36mUser Load (0.2ms)[0m [1m[34mSELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/[0m
|
280
|
+
[1m[36mHasStates::Base Load (0.1ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for pp */ LIMIT 11 /*application='Dummy'*/[0m
|
281
|
+
[1m[36mHasStates::Base Load (0.2ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for inspect */ LIMIT 11 /*application='Dummy'*/[0m
|
282
|
+
[1m[36mUser Load (0.3ms)[0m [1m[34mSELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/[0m
|
283
|
+
[1m[36mHasStates::Base Load (0.3ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'kyc' ORDER BY "has_states_states"."created_at" DESC LIMIT 1 /*application='Dummy'*/[0m
|
284
|
+
[1m[36mUser Load (0.1ms)[0m [1m[34mSELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/[0m
|
285
|
+
[1m[36mHasStates::Base Load (0.1ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for pp */ LIMIT 11 /*application='Dummy'*/[0m
|
286
|
+
[1m[36mHasStates::Base Load (0.1ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for inspect */ LIMIT 11 /*application='Dummy'*/[0m
|
287
|
+
[1m[36mUser Load (0.2ms)[0m [1m[34mSELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/[0m
|
288
|
+
[1m[36mHasStates::Base Load (0.2ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'kyc' ORDER BY "has_states_states"."created_at" DESC LIMIT 1 /*application='Dummy'*/[0m
|
289
|
+
[1m[36mHasStates::State Update All (13.4ms)[0m [1m[33mUPDATE "has_states_states" SET "type" = 'HasStates::State' WHERE "has_states_states"."type" = 'HasStates::State' /*application='Dummy'*/[0m
|
290
|
+
[1m[36mUser Load (0.2ms)[0m [1m[34mSELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/[0m
|
291
|
+
[1m[36mHasStates::Base Load (0.1ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for pp */ LIMIT 11 /*application='Dummy'*/[0m
|
292
|
+
[1m[36mHasStates::Base Load (0.1ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for inspect */ LIMIT 11 /*application='Dummy'*/[0m
|
293
|
+
[1m[36mUser Load (0.2ms)[0m [1m[34mSELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/[0m
|
294
|
+
[1m[36mHasStates::Base Load (0.2ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'kyc' ORDER BY "has_states_states"."created_at" DESC LIMIT 1 /*application='Dummy'*/[0m
|
295
|
+
[1m[36mUser Load (0.2ms)[0m [1m[34mSELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/[0m
|
296
|
+
[1m[36mHasStates::Base Load (0.2ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'kyc' /* loading for pp */ ORDER BY "has_states_states"."created_at" DESC LIMIT 11 /*application='Dummy'*/[0m
|
297
|
+
[1m[36mHasStates::Base Load (0.1ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for inspect */ LIMIT 11 /*application='Dummy'*/[0m
|
298
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT id, type, state_type, status FROM has_states_states /*application='Dummy'*/[0m
|
299
|
+
[1m[36mHasStates::Base Update All (0.5ms)[0m [1m[33mUPDATE "has_states_states" SET "type" = 'HasStates::State' WHERE "has_states_states"."type" IN ('TestState', 'KYCState') /*application='Dummy'*/[0m
|
300
|
+
[1m[36mUser Load (0.2ms)[0m [1m[34mSELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/[0m
|
301
|
+
[1m[36mHasStates::Base Load (0.2ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'kyc' /* loading for pp */ ORDER BY "has_states_states"."created_at" DESC LIMIT 11 /*application='Dummy'*/[0m
|
302
|
+
[1m[36mUser Load (0.2ms)[0m [1m[34mSELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/[0m
|
303
|
+
[1m[36mHasStates::Base Load (0.3ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'kyc' ORDER BY "has_states_states"."created_at" DESC LIMIT 1 /*application='Dummy'*/[0m
|
304
|
+
[1m[36mUser Load (0.2ms)[0m [1m[34mSELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/[0m
|
305
|
+
[1m[36mUser Load (0.2ms)[0m [1m[34mSELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/[0m
|
306
|
+
[1m[36mHasStates::Base Load (0.2ms)[0m [1m[34mSELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'kyc' ORDER BY "has_states_states"."created_at" DESC LIMIT 1 /*application='Dummy'*/[0m
|
307
|
+
[1m[36mUser Load (0.2ms)[0m [1m[34mSELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/[0m
|
308
|
+
[1m[36mHasStates::Base Exists? (0.1ms)[0m [1m[34mSELECT 1 AS one FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'kyc' AND "has_states_states"."status" = 'approved' LIMIT 1 /*application='Dummy'*/[0m
|
309
|
+
[1m[36mUser Load (0.2ms)[0m [1m[34mSELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/[0m
|
310
|
+
[1m[36mUser Load (0.1ms)[0m [1m[34mSELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/[0m
|
311
|
+
[1m[36mHasStates::Base Exists? (0.1ms)[0m [1m[34mSELECT 1 AS one FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'kyc' AND "has_states_states"."status" = 'approved' LIMIT 1 /*application='Dummy'*/[0m
|
312
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT * FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = 'environment' ORDER BY "ar_internal_metadata"."key" ASC LIMIT 1 /*application='Dummy'*/[0m
|
313
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.0ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC /*application='Dummy'*/[0m
|
314
|
+
Migrating to CreateIndexesOnHasStatesStates (20250114175939)
|
315
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT * FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = 'environment' ORDER BY "ar_internal_metadata"."key" ASC LIMIT 1 /*application='Dummy'*/[0m
|
316
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.0ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC /*application='Dummy'*/[0m
|
317
|
+
Migrating to CreateIndexesOnHasStatesStates (20250114175939)
|
318
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mBEGIN immediate TRANSACTION /*application='Dummy'*/[0m
|
319
|
+
[1m[35m (0.6ms)[0m [1m[35mCREATE INDEX "index_has_states_states_on_stateable_id_and_state_type" ON "has_states_states" ("stateable_id", "state_type") /*application='Dummy'*/[0m
|
320
|
+
[1m[35m (0.1ms)[0m [1m[35mCREATE INDEX "idx_on_stateable_id_state_type_status_6d3d026e4d" ON "has_states_states" ("stateable_id", "state_type", "status") /*application='Dummy'*/[0m
|
321
|
+
[1m[35m (0.0ms)[0m [1m[35mCREATE INDEX "idx_on_stateable_id_state_type_created_at_b5d09fb6ee" ON "has_states_states" ("stateable_id", "state_type", "created_at") /*application='Dummy'*/[0m
|
322
|
+
[1m[35m (0.0ms)[0m [1m[35mCREATE INDEX "idx_on_stateable_id_state_type_status_created_at_19e1cf37c2" ON "has_states_states" ("stateable_id", "state_type", "status", "created_at") /*application='Dummy'*/[0m
|
323
|
+
[1m[35m (0.1ms)[0m [1m[35mCREATE INDEX "index_has_states_states_on_stateble_type_and_stateable_id" ON "has_states_states" ("stateble_type", "stateable_id") /*application='Dummy'*/[0m
|
324
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mROLLBACK TRANSACTION /*application='Dummy'*/[0m
|
325
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT * FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = 'environment' ORDER BY "ar_internal_metadata"."key" ASC LIMIT 1 /*application='Dummy'*/[0m
|
326
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.0ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC /*application='Dummy'*/[0m
|
327
|
+
Migrating to CreateIndexesOnHasStatesStates (20250114175939)
|
328
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mBEGIN immediate TRANSACTION /*application='Dummy'*/[0m
|
329
|
+
[1m[35m (0.7ms)[0m [1m[35mCREATE INDEX "index_has_states_states_on_stateable_id_and_state_type" ON "has_states_states" ("stateable_id", "state_type") /*application='Dummy'*/[0m
|
330
|
+
[1m[35m (0.1ms)[0m [1m[35mCREATE INDEX "idx_on_stateable_id_state_type_status_6d3d026e4d" ON "has_states_states" ("stateable_id", "state_type", "status") /*application='Dummy'*/[0m
|
331
|
+
[1m[35m (0.0ms)[0m [1m[35mCREATE INDEX "idx_on_stateable_id_state_type_created_at_b5d09fb6ee" ON "has_states_states" ("stateable_id", "state_type", "created_at") /*application='Dummy'*/[0m
|
332
|
+
[1m[35m (0.0ms)[0m [1m[35mCREATE INDEX "idx_on_stateable_id_state_type_status_created_at_19e1cf37c2" ON "has_states_states" ("stateable_id", "state_type", "status", "created_at") /*application='Dummy'*/[0m
|
333
|
+
[1m[35m (0.1ms)[0m [1m[35mCREATE INDEX "index_has_states_states_on_stateable_type_and_stateable_id" ON "has_states_states" ("stateable_type", "stateable_id") /*application='Dummy'*/[0m
|
334
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mROLLBACK TRANSACTION /*application='Dummy'*/[0m
|
335
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT * FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = 'environment' ORDER BY "ar_internal_metadata"."key" ASC LIMIT 1 /*application='Dummy'*/[0m
|
336
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.0ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC /*application='Dummy'*/[0m
|
337
|
+
Migrating to CreateIndexesOnHasStatesStates (20250114175939)
|
338
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mBEGIN immediate TRANSACTION /*application='Dummy'*/[0m
|
339
|
+
[1m[35m (0.7ms)[0m [1m[35mCREATE INDEX "index_has_states_states_on_stateable_id_and_state_type" ON "has_states_states" ("stateable_id", "state_type") /*application='Dummy'*/[0m
|
340
|
+
[1m[35m (0.1ms)[0m [1m[35mCREATE INDEX "idx_on_stateable_id_state_type_status_6d3d026e4d" ON "has_states_states" ("stateable_id", "state_type", "status") /*application='Dummy'*/[0m
|
341
|
+
[1m[35m (0.0ms)[0m [1m[35mCREATE INDEX "idx_on_stateable_id_state_type_created_at_b5d09fb6ee" ON "has_states_states" ("stateable_id", "state_type", "created_at") /*application='Dummy'*/[0m
|
342
|
+
[1m[35m (0.0ms)[0m [1m[35mCREATE INDEX "idx_on_stateable_id_state_type_status_created_at_19e1cf37c2" ON "has_states_states" ("stateable_id", "state_type", "status", "created_at") /*application='Dummy'*/[0m
|
343
|
+
[1m[36mActiveRecord::SchemaMigration Create (0.0ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ('20250114175939') RETURNING "version" /*application='Dummy'*/[0m
|
344
|
+
[1m[36mTRANSACTION (14.2ms)[0m [1m[35mCOMMIT TRANSACTION /*application='Dummy'*/[0m
|
345
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.0ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC /*application='Dummy'*/[0m
|