This repository was archived by the owner on Nov 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 44describe ActiveRecord ::Migrator do
55 with_phenix
66
7+ before { ActiveRecord ::Base . establish_connection ( RAILS_ENV . to_sym ) }
8+
79 it "migrates" do
810 migration_path = File . join ( File . dirname ( __FILE__ ) , "/migrations" )
11+
12+ refute ActiveRecord ::Base . current_shard_id
913 ActiveRecord ::Migrator . migrate ( migration_path )
14+
1015 ActiveRecord ::Base . on_all_shards do
1116 assert ActiveRecord ::Base . connection . public_send ( connection_exist_method , :schema_migrations ) , "Schema Migrations doesn't exist"
12- assert ActiveRecord ::Base . connection . public_send ( connection_exist_method , :accounts )
17+ assert ActiveRecord ::Base . connection . public_send ( connection_exist_method , :tickets )
18+ refute ActiveRecord ::Base . connection . public_send ( connection_exist_method , :accounts )
1319 assert ActiveRecord ::Base . connection . select_value ( "select version from schema_migrations where version = '20110824010216'" )
1420 assert ActiveRecord ::Base . connection . select_value ( "select version from schema_migrations where version = '20110829215912'" )
1521 end
1622
1723 ActiveRecord ::Base . on_all_shards do
1824 assert table_has_column? ( "tickets" , "sharded_column" )
19- assert !table_has_column? ( "accounts" , "non_sharded_column" )
2025 end
2126
2227 ActiveRecord ::Base . on_shard ( nil ) do
23- assert !table_has_column? ( "tickets" , "sharded_column" )
2428 assert table_has_column? ( "accounts" , "non_sharded_column" )
2529 end
2630
Original file line number Diff line number Diff line change 99 with_phenix
1010
1111 before do
12+ ActiveRecord ::Base . establish_connection ( RAILS_ENV . to_sym )
13+
1214 # create shard-specific columns
1315 ActiveRecord ::Migrator . migrations_paths = [ File . join ( File . dirname ( __FILE__ ) , "/migrations" ) ]
1416 ActiveRecord ::Migrator . migrate ( ActiveRecord ::Migrator . migrations_paths )
2527
2628 ActiveRecord ::Base . on_all_shards do
2729 assert ActiveRecord ::Base . connection . public_send ( connection_exist_method , :schema_migrations ) , "Schema Migrations doesn't exist"
28- assert ActiveRecord ::Base . connection . public_send ( connection_exist_method , :accounts )
2930 assert ActiveRecord ::Base . connection . select_value ( "select version from schema_migrations where version = '20110824010216'" )
3031 assert ActiveRecord ::Base . connection . select_value ( "select version from schema_migrations where version = '20110829215912'" )
3132 end
3233
3334 ActiveRecord ::Base . on_all_shards do
3435 assert table_has_column? ( "tickets" , "sharded_column" )
35- assert !table_has_column? ( "accounts" , "non_sharded_column" )
3636 end
3737
3838 ActiveRecord ::Base . on_shard ( nil ) do
39- assert !table_has_column? ( "tickets" , "sharded_column" )
4039 assert table_has_column? ( "accounts" , "non_sharded_column" )
4140 end
4241 end
You can’t perform that action at this time.
0 commit comments