File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33class ApplicationRecord < ActiveRecord ::Base
44 self . abstract_class = true
5+
6+ connects_to database : { writing : :primary , reading : :primary }
57end
68
79class SecondDatabaseRecord < ActiveRecord ::Base
810 self . abstract_class = true
911
10- establish_connection : secondary
12+ connects_to database : { writing : : secondary, reading : :secondary }
1113end
1214
1315ActiveRecord ::Schema . define ( version : 0 ) do
@@ -151,6 +153,7 @@ class SecondDatabaseRecord < ActiveRecord::Base
151153 add_foreign_key ( :tag_hierarchies , :tags , column : 'descendant_id' , on_delete : :cascade )
152154end
153155
156+ SecondDatabaseRecord . establish_connection
154157SecondDatabaseRecord . connection_pool . with_connection do |connection |
155158 ActiveRecord ::Schema . define ( version : 0 ) do
156159 connection . create_table 'menu_items' , force : :cascade do |t |
You can’t perform that action at this time.
0 commit comments