ibm_db 3.0.5-x86-mingw32 → 5.0.5-x86-mingw32
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 +5 -5
 - data/CHANGES +4 -0
 - data/LICENSE +1 -1
 - data/ParameterizedQueries README +6 -6
 - data/README +38 -55
 - data/ext/Makefile +269 -0
 - data/ext/extconf.rb +34 -3
 - data/ext/gil_release_version +3 -0
 - data/ext/ibm_db-i386-mingw32.def +2 -0
 - data/ext/ibm_db.c +100 -108
 - data/ext/ibm_db.o +0 -0
 - data/ext/ibm_db.so +0 -0
 - data/ext/mkmf.log +110 -0
 - data/ext/ruby_ibm_db_cli.o +0 -0
 - data/ext/unicode_support_version +3 -0
 - data/lib/active_record/connection_adapters/ibm_db_adapter.rb +923 -527
 - data/lib/active_record/connection_adapters/ibmdb_adapter.rb +4 -1
 - data/lib/mswin32/ibm_db.rb +7 -39
 - data/lib/mswin32/rb2x/i386/ibm_db.so +0 -0
 - data/test/active_record/connection_adapters/fake_adapter.rb +8 -5
 - data/test/cases/adapter_test.rb +133 -58
 - data/test/cases/adapters/mysql2/active_schema_test.rb +193 -0
 - data/test/cases/adapters/mysql2/bind_parameter_test.rb +50 -0
 - data/test/cases/adapters/mysql2/boolean_test.rb +100 -0
 - data/test/cases/adapters/mysql2/case_sensitivity_test.rb +63 -0
 - data/test/cases/adapters/mysql2/charset_collation_test.rb +54 -0
 - data/test/cases/adapters/mysql2/connection_test.rb +210 -0
 - data/test/cases/adapters/mysql2/datetime_precision_quoting_test.rb +45 -0
 - data/test/cases/adapters/mysql2/enum_test.rb +26 -0
 - data/test/cases/adapters/mysql2/explain_test.rb +21 -0
 - data/test/cases/adapters/mysql2/json_test.rb +195 -0
 - data/test/cases/adapters/mysql2/mysql2_adapter_test.rb +83 -0
 - data/test/cases/adapters/mysql2/reserved_word_test.rb +152 -0
 - data/test/cases/adapters/mysql2/schema_migrations_test.rb +59 -0
 - data/test/cases/adapters/mysql2/schema_test.rb +126 -0
 - data/test/cases/adapters/mysql2/sp_test.rb +36 -0
 - data/test/cases/adapters/mysql2/sql_types_test.rb +14 -0
 - data/test/cases/adapters/mysql2/table_options_test.rb +42 -0
 - data/test/cases/adapters/mysql2/unsigned_type_test.rb +66 -0
 - data/test/cases/adapters/postgresql/active_schema_test.rb +98 -0
 - data/test/cases/adapters/postgresql/array_test.rb +339 -0
 - data/test/cases/adapters/postgresql/bit_string_test.rb +82 -0
 - data/test/cases/adapters/postgresql/bytea_test.rb +134 -0
 - data/test/cases/adapters/postgresql/case_insensitive_test.rb +26 -0
 - data/test/cases/adapters/postgresql/change_schema_test.rb +38 -0
 - data/test/cases/adapters/postgresql/cidr_test.rb +25 -0
 - data/test/cases/adapters/postgresql/citext_test.rb +78 -0
 - data/test/cases/adapters/postgresql/collation_test.rb +53 -0
 - data/test/cases/adapters/postgresql/composite_test.rb +132 -0
 - data/test/cases/adapters/postgresql/connection_test.rb +257 -0
 - data/test/cases/adapters/postgresql/datatype_test.rb +92 -0
 - data/test/cases/adapters/postgresql/domain_test.rb +47 -0
 - data/test/cases/adapters/postgresql/enum_test.rb +91 -0
 - data/test/cases/adapters/postgresql/explain_test.rb +20 -0
 - data/test/cases/adapters/postgresql/extension_migration_test.rb +63 -0
 - data/test/cases/adapters/postgresql/full_text_test.rb +44 -0
 - data/test/cases/adapters/postgresql/geometric_test.rb +378 -0
 - data/test/cases/adapters/postgresql/hstore_test.rb +382 -0
 - data/test/cases/adapters/postgresql/infinity_test.rb +69 -0
 - data/test/cases/adapters/postgresql/integer_test.rb +25 -0
 - data/test/cases/adapters/postgresql/json_test.rb +237 -0
 - data/test/cases/adapters/postgresql/ltree_test.rb +53 -0
 - data/test/cases/adapters/postgresql/money_test.rb +96 -0
 - data/test/cases/adapters/postgresql/network_test.rb +94 -0
 - data/test/cases/adapters/postgresql/numbers_test.rb +49 -0
 - data/test/cases/adapters/postgresql/postgresql_adapter_test.rb +405 -0
 - data/test/cases/adapters/postgresql/prepared_statements_test.rb +22 -0
 - data/test/cases/adapters/postgresql/quoting_test.rb +44 -0
 - data/test/cases/adapters/postgresql/range_test.rb +343 -0
 - data/test/cases/adapters/postgresql/referential_integrity_test.rb +111 -0
 - data/test/cases/adapters/postgresql/rename_table_test.rb +34 -0
 - data/test/cases/adapters/postgresql/schema_authorization_test.rb +119 -0
 - data/test/cases/adapters/postgresql/schema_test.rb +597 -0
 - data/test/cases/adapters/postgresql/serial_test.rb +154 -0
 - data/test/cases/adapters/postgresql/statement_pool_test.rb +41 -0
 - data/test/cases/adapters/postgresql/timestamp_test.rb +90 -0
 - data/test/cases/adapters/postgresql/type_lookup_test.rb +33 -0
 - data/test/cases/adapters/postgresql/utils_test.rb +62 -0
 - data/test/cases/adapters/postgresql/uuid_test.rb +294 -0
 - data/test/cases/adapters/postgresql/xml_test.rb +54 -0
 - data/test/cases/adapters/sqlite3/collation_test.rb +53 -0
 - data/test/cases/adapters/sqlite3/copy_table_test.rb +98 -0
 - data/test/cases/adapters/sqlite3/explain_test.rb +21 -0
 - data/test/cases/adapters/sqlite3/quoting_test.rb +101 -0
 - data/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb +441 -0
 - data/test/cases/adapters/sqlite3/sqlite3_create_folder_test.rb +24 -0
 - data/test/cases/adapters/sqlite3/statement_pool_test.rb +20 -0
 - data/test/cases/aggregations_test.rb +11 -1
 - data/test/cases/ar_schema_test.rb +35 -50
 - data/test/cases/associations/association_scope_test.rb +1 -6
 - data/test/cases/associations/belongs_to_associations_test.rb +122 -10
 - data/test/cases/associations/bidirectional_destroy_dependencies_test.rb +41 -0
 - data/test/cases/associations/callbacks_test.rb +5 -7
 - data/test/cases/associations/cascaded_eager_loading_test.rb +1 -1
 - data/test/cases/associations/eager_load_nested_include_test.rb +1 -3
 - data/test/cases/associations/eager_test.rb +158 -73
 - data/test/cases/associations/extension_test.rb +7 -2
 - data/test/cases/associations/has_and_belongs_to_many_associations_test.rb +64 -32
 - data/test/cases/associations/has_many_associations_test.rb +362 -43
 - data/test/cases/associations/has_many_through_associations_test.rb +108 -41
 - data/test/cases/associations/has_one_associations_test.rb +105 -8
 - data/test/cases/associations/has_one_through_associations_test.rb +6 -3
 - data/test/cases/associations/inner_join_association_test.rb +3 -3
 - data/test/cases/associations/inverse_associations_test.rb +38 -11
 - data/test/cases/associations/join_model_test.rb +59 -36
 - data/test/cases/associations/left_outer_join_association_test.rb +88 -0
 - data/test/cases/associations/nested_through_associations_test.rb +2 -2
 - data/test/cases/associations/required_test.rb +25 -5
 - data/test/cases/associations_test.rb +39 -34
 - data/test/cases/attribute_decorators_test.rb +9 -8
 - data/test/cases/attribute_methods/read_test.rb +5 -5
 - data/test/cases/attribute_methods_test.rb +97 -40
 - data/test/cases/attribute_set_test.rb +64 -4
 - data/test/cases/attribute_test.rb +84 -18
 - data/test/cases/attributes_test.rb +151 -34
 - data/test/cases/autosave_association_test.rb +149 -36
 - data/test/cases/base_test.rb +290 -241
 - data/test/cases/batches_test.rb +299 -22
 - data/test/cases/binary_test.rb +2 -10
 - data/test/cases/bind_parameter_test.rb +76 -66
 - data/test/cases/cache_key_test.rb +26 -0
 - data/test/cases/calculations_test.rb +167 -15
 - data/test/cases/callbacks_test.rb +161 -68
 - data/test/cases/coders/json_test.rb +15 -0
 - data/test/cases/collection_cache_key_test.rb +115 -0
 - data/test/cases/column_definition_test.rb +26 -57
 - data/test/cases/comment_test.rb +145 -0
 - data/test/cases/connection_adapters/adapter_leasing_test.rb +5 -3
 - data/test/cases/connection_adapters/connection_handler_test.rb +128 -21
 - data/test/cases/connection_adapters/connection_specification_test.rb +1 -1
 - data/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb +0 -38
 - data/test/cases/connection_adapters/mysql_type_lookup_test.rb +5 -1
 - data/test/cases/connection_adapters/schema_cache_test.rb +8 -3
 - data/test/cases/connection_adapters/type_lookup_test.rb +15 -7
 - data/test/cases/connection_management_test.rb +46 -56
 - data/test/cases/connection_pool_test.rb +195 -20
 - data/test/cases/connection_specification/resolver_test.rb +15 -0
 - data/test/cases/counter_cache_test.rb +10 -5
 - data/test/cases/custom_locking_test.rb +1 -1
 - data/test/cases/database_statements_test.rb +18 -3
 - data/test/cases/{invalid_date_test.rb → date_test.rb} +13 -1
 - data/test/cases/date_time_precision_test.rb +107 -0
 - data/test/cases/defaults_test.rb +85 -89
 - data/test/cases/dirty_test.rb +30 -52
 - data/test/cases/disconnected_test.rb +4 -2
 - data/test/cases/enum_test.rb +178 -24
 - data/test/cases/errors_test.rb +16 -0
 - data/test/cases/explain_test.rb +32 -21
 - data/test/cases/finder_test.rb +273 -148
 - data/test/cases/fixture_set/file_test.rb +18 -0
 - data/test/cases/fixtures_test.rb +112 -32
 - data/test/cases/forbidden_attributes_protection_test.rb +69 -3
 - data/test/cases/helper.rb +10 -16
 - data/test/cases/hot_compatibility_test.rb +89 -1
 - data/test/cases/inheritance_test.rb +284 -53
 - data/test/cases/integration_test.rb +23 -7
 - data/test/cases/invalid_connection_test.rb +4 -2
 - data/test/cases/invertible_migration_test.rb +124 -32
 - data/test/cases/json_serialization_test.rb +11 -2
 - data/test/cases/locking_test.rb +22 -6
 - data/test/cases/log_subscriber_test.rb +106 -17
 - data/test/cases/migration/change_schema_test.rb +60 -114
 - data/test/cases/migration/change_table_test.rb +34 -2
 - data/test/cases/migration/column_attributes_test.rb +7 -23
 - data/test/cases/migration/column_positioning_test.rb +8 -8
 - data/test/cases/migration/columns_test.rb +17 -11
 - data/test/cases/migration/command_recorder_test.rb +47 -2
 - data/test/cases/migration/compatibility_test.rb +118 -0
 - data/test/cases/migration/create_join_table_test.rb +21 -12
 - data/test/cases/migration/foreign_key_test.rb +52 -18
 - data/test/cases/migration/index_test.rb +14 -12
 - data/test/cases/migration/logger_test.rb +1 -1
 - data/test/cases/migration/pending_migrations_test.rb +0 -1
 - data/test/cases/migration/references_foreign_key_test.rb +59 -7
 - data/test/cases/migration/references_index_test.rb +4 -4
 - data/test/cases/migration/references_statements_test.rb +26 -6
 - data/test/cases/migration/rename_table_test.rb +25 -25
 - data/test/cases/migration_test.rb +279 -81
 - data/test/cases/migrator_test.rb +91 -8
 - data/test/cases/mixin_test.rb +0 -2
 - data/test/cases/modules_test.rb +3 -4
 - data/test/cases/multiparameter_attributes_test.rb +24 -2
 - data/test/cases/multiple_db_test.rb +11 -4
 - data/test/cases/nested_attributes_test.rb +61 -33
 - data/test/cases/persistence_test.rb +102 -10
 - data/test/cases/pooled_connections_test.rb +3 -3
 - data/test/cases/primary_keys_test.rb +170 -31
 - data/test/cases/query_cache_test.rb +216 -96
 - data/test/cases/quoting_test.rb +65 -19
 - data/test/cases/readonly_test.rb +2 -1
 - data/test/cases/reflection_test.rb +68 -22
 - data/test/cases/relation/delegation_test.rb +3 -8
 - data/test/cases/relation/merging_test.rb +10 -14
 - data/test/cases/relation/mutation_test.rb +42 -24
 - data/test/cases/relation/or_test.rb +92 -0
 - data/test/cases/relation/predicate_builder_test.rb +4 -2
 - data/test/cases/relation/record_fetch_warning_test.rb +40 -0
 - data/test/cases/relation/where_chain_test.rb +23 -99
 - data/test/cases/relation/where_clause_test.rb +182 -0
 - data/test/cases/relation/where_test.rb +45 -23
 - data/test/cases/relation_test.rb +67 -58
 - data/test/cases/relations_test.rb +249 -38
 - data/test/cases/result_test.rb +10 -0
 - data/test/cases/sanitize_test.rb +108 -15
 - data/test/cases/schema_dumper_test.rb +119 -125
 - data/test/cases/schema_loading_test.rb +52 -0
 - data/test/cases/scoping/default_scoping_test.rb +113 -39
 - data/test/cases/scoping/named_scoping_test.rb +46 -9
 - data/test/cases/scoping/relation_scoping_test.rb +47 -4
 - data/test/cases/secure_token_test.rb +32 -0
 - data/test/cases/serialization_test.rb +1 -1
 - data/test/cases/serialized_attribute_test.rb +93 -6
 - data/test/cases/statement_cache_test.rb +38 -0
 - data/test/cases/store_test.rb +2 -1
 - data/test/cases/suppressor_test.rb +63 -0
 - data/test/cases/tasks/database_tasks_test.rb +73 -9
 - data/test/cases/tasks/mysql_rake_test.rb +139 -118
 - data/test/cases/tasks/postgresql_rake_test.rb +60 -6
 - data/test/cases/tasks/sqlite_rake_test.rb +30 -3
 - data/test/cases/test_case.rb +28 -20
 - data/test/cases/test_fixtures_test.rb +36 -0
 - data/test/cases/time_precision_test.rb +103 -0
 - data/test/cases/timestamp_test.rb +44 -10
 - data/test/cases/touch_later_test.rb +121 -0
 - data/test/cases/transaction_callbacks_test.rb +128 -62
 - data/test/cases/transaction_isolation_test.rb +2 -2
 - data/test/cases/transactions_test.rb +61 -43
 - data/test/cases/type/adapter_specific_registry_test.rb +133 -0
 - data/test/cases/type/date_time_test.rb +14 -0
 - data/test/cases/type/integer_test.rb +2 -96
 - data/test/cases/type/string_test.rb +0 -14
 - data/test/cases/type_test.rb +39 -0
 - data/test/cases/types_test.rb +1 -118
 - data/test/cases/unconnected_test.rb +1 -1
 - data/test/cases/validations/absence_validation_test.rb +73 -0
 - data/test/cases/validations/association_validation_test.rb +13 -2
 - data/test/cases/validations/i18n_validation_test.rb +6 -10
 - data/test/cases/validations/length_validation_test.rb +62 -30
 - data/test/cases/validations/presence_validation_test.rb +36 -1
 - data/test/cases/validations/uniqueness_validation_test.rb +128 -37
 - data/test/cases/validations_repair_helper.rb +2 -6
 - data/test/cases/validations_test.rb +36 -7
 - data/test/cases/view_test.rb +102 -5
 - data/test/cases/yaml_serialization_test.rb +21 -26
 - data/test/config.example.yml +97 -0
 - data/test/fixtures/bad_posts.yml +9 -0
 - data/test/fixtures/books.yml +20 -0
 - data/test/fixtures/content.yml +3 -0
 - data/test/fixtures/content_positions.yml +3 -0
 - data/test/fixtures/dead_parrots.yml +5 -0
 - data/test/fixtures/live_parrots.yml +4 -0
 - data/test/fixtures/naked/yml/parrots.yml +2 -0
 - data/test/fixtures/naked/yml/trees.yml +3 -0
 - data/test/fixtures/nodes.yml +29 -0
 - data/test/fixtures/other_comments.yml +6 -0
 - data/test/fixtures/other_dogs.yml +2 -0
 - data/test/fixtures/other_posts.yml +7 -0
 - data/test/fixtures/price_estimates.yml +10 -1
 - data/test/fixtures/trees.yml +3 -0
 - data/test/migrations/10_urban/9_add_expressions.rb +1 -1
 - data/test/migrations/decimal/1_give_me_big_numbers.rb +1 -1
 - data/test/migrations/magic/1_currencies_have_symbols.rb +1 -1
 - data/test/migrations/missing/1000_people_have_middle_names.rb +2 -2
 - data/test/migrations/missing/1_people_have_last_names.rb +2 -2
 - data/test/migrations/missing/3_we_need_reminders.rb +2 -2
 - data/test/migrations/missing/4_innocent_jointable.rb +2 -2
 - data/test/migrations/rename/1_we_need_things.rb +2 -2
 - data/test/migrations/rename/2_rename_things.rb +2 -2
 - data/test/migrations/to_copy/1_people_have_hobbies.rb +1 -1
 - data/test/migrations/to_copy/2_people_have_descriptions.rb +1 -1
 - data/test/migrations/to_copy2/1_create_articles.rb +1 -1
 - data/test/migrations/to_copy2/2_create_comments.rb +1 -1
 - data/test/migrations/to_copy_with_name_collision/1_people_have_hobbies.rb +1 -1
 - data/test/migrations/to_copy_with_timestamps/20090101010101_people_have_hobbies.rb +1 -1
 - data/test/migrations/to_copy_with_timestamps/20090101010202_people_have_descriptions.rb +1 -1
 - data/test/migrations/to_copy_with_timestamps2/20090101010101_create_articles.rb +1 -1
 - data/test/migrations/to_copy_with_timestamps2/20090101010202_create_comments.rb +1 -1
 - data/test/migrations/valid/1_valid_people_have_last_names.rb +1 -1
 - data/test/migrations/valid/2_we_need_reminders.rb +2 -2
 - data/test/migrations/valid/3_innocent_jointable.rb +2 -2
 - data/test/migrations/valid_with_subdirectories/1_valid_people_have_last_names.rb +1 -1
 - data/test/migrations/valid_with_subdirectories/sub/2_we_need_reminders.rb +2 -2
 - data/test/migrations/valid_with_subdirectories/sub1/3_innocent_jointable.rb +2 -2
 - data/test/migrations/valid_with_timestamps/20100101010101_valid_with_timestamps_people_have_last_names.rb +1 -1
 - data/test/migrations/valid_with_timestamps/20100201010101_valid_with_timestamps_we_need_reminders.rb +1 -1
 - data/test/migrations/valid_with_timestamps/20100301010101_valid_with_timestamps_innocent_jointable.rb +1 -1
 - data/test/migrations/version_check/20131219224947_migration_version_check.rb +1 -1
 - data/test/models/admin/randomly_named_c1.rb +6 -2
 - data/test/models/aircraft.rb +1 -0
 - data/test/models/author.rb +4 -7
 - data/test/models/bird.rb +1 -1
 - data/test/models/book.rb +5 -0
 - data/test/models/bulb.rb +2 -1
 - data/test/models/car.rb +3 -0
 - data/test/models/cat.rb +10 -0
 - data/test/models/chef.rb +1 -0
 - data/test/models/club.rb +2 -0
 - data/test/models/comment.rb +17 -5
 - data/test/models/company.rb +4 -2
 - data/test/models/company_in_module.rb +1 -1
 - data/test/models/contact.rb +1 -1
 - data/test/models/content.rb +40 -0
 - data/test/models/customer.rb +8 -2
 - data/test/models/developer.rb +19 -0
 - data/test/models/face.rb +1 -1
 - data/test/models/guitar.rb +4 -0
 - data/test/models/hotel.rb +2 -0
 - data/test/models/member.rb +1 -0
 - data/test/models/member_detail.rb +4 -3
 - data/test/models/mentor.rb +3 -0
 - data/test/models/mocktail_designer.rb +2 -0
 - data/test/models/node.rb +5 -0
 - data/test/models/non_primary_key.rb +2 -0
 - data/test/models/notification.rb +3 -0
 - data/test/models/other_dog.rb +5 -0
 - data/test/models/owner.rb +4 -1
 - data/test/models/parrot.rb +6 -7
 - data/test/models/person.rb +0 -1
 - data/test/models/pet.rb +3 -0
 - data/test/models/pet_treasure.rb +6 -0
 - data/test/models/pirate.rb +3 -3
 - data/test/models/post.rb +18 -9
 - data/test/models/project.rb +9 -0
 - data/test/models/randomly_named_c1.rb +1 -1
 - data/test/models/recipe.rb +3 -0
 - data/test/models/ship.rb +8 -2
 - data/test/models/tag.rb +6 -0
 - data/test/models/topic.rb +2 -8
 - data/test/models/tree.rb +3 -0
 - data/test/models/tuning_peg.rb +4 -0
 - data/test/models/user.rb +14 -0
 - data/test/models/uuid_item.rb +6 -0
 - data/test/schema/mysql2_specific_schema.rb +33 -23
 - data/test/schema/oracle_specific_schema.rb +1 -4
 - data/test/schema/postgresql_specific_schema.rb +36 -124
 - data/test/schema/schema.rb +170 -65
 - data/test/schema/schema.rb.original +1057 -0
 - data/test/schema/sqlite_specific_schema.rb +1 -5
 - data/test/support/connection.rb +1 -0
 - data/test/support/schema_dumping_helper.rb +1 -1
 - data/test/support/yaml_compatibility_fixtures/rails_4_1.yml +22 -0
 - data/test/support/yaml_compatibility_fixtures/rails_4_2_0.yml +182 -0
 - metadata +146 -30
 - data/lib/mswin32/rb19x/ibm_db.so +0 -0
 - data/lib/mswin32/rb21x/i386/ibm_db.so +0 -0
 - data/lib/mswin32/rb22x/i386/ibm_db.so +0 -0
 - data/lib/mswin32/rb23x/i386/ibm_db.so +0 -0
 - data/test/cases/associations/deprecated_counter_cache_on_has_many_through_test.rb +0 -26
 - data/test/cases/attribute_methods/serialization_test.rb +0 -29
 - data/test/cases/migration/change_schema_test - Copy.rb +0 -448
 - data/test/cases/migration/foreign_key_test - Changed.rb +0 -325
 - data/test/cases/migration/table_and_index_test.rb +0 -24
 - data/test/cases/relation/where_test2.rb +0 -36
 - data/test/cases/type/decimal_test.rb +0 -56
 - data/test/cases/type/unsigned_integer_test.rb +0 -18
 - data/test/cases/xml_serialization_test.rb +0 -457
 - data/test/fixtures/naked/csv/accounts.csv +0 -1
 - data/test/schema/mysql_specific_schema.rb +0 -70
 
| 
         @@ -5,7 +5,7 @@ module ActiveRecord 
     | 
|
| 
       5 
5 
     | 
    
         
             
                class ReferencesStatementsTest < ActiveRecord::TestCase
         
     | 
| 
       6 
6 
     | 
    
         
             
                  include ActiveRecord::Migration::TestHelper
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
                  self. 
     | 
| 
      
 8 
     | 
    
         
            +
                  self.use_transactional_tests = false
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
                  def setup
         
     | 
| 
       11 
11 
     | 
    
         
             
                    super
         
     | 
| 
         @@ -30,14 +30,14 @@ module ActiveRecord 
     | 
|
| 
       30 
30 
     | 
    
         
             
                    assert column_exists?(table_name, :taggable_type, :string)
         
     | 
| 
       31 
31 
     | 
    
         
             
                  end
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
                  def  
     | 
| 
       34 
     | 
    
         
            -
                    add_reference table_name, :user, index:  
     | 
| 
       35 
     | 
    
         
            -
                     
     | 
| 
      
 33 
     | 
    
         
            +
                  def test_does_not_create_reference_id_index_if_index_is_false
         
     | 
| 
      
 34 
     | 
    
         
            +
                    add_reference table_name, :user, index: false
         
     | 
| 
      
 35 
     | 
    
         
            +
                    assert_not index_exists?(table_name, :user_id)
         
     | 
| 
       36 
36 
     | 
    
         
             
                  end
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
     | 
    
         
            -
                  def  
     | 
| 
      
 38 
     | 
    
         
            +
                  def test_create_reference_id_index_even_if_index_option_is_passed
         
     | 
| 
       39 
39 
     | 
    
         
             
                    add_reference table_name, :user
         
     | 
| 
       40 
     | 
    
         
            -
                     
     | 
| 
      
 40 
     | 
    
         
            +
                    assert index_exists?(table_name, :user_id)
         
     | 
| 
       41 
41 
     | 
    
         
             
                  end
         
     | 
| 
       42 
42 
     | 
    
         | 
| 
       43 
43 
     | 
    
         
             
                  def test_creates_polymorphic_index
         
     | 
| 
         @@ -50,11 +50,31 @@ module ActiveRecord 
     | 
|
| 
       50 
50 
     | 
    
         
             
                    assert column_exists?(table_name, :taggable_type, :string, default: 'Photo')
         
     | 
| 
       51 
51 
     | 
    
         
             
                  end
         
     | 
| 
       52 
52 
     | 
    
         | 
| 
      
 53 
     | 
    
         
            +
                  def test_creates_reference_type_column_with_not_null
         
     | 
| 
      
 54 
     | 
    
         
            +
                    connection.create_table table_name, force: true do |t|
         
     | 
| 
      
 55 
     | 
    
         
            +
                      t.references :taggable, null: false, polymorphic: true
         
     | 
| 
      
 56 
     | 
    
         
            +
                    end
         
     | 
| 
      
 57 
     | 
    
         
            +
                    assert column_exists?(table_name, :taggable_id, :integer, null: false)
         
     | 
| 
      
 58 
     | 
    
         
            +
                    assert column_exists?(table_name, :taggable_type, :string, null: false)
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                  def test_does_not_share_options_with_reference_type_column
         
     | 
| 
      
 62 
     | 
    
         
            +
                    add_reference table_name, :taggable, type: :integer, limit: 2, polymorphic: true
         
     | 
| 
      
 63 
     | 
    
         
            +
                    assert column_exists?(table_name, :taggable_id, :integer, limit: 2)
         
     | 
| 
      
 64 
     | 
    
         
            +
                    assert column_exists?(table_name, :taggable_type, :string)
         
     | 
| 
      
 65 
     | 
    
         
            +
                    assert_not column_exists?(table_name, :taggable_type, :string, limit: 2)
         
     | 
| 
      
 66 
     | 
    
         
            +
                  end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
       53 
68 
     | 
    
         
             
                  def test_creates_named_index
         
     | 
| 
       54 
69 
     | 
    
         
             
                    add_reference table_name, :tag, index: { name: 'index_taggings_on_tag_id' }
         
     | 
| 
       55 
70 
     | 
    
         
             
                    assert index_exists?(table_name, :tag_id, name: 'index_taggings_on_tag_id')
         
     | 
| 
       56 
71 
     | 
    
         
             
                  end
         
     | 
| 
       57 
72 
     | 
    
         | 
| 
      
 73 
     | 
    
         
            +
                  def test_creates_named_unique_index
         
     | 
| 
      
 74 
     | 
    
         
            +
                    add_reference table_name, :tag, index: { name: 'index_taggings_on_tag_id', unique: true }
         
     | 
| 
      
 75 
     | 
    
         
            +
                    assert index_exists?(table_name, :tag_id, name: 'index_taggings_on_tag_id', unique: true )
         
     | 
| 
      
 76 
     | 
    
         
            +
                  end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
       58 
78 
     | 
    
         
             
                  def test_creates_reference_id_with_specified_type
         
     | 
| 
       59 
79 
     | 
    
         
             
                    add_reference table_name, :user, type: :string
         
     | 
| 
       60 
80 
     | 
    
         
             
                    assert column_exists?(table_name, :user_id, :string)
         
     | 
| 
         @@ -5,7 +5,7 @@ module ActiveRecord 
     | 
|
| 
       5 
5 
     | 
    
         
             
                class RenameTableTest < ActiveRecord::TestCase
         
     | 
| 
       6 
6 
     | 
    
         
             
                  include ActiveRecord::Migration::TestHelper
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
                  self. 
     | 
| 
      
 8 
     | 
    
         
            +
                  self.use_transactional_tests = false
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
                  def setup
         
     | 
| 
       11 
11 
     | 
    
         
             
                    super
         
     | 
| 
         @@ -15,7 +15,7 @@ module ActiveRecord 
     | 
|
| 
       15 
15 
     | 
    
         
             
                  end
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
                  def teardown
         
     | 
| 
       18 
     | 
    
         
            -
                    rename_table :octopi, :test_models if connection.table_exists? :octopi
         
     | 
| 
      
 18 
     | 
    
         
            +
                    ActiveSupport::Deprecation.silence { rename_table :octopi, :test_models if connection.table_exists? :octopi }
         
     | 
| 
       19 
19 
     | 
    
         
             
                    super
         
     | 
| 
       20 
20 
     | 
    
         
             
                  end
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
         @@ -39,33 +39,35 @@ module ActiveRecord 
     | 
|
| 
       39 
39 
     | 
    
         
             
                    end
         
     | 
| 
       40 
40 
     | 
    
         
             
                  end
         
     | 
| 
       41 
41 
     | 
    
         | 
| 
       42 
     | 
    
         
            -
                   
     | 
| 
       43 
     | 
    
         
            -
                     
     | 
| 
      
 42 
     | 
    
         
            +
                  unless current_adapter?(:FbAdapter) # Firebird cannot rename tables
         
     | 
| 
      
 43 
     | 
    
         
            +
                    def test_rename_table
         
     | 
| 
      
 44 
     | 
    
         
            +
                      rename_table :test_models, :octopi
         
     | 
| 
       44 
45 
     | 
    
         | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
      
 46 
     | 
    
         
            +
                      connection.execute "INSERT INTO octopi (#{connection.quote_column_name('id')}, #{connection.quote_column_name('url')}) VALUES (1, 'http://www.foreverflying.com/octopus-black7.jpg')"
         
     | 
| 
       46 
47 
     | 
    
         | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
      
 48 
     | 
    
         
            +
                      assert_equal 'http://www.foreverflying.com/octopus-black7.jpg', connection.select_value("SELECT url FROM octopi WHERE id=1")
         
     | 
| 
      
 49 
     | 
    
         
            +
                    end
         
     | 
| 
       49 
50 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
      
 51 
     | 
    
         
            +
                    def test_rename_table_with_an_index
         
     | 
| 
      
 52 
     | 
    
         
            +
                      add_index :test_models, :url
         
     | 
| 
       52 
53 
     | 
    
         | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
      
 54 
     | 
    
         
            +
                      rename_table :test_models, :octopi
         
     | 
| 
       54 
55 
     | 
    
         | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
      
 56 
     | 
    
         
            +
                      connection.execute "INSERT INTO octopi (#{connection.quote_column_name('id')}, #{connection.quote_column_name('url')}) VALUES (1, 'http://www.foreverflying.com/octopus-black7.jpg')"
         
     | 
| 
       56 
57 
     | 
    
         | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
      
 58 
     | 
    
         
            +
                      assert_equal 'http://www.foreverflying.com/octopus-black7.jpg', connection.select_value("SELECT url FROM octopi WHERE id=1")
         
     | 
| 
      
 59 
     | 
    
         
            +
                      index = connection.indexes(:octopi).first
         
     | 
| 
      
 60 
     | 
    
         
            +
                      assert index.columns.include?("url")
         
     | 
| 
      
 61 
     | 
    
         
            +
                      assert_equal 'index_octopi_on_url', index.name
         
     | 
| 
      
 62 
     | 
    
         
            +
                    end
         
     | 
| 
       62 
63 
     | 
    
         | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
      
 64 
     | 
    
         
            +
                    def test_rename_table_does_not_rename_custom_named_index
         
     | 
| 
      
 65 
     | 
    
         
            +
                      add_index :test_models, :url, name: 'special_url_idx'
         
     | 
| 
       65 
66 
     | 
    
         | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
      
 67 
     | 
    
         
            +
                      rename_table :test_models, :octopi
         
     | 
| 
       67 
68 
     | 
    
         | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
      
 69 
     | 
    
         
            +
                      assert_equal ['special_url_idx'], connection.indexes(:octopi).map(&:name)
         
     | 
| 
      
 70 
     | 
    
         
            +
                    end
         
     | 
| 
       69 
71 
     | 
    
         
             
                  end
         
     | 
| 
       70 
72 
     | 
    
         | 
| 
       71 
73 
     | 
    
         
             
                  if current_adapter?(:PostgreSQLAdapter)
         
     | 
| 
         @@ -78,14 +80,12 @@ module ActiveRecord 
     | 
|
| 
       78 
80 
     | 
    
         
             
                    end
         
     | 
| 
       79 
81 
     | 
    
         | 
| 
       80 
82 
     | 
    
         
             
                    def test_renaming_table_doesnt_attempt_to_rename_non_existent_sequences
         
     | 
| 
       81 
     | 
    
         
            -
                      enable_extension!('uuid-ossp', connection)
         
     | 
| 
       82 
83 
     | 
    
         
             
                      connection.create_table :cats, id: :uuid
         
     | 
| 
       83 
84 
     | 
    
         
             
                      assert_nothing_raised { rename_table :cats, :felines }
         
     | 
| 
       84 
     | 
    
         
            -
                      assert connection.table_exists? :felines
         
     | 
| 
      
 85 
     | 
    
         
            +
                      ActiveSupport::Deprecation.silence { assert connection.table_exists? :felines }
         
     | 
| 
       85 
86 
     | 
    
         
             
                    ensure
         
     | 
| 
       86 
     | 
    
         
            -
                       
     | 
| 
       87 
     | 
    
         
            -
                      connection.drop_table : 
     | 
| 
       88 
     | 
    
         
            -
                      connection.drop_table :felines if connection.table_exists? :felines
         
     | 
| 
      
 87 
     | 
    
         
            +
                      connection.drop_table :cats, if_exists: true
         
     | 
| 
      
 88 
     | 
    
         
            +
                      connection.drop_table :felines, if_exists: true
         
     | 
| 
       89 
89 
     | 
    
         
             
                    end
         
     | 
| 
       90 
90 
     | 
    
         
             
                  end
         
     | 
| 
       91 
91 
     | 
    
         
             
                end
         
     | 
| 
         @@ -1,6 +1,7 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require  
     | 
| 
       2 
     | 
    
         
            -
            require  
     | 
| 
      
 1 
     | 
    
         
            +
            require 'cases/helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'cases/migration/helper'
         
     | 
| 
       3 
3 
     | 
    
         
             
            require 'bigdecimal/util'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'concurrent/atomic/count_down_latch'
         
     | 
| 
       4 
5 
     | 
    
         | 
| 
       5 
6 
     | 
    
         
             
            require 'models/person'
         
     | 
| 
       6 
7 
     | 
    
         
             
            require 'models/topic'
         
     | 
| 
         @@ -14,9 +15,9 @@ require MIGRATIONS_ROOT + "/decimal/1_give_me_big_numbers" 
     | 
|
| 
       14 
15 
     | 
    
         | 
| 
       15 
16 
     | 
    
         
             
            class BigNumber < ActiveRecord::Base
         
     | 
| 
       16 
17 
     | 
    
         
             
              unless current_adapter?(:PostgreSQLAdapter, :SQLite3Adapter)
         
     | 
| 
       17 
     | 
    
         
            -
                attribute :value_of_e,  
     | 
| 
      
 18 
     | 
    
         
            +
                attribute :value_of_e, :integer
         
     | 
| 
       18 
19 
     | 
    
         
             
              end
         
     | 
| 
       19 
     | 
    
         
            -
              attribute :my_house_population,  
     | 
| 
      
 20 
     | 
    
         
            +
              attribute :my_house_population, :integer
         
     | 
| 
       20 
21 
     | 
    
         
             
            end
         
     | 
| 
       21 
22 
     | 
    
         | 
| 
       22 
23 
     | 
    
         
             
            class Reminder < ActiveRecord::Base; end
         
     | 
| 
         @@ -24,18 +25,10 @@ class Reminder < ActiveRecord::Base; end 
     | 
|
| 
       24 
25 
     | 
    
         
             
            class Thing < ActiveRecord::Base; end
         
     | 
| 
       25 
26 
     | 
    
         | 
| 
       26 
27 
     | 
    
         
             
            class MigrationTest < ActiveRecord::TestCase
         
     | 
| 
       27 
     | 
    
         
            -
              self. 
     | 
| 
      
 28 
     | 
    
         
            +
              self.use_transactional_tests = false
         
     | 
| 
       28 
29 
     | 
    
         | 
| 
       29 
30 
     | 
    
         
             
              fixtures :people
         
     | 
| 
       30 
31 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
              if (current_adapter?(:IBM_DBAdapter))
         
     | 
| 
       32 
     | 
    
         
            -
                #Rename is supported only for server zOS 9 , DB2 COBRA and Informix
         
     | 
| 
       33 
     | 
    
         
            -
                server_type = ActiveRecord::Base.connection.servertype.class.name
         
     | 
| 
       34 
     | 
    
         
            -
                @ibm_db_rename_supported =  server_type.include?('::IBM_DB2_LUW_COBRA') ||
         
     | 
| 
       35 
     | 
    
         
            -
                                    server_type.class.name.include?('::IBM_IDS') ||
         
     | 
| 
       36 
     | 
    
         
            -
                  (server_type.include?('IBM_DB2_ZOS') && !server_type.include?('IBM_DB2_ZOS_8'))
         
     | 
| 
       37 
     | 
    
         
            -
              end
         
     | 
| 
       38 
     | 
    
         
            -
              
         
     | 
| 
       39 
32 
     | 
    
         
             
              def setup
         
     | 
| 
       40 
33 
     | 
    
         
             
                super
         
     | 
| 
       41 
34 
     | 
    
         
             
                %w(reminders people_reminders prefix_reminders_suffix p_things_s).each do |table|
         
     | 
| 
         @@ -76,6 +69,10 @@ class MigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       76 
69 
     | 
    
         
             
                ActiveRecord::Migration.verbose = @verbose_was
         
     | 
| 
       77 
70 
     | 
    
         
             
              end
         
     | 
| 
       78 
71 
     | 
    
         | 
| 
      
 72 
     | 
    
         
            +
              def test_migration_version_matches_component_version
         
     | 
| 
      
 73 
     | 
    
         
            +
                assert_equal ActiveRecord::VERSION::STRING.to_f, ActiveRecord::Migration.current_version
         
     | 
| 
      
 74 
     | 
    
         
            +
              end
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
       79 
76 
     | 
    
         
             
              def test_migrator_versions
         
     | 
| 
       80 
77 
     | 
    
         
             
                migrations_path = MIGRATIONS_ROOT + "/valid"
         
     | 
| 
       81 
78 
     | 
    
         
             
                old_path = ActiveRecord::Migrator.migrations_paths
         
     | 
| 
         @@ -83,22 +80,21 @@ class MigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       83 
80 
     | 
    
         | 
| 
       84 
81 
     | 
    
         
             
                ActiveRecord::Migrator.up(migrations_path)
         
     | 
| 
       85 
82 
     | 
    
         
             
                assert_equal 3, ActiveRecord::Migrator.current_version
         
     | 
| 
       86 
     | 
    
         
            -
                assert_equal 3, ActiveRecord::Migrator.last_version
         
     | 
| 
       87 
83 
     | 
    
         
             
                assert_equal false, ActiveRecord::Migrator.needs_migration?
         
     | 
| 
       88 
84 
     | 
    
         | 
| 
       89 
85 
     | 
    
         
             
                ActiveRecord::Migrator.down(MIGRATIONS_ROOT + "/valid")
         
     | 
| 
       90 
86 
     | 
    
         
             
                assert_equal 0, ActiveRecord::Migrator.current_version
         
     | 
| 
       91 
     | 
    
         
            -
                assert_equal 3, ActiveRecord::Migrator.last_version
         
     | 
| 
       92 
87 
     | 
    
         
             
                assert_equal true, ActiveRecord::Migrator.needs_migration?
         
     | 
| 
       93 
88 
     | 
    
         | 
| 
       94 
     | 
    
         
            -
                ActiveRecord::SchemaMigration.create!(: 
     | 
| 
      
 89 
     | 
    
         
            +
                ActiveRecord::SchemaMigration.create!(version: 3)
         
     | 
| 
       95 
90 
     | 
    
         
             
                assert_equal true, ActiveRecord::Migrator.needs_migration?
         
     | 
| 
       96 
91 
     | 
    
         
             
              ensure
         
     | 
| 
       97 
92 
     | 
    
         
             
                ActiveRecord::Migrator.migrations_paths = old_path
         
     | 
| 
       98 
93 
     | 
    
         
             
              end
         
     | 
| 
       99 
94 
     | 
    
         | 
| 
       100 
95 
     | 
    
         
             
              def test_migration_detection_without_schema_migration_table
         
     | 
| 
       101 
     | 
    
         
            -
                ActiveRecord::Base.connection.drop_table 
     | 
| 
      
 96 
     | 
    
         
            +
                ActiveRecord::Base.connection.drop_table 'schema_migrations'
         
     | 
| 
      
 97 
     | 
    
         
            +
            	#, if_exists: true
         
     | 
| 
       102 
98 
     | 
    
         | 
| 
       103 
99 
     | 
    
         
             
                migrations_path = MIGRATIONS_ROOT + "/valid"
         
     | 
| 
       104 
100 
     | 
    
         
             
                old_path = ActiveRecord::Migrator.migrations_paths
         
     | 
| 
         @@ -123,14 +119,10 @@ class MigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       123 
119 
     | 
    
         
             
              end
         
     | 
| 
       124 
120 
     | 
    
         | 
| 
       125 
121 
     | 
    
         
             
              def test_migration_version
         
     | 
| 
       126 
     | 
    
         
            -
                ActiveRecord::Migrator.run(:up, MIGRATIONS_ROOT + "/version_check", 20131219224947)
         
     | 
| 
      
 122 
     | 
    
         
            +
                assert_nothing_raised { ActiveRecord::Migrator.run(:up, MIGRATIONS_ROOT + "/version_check", 20131219224947) }
         
     | 
| 
       127 
123 
     | 
    
         
             
              end
         
     | 
| 
       128 
124 
     | 
    
         | 
| 
       129 
125 
     | 
    
         
             
              def test_create_table_with_force_true_does_not_drop_nonexisting_table
         
     | 
| 
       130 
     | 
    
         
            -
                if Person.connection.table_exists?(:testings2)
         
     | 
| 
       131 
     | 
    
         
            -
                  Person.connection.drop_table :testings2
         
     | 
| 
       132 
     | 
    
         
            -
                end
         
     | 
| 
       133 
     | 
    
         
            -
             
     | 
| 
       134 
126 
     | 
    
         
             
                # using a copy as we need the drop_table method to
         
     | 
| 
       135 
127 
     | 
    
         
             
                # continue to work for the ensure block of the test
         
     | 
| 
       136 
128 
     | 
    
         
             
                temp_conn = Person.connection.dup
         
     | 
| 
         @@ -141,20 +133,17 @@ class MigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       141 
133 
     | 
    
         
             
                  t.column :foo, :string
         
     | 
| 
       142 
134 
     | 
    
         
             
                end
         
     | 
| 
       143 
135 
     | 
    
         
             
              ensure
         
     | 
| 
       144 
     | 
    
         
            -
                Person.connection.drop_table :testings2 
     | 
| 
       145 
     | 
    
         
            -
             
     | 
| 
       146 
     | 
    
         
            -
             
     | 
| 
       147 
     | 
    
         
            -
              def connection
         
     | 
| 
       148 
     | 
    
         
            -
                ActiveRecord::Base.connection
         
     | 
| 
      
 136 
     | 
    
         
            +
                Person.connection.drop_table :testings2
         
     | 
| 
      
 137 
     | 
    
         
            +
            	#, if_exists: true
         
     | 
| 
       149 
138 
     | 
    
         
             
              end
         
     | 
| 
       150 
139 
     | 
    
         | 
| 
       151 
140 
     | 
    
         
             
              def test_migration_instance_has_connection
         
     | 
| 
       152 
     | 
    
         
            -
                migration = Class.new(ActiveRecord::Migration).new
         
     | 
| 
       153 
     | 
    
         
            -
                assert_equal connection, migration.connection
         
     | 
| 
      
 141 
     | 
    
         
            +
                migration = Class.new(ActiveRecord::Migration::Current).new
         
     | 
| 
      
 142 
     | 
    
         
            +
                assert_equal ActiveRecord::Base.connection, migration.connection
         
     | 
| 
       154 
143 
     | 
    
         
             
              end
         
     | 
| 
       155 
144 
     | 
    
         | 
| 
       156 
145 
     | 
    
         
             
              def test_method_missing_delegates_to_connection
         
     | 
| 
       157 
     | 
    
         
            -
                migration = Class.new(ActiveRecord::Migration) {
         
     | 
| 
      
 146 
     | 
    
         
            +
                migration = Class.new(ActiveRecord::Migration::Current) {
         
     | 
| 
       158 
147 
     | 
    
         
             
                  def connection
         
     | 
| 
       159 
148 
     | 
    
         
             
                    Class.new {
         
     | 
| 
       160 
149 
     | 
    
         
             
                      def create_table; "hi mom!"; end
         
     | 
| 
         @@ -170,6 +159,7 @@ class MigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       170 
159 
     | 
    
         | 
| 
       171 
160 
     | 
    
         
             
                assert !BigNumber.table_exists?
         
     | 
| 
       172 
161 
     | 
    
         
             
                GiveMeBigNumbers.up
         
     | 
| 
      
 162 
     | 
    
         
            +
                BigNumber.reset_column_information
         
     | 
| 
       173 
163 
     | 
    
         | 
| 
       174 
164 
     | 
    
         
             
                assert BigNumber.create(
         
     | 
| 
       175 
165 
     | 
    
         
             
                  :bank_balance => 1586.43,
         
     | 
| 
         @@ -190,17 +180,9 @@ class MigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       190 
180 
     | 
    
         | 
| 
       191 
181 
     | 
    
         
             
                # TODO: set world_population >= 2**62 to cover 64-bit platforms and test
         
     | 
| 
       192 
182 
     | 
    
         
             
                # is_a?(Bignum)
         
     | 
| 
       193 
     | 
    
         
            -
                 
     | 
| 
       194 
     | 
    
         
            -
                    assert_kind_of Integer, b.world_population
         
     | 
| 
       195 
     | 
    
         
            -
                else
         
     | 
| 
       196 
     | 
    
         
            -
                    assert_kind_of BigDecimal, b.world_population
         
     | 
| 
       197 
     | 
    
         
            -
                end
         
     | 
| 
      
 183 
     | 
    
         
            +
                assert_kind_of Integer, b.world_population
         
     | 
| 
       198 
184 
     | 
    
         
             
                assert_equal 6000000000, b.world_population
         
     | 
| 
       199 
     | 
    
         
            -
                 
     | 
| 
       200 
     | 
    
         
            -
                    assert_kind_of Fixnum, b.my_house_population
         
     | 
| 
       201 
     | 
    
         
            -
                else
         
     | 
| 
       202 
     | 
    
         
            -
                    assert_kind_of BigDecimal, b.my_house_population
         
     | 
| 
       203 
     | 
    
         
            -
                end
         
     | 
| 
      
 185 
     | 
    
         
            +
                assert_kind_of Integer, b.my_house_population
         
     | 
| 
       204 
186 
     | 
    
         
             
                assert_equal 3, b.my_house_population
         
     | 
| 
       205 
187 
     | 
    
         
             
                assert_kind_of BigDecimal, b.bank_balance
         
     | 
| 
       206 
188 
     | 
    
         
             
                assert_equal BigDecimal("1586.43"), b.bank_balance
         
     | 
| 
         @@ -216,8 +198,6 @@ class MigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       216 
198 
     | 
    
         
             
                  # of 0, they take on the compile-time limit for precision and scale,
         
     | 
| 
       217 
199 
     | 
    
         
             
                  # so the following should succeed unless you have used really wacky
         
     | 
| 
       218 
200 
     | 
    
         
             
                  # compilation options
         
     | 
| 
       219 
     | 
    
         
            -
                  # - SQLite2 has the default behavior of preserving all data sent in,
         
     | 
| 
       220 
     | 
    
         
            -
                  # so this happens there too
         
     | 
| 
       221 
201 
     | 
    
         
             
                  assert_kind_of BigDecimal, b.value_of_e
         
     | 
| 
       222 
202 
     | 
    
         
             
                  assert_equal BigDecimal("2.7182818284590452353602875"), b.value_of_e
         
     | 
| 
       223 
203 
     | 
    
         
             
                elsif current_adapter?(:SQLite3Adapter)
         
     | 
| 
         @@ -226,11 +206,7 @@ class MigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       226 
206 
     | 
    
         
             
                  assert_in_delta BigDecimal("2.71828182845905"), b.value_of_e, 0.00000000000001
         
     | 
| 
       227 
207 
     | 
    
         
             
                else
         
     | 
| 
       228 
208 
     | 
    
         
             
                  # - SQL standard is an integer
         
     | 
| 
       229 
     | 
    
         
            -
                   
     | 
| 
       230 
     | 
    
         
            -
                      assert_kind_of Fixnum, b.value_of_e
         
     | 
| 
       231 
     | 
    
         
            -
                  else
         
     | 
| 
       232 
     | 
    
         
            -
                      assert_kind_of BigDecimal, b.value_of_e
         
     | 
| 
       233 
     | 
    
         
            -
                  end
         
     | 
| 
      
 209 
     | 
    
         
            +
                  assert_kind_of Integer, b.value_of_e
         
     | 
| 
       234 
210 
     | 
    
         
             
                  assert_equal 2, b.value_of_e
         
     | 
| 
       235 
211 
     | 
    
         
             
                end
         
     | 
| 
       236 
212 
     | 
    
         | 
| 
         @@ -254,7 +230,7 @@ class MigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       254 
230 
     | 
    
         
             
                assert_raise(ActiveRecord::StatementInvalid) { Reminder.first }
         
     | 
| 
       255 
231 
     | 
    
         
             
              end
         
     | 
| 
       256 
232 
     | 
    
         | 
| 
       257 
     | 
    
         
            -
              class MockMigration < ActiveRecord::Migration
         
     | 
| 
      
 233 
     | 
    
         
            +
              class MockMigration < ActiveRecord::Migration::Current
         
     | 
| 
       258 
234 
     | 
    
         
             
                attr_reader :went_up, :went_down
         
     | 
| 
       259 
235 
     | 
    
         
             
                def initialize
         
     | 
| 
       260 
236 
     | 
    
         
             
                  @went_up   = false
         
     | 
| 
         @@ -296,7 +272,7 @@ class MigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       296 
272 
     | 
    
         
             
                def test_migrator_one_up_with_exception_and_rollback
         
     | 
| 
       297 
273 
     | 
    
         
             
                  assert_no_column Person, :last_name
         
     | 
| 
       298 
274 
     | 
    
         | 
| 
       299 
     | 
    
         
            -
                  migration = Class.new(ActiveRecord::Migration) {
         
     | 
| 
      
 275 
     | 
    
         
            +
                  migration = Class.new(ActiveRecord::Migration::Current) {
         
     | 
| 
       300 
276 
     | 
    
         
             
                    def version; 100 end
         
     | 
| 
       301 
277 
     | 
    
         
             
                    def migrate(x)
         
     | 
| 
       302 
278 
     | 
    
         
             
                      add_column "people", "last_name", :string
         
     | 
| 
         @@ -317,7 +293,7 @@ class MigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       317 
293 
     | 
    
         
             
                def test_migrator_one_up_with_exception_and_rollback_using_run
         
     | 
| 
       318 
294 
     | 
    
         
             
                  assert_no_column Person, :last_name
         
     | 
| 
       319 
295 
     | 
    
         | 
| 
       320 
     | 
    
         
            -
                  migration = Class.new(ActiveRecord::Migration) {
         
     | 
| 
      
 296 
     | 
    
         
            +
                  migration = Class.new(ActiveRecord::Migration::Current) {
         
     | 
| 
       321 
297 
     | 
    
         
             
                    def version; 100 end
         
     | 
| 
       322 
298 
     | 
    
         
             
                    def migrate(x)
         
     | 
| 
       323 
299 
     | 
    
         
             
                      add_column "people", "last_name", :string
         
     | 
| 
         @@ -329,7 +305,7 @@ class MigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       329 
305 
     | 
    
         | 
| 
       330 
306 
     | 
    
         
             
                  e = assert_raise(StandardError) { migrator.run }
         
     | 
| 
       331 
307 
     | 
    
         | 
| 
       332 
     | 
    
         
            -
                  assert_equal "An error has occurred, this  
     | 
| 
      
 308 
     | 
    
         
            +
                  assert_equal "An error has occurred, this and all later migrations canceled:\n\nSomething broke", e.message
         
     | 
| 
       333 
309 
     | 
    
         | 
| 
       334 
310 
     | 
    
         
             
                  assert_no_column Person, :last_name,
         
     | 
| 
       335 
311 
     | 
    
         
             
                    "On error, the Migrator should revert schema changes but it did not."
         
     | 
| 
         @@ -338,7 +314,7 @@ class MigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       338 
314 
     | 
    
         
             
                def test_migration_without_transaction
         
     | 
| 
       339 
315 
     | 
    
         
             
                  assert_no_column Person, :last_name
         
     | 
| 
       340 
316 
     | 
    
         | 
| 
       341 
     | 
    
         
            -
                  migration = Class.new(ActiveRecord::Migration) {
         
     | 
| 
      
 317 
     | 
    
         
            +
                  migration = Class.new(ActiveRecord::Migration::Current) {
         
     | 
| 
       342 
318 
     | 
    
         
             
                    self.disable_ddl_transaction!
         
     | 
| 
       343 
319 
     | 
    
         | 
| 
       344 
320 
     | 
    
         
             
                    def version; 101 end
         
     | 
| 
         @@ -382,6 +358,110 @@ class MigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       382 
358 
     | 
    
         
             
                Reminder.reset_table_name
         
     | 
| 
       383 
359 
     | 
    
         
             
              end
         
     | 
| 
       384 
360 
     | 
    
         | 
| 
      
 361 
     | 
    
         
            +
              def test_internal_metadata_table_name
         
     | 
| 
      
 362 
     | 
    
         
            +
                original_internal_metadata_table_name = ActiveRecord::Base.internal_metadata_table_name
         
     | 
| 
      
 363 
     | 
    
         
            +
             
     | 
| 
      
 364 
     | 
    
         
            +
                assert_equal "ar_internal_metadata", ActiveRecord::InternalMetadata.table_name
         
     | 
| 
      
 365 
     | 
    
         
            +
                ActiveRecord::Base.table_name_prefix = "p_"
         
     | 
| 
      
 366 
     | 
    
         
            +
                ActiveRecord::Base.table_name_suffix = "_s"
         
     | 
| 
      
 367 
     | 
    
         
            +
                Reminder.reset_table_name
         
     | 
| 
      
 368 
     | 
    
         
            +
                assert_equal "p_ar_internal_metadata_s", ActiveRecord::InternalMetadata.table_name
         
     | 
| 
      
 369 
     | 
    
         
            +
                ActiveRecord::Base.internal_metadata_table_name = "changed"
         
     | 
| 
      
 370 
     | 
    
         
            +
                Reminder.reset_table_name
         
     | 
| 
      
 371 
     | 
    
         
            +
                assert_equal "p_changed_s", ActiveRecord::InternalMetadata.table_name
         
     | 
| 
      
 372 
     | 
    
         
            +
                ActiveRecord::Base.table_name_prefix = ""
         
     | 
| 
      
 373 
     | 
    
         
            +
                ActiveRecord::Base.table_name_suffix = ""
         
     | 
| 
      
 374 
     | 
    
         
            +
                Reminder.reset_table_name
         
     | 
| 
      
 375 
     | 
    
         
            +
                assert_equal "changed", ActiveRecord::InternalMetadata.table_name
         
     | 
| 
      
 376 
     | 
    
         
            +
              ensure
         
     | 
| 
      
 377 
     | 
    
         
            +
                ActiveRecord::Base.internal_metadata_table_name = original_internal_metadata_table_name
         
     | 
| 
      
 378 
     | 
    
         
            +
                Reminder.reset_table_name
         
     | 
| 
      
 379 
     | 
    
         
            +
              end
         
     | 
| 
      
 380 
     | 
    
         
            +
             
     | 
| 
      
 381 
     | 
    
         
            +
              def test_internal_metadata_stores_environment
         
     | 
| 
      
 382 
     | 
    
         
            +
                current_env     = ActiveRecord::ConnectionHandling::DEFAULT_ENV.call
         
     | 
| 
      
 383 
     | 
    
         
            +
                migrations_path = MIGRATIONS_ROOT + "/valid"
         
     | 
| 
      
 384 
     | 
    
         
            +
                old_path        = ActiveRecord::Migrator.migrations_paths
         
     | 
| 
      
 385 
     | 
    
         
            +
                ActiveRecord::Migrator.migrations_paths = migrations_path
         
     | 
| 
      
 386 
     | 
    
         
            +
             
     | 
| 
      
 387 
     | 
    
         
            +
                ActiveRecord::Migrator.up(migrations_path)
         
     | 
| 
      
 388 
     | 
    
         
            +
                assert_equal current_env, ActiveRecord::InternalMetadata[:environment]
         
     | 
| 
      
 389 
     | 
    
         
            +
             
     | 
| 
      
 390 
     | 
    
         
            +
                original_rails_env  = ENV["RAILS_ENV"]
         
     | 
| 
      
 391 
     | 
    
         
            +
                original_rack_env   = ENV["RACK_ENV"]
         
     | 
| 
      
 392 
     | 
    
         
            +
                ENV["RAILS_ENV"]    = ENV["RACK_ENV"] = "foofoo"
         
     | 
| 
      
 393 
     | 
    
         
            +
                new_env     = ActiveRecord::ConnectionHandling::DEFAULT_ENV.call
         
     | 
| 
      
 394 
     | 
    
         
            +
             
     | 
| 
      
 395 
     | 
    
         
            +
                refute_equal current_env, new_env
         
     | 
| 
      
 396 
     | 
    
         
            +
             
     | 
| 
      
 397 
     | 
    
         
            +
                sleep 1 # mysql by default does not store fractional seconds in the database
         
     | 
| 
      
 398 
     | 
    
         
            +
                ActiveRecord::Migrator.up(migrations_path)
         
     | 
| 
      
 399 
     | 
    
         
            +
                assert_equal new_env, ActiveRecord::InternalMetadata[:environment]
         
     | 
| 
      
 400 
     | 
    
         
            +
              ensure
         
     | 
| 
      
 401 
     | 
    
         
            +
                ActiveRecord::Migrator.migrations_paths = old_path
         
     | 
| 
      
 402 
     | 
    
         
            +
                ENV["RAILS_ENV"] = original_rails_env
         
     | 
| 
      
 403 
     | 
    
         
            +
                ENV["RACK_ENV"]  = original_rack_env
         
     | 
| 
      
 404 
     | 
    
         
            +
              end
         
     | 
| 
      
 405 
     | 
    
         
            +
             
     | 
| 
      
 406 
     | 
    
         
            +
             
     | 
| 
      
 407 
     | 
    
         
            +
              def test_migration_sets_internal_metadata_even_when_fully_migrated
         
     | 
| 
      
 408 
     | 
    
         
            +
                current_env     = ActiveRecord::ConnectionHandling::DEFAULT_ENV.call
         
     | 
| 
      
 409 
     | 
    
         
            +
                migrations_path = MIGRATIONS_ROOT + "/valid"
         
     | 
| 
      
 410 
     | 
    
         
            +
                old_path        = ActiveRecord::Migrator.migrations_paths
         
     | 
| 
      
 411 
     | 
    
         
            +
                ActiveRecord::Migrator.migrations_paths = migrations_path
         
     | 
| 
      
 412 
     | 
    
         
            +
             
     | 
| 
      
 413 
     | 
    
         
            +
                ActiveRecord::Migrator.up(migrations_path)
         
     | 
| 
      
 414 
     | 
    
         
            +
                assert_equal current_env, ActiveRecord::InternalMetadata[:environment]
         
     | 
| 
      
 415 
     | 
    
         
            +
             
     | 
| 
      
 416 
     | 
    
         
            +
                original_rails_env  = ENV["RAILS_ENV"]
         
     | 
| 
      
 417 
     | 
    
         
            +
                original_rack_env   = ENV["RACK_ENV"]
         
     | 
| 
      
 418 
     | 
    
         
            +
                ENV["RAILS_ENV"]    = ENV["RACK_ENV"] = "foofoo"
         
     | 
| 
      
 419 
     | 
    
         
            +
                new_env     = ActiveRecord::ConnectionHandling::DEFAULT_ENV.call
         
     | 
| 
      
 420 
     | 
    
         
            +
             
     | 
| 
      
 421 
     | 
    
         
            +
                refute_equal current_env, new_env
         
     | 
| 
      
 422 
     | 
    
         
            +
             
     | 
| 
      
 423 
     | 
    
         
            +
                sleep 1 # mysql by default does not store fractional seconds in the database
         
     | 
| 
      
 424 
     | 
    
         
            +
             
     | 
| 
      
 425 
     | 
    
         
            +
                ActiveRecord::Migrator.up(migrations_path)
         
     | 
| 
      
 426 
     | 
    
         
            +
                assert_equal new_env, ActiveRecord::InternalMetadata[:environment]
         
     | 
| 
      
 427 
     | 
    
         
            +
              ensure
         
     | 
| 
      
 428 
     | 
    
         
            +
                ActiveRecord::Migrator.migrations_paths = old_path
         
     | 
| 
      
 429 
     | 
    
         
            +
                ENV["RAILS_ENV"] = original_rails_env
         
     | 
| 
      
 430 
     | 
    
         
            +
                ENV["RACK_ENV"]  = original_rack_env
         
     | 
| 
      
 431 
     | 
    
         
            +
              end
         
     | 
| 
      
 432 
     | 
    
         
            +
             
     | 
| 
      
 433 
     | 
    
         
            +
              def test_internal_metadata_stores_environment_when_other_data_exists
         
     | 
| 
      
 434 
     | 
    
         
            +
                ActiveRecord::InternalMetadata.delete_all
         
     | 
| 
      
 435 
     | 
    
         
            +
                ActiveRecord::InternalMetadata[:foo]  = 'bar'
         
     | 
| 
      
 436 
     | 
    
         
            +
             
     | 
| 
      
 437 
     | 
    
         
            +
                current_env     = ActiveRecord::ConnectionHandling::DEFAULT_ENV.call
         
     | 
| 
      
 438 
     | 
    
         
            +
                migrations_path = MIGRATIONS_ROOT + "/valid"
         
     | 
| 
      
 439 
     | 
    
         
            +
                old_path        = ActiveRecord::Migrator.migrations_paths
         
     | 
| 
      
 440 
     | 
    
         
            +
                ActiveRecord::Migrator.migrations_paths = migrations_path
         
     | 
| 
      
 441 
     | 
    
         
            +
             
     | 
| 
      
 442 
     | 
    
         
            +
                current_env     = ActiveRecord::ConnectionHandling::DEFAULT_ENV.call
         
     | 
| 
      
 443 
     | 
    
         
            +
                ActiveRecord::Migrator.up(migrations_path)
         
     | 
| 
      
 444 
     | 
    
         
            +
                assert_equal current_env, ActiveRecord::InternalMetadata[:environment]
         
     | 
| 
      
 445 
     | 
    
         
            +
                assert_equal 'bar', ActiveRecord::InternalMetadata[:foo]
         
     | 
| 
      
 446 
     | 
    
         
            +
              ensure
         
     | 
| 
      
 447 
     | 
    
         
            +
                ActiveRecord::Migrator.migrations_paths = old_path
         
     | 
| 
      
 448 
     | 
    
         
            +
              end
         
     | 
| 
      
 449 
     | 
    
         
            +
             
     | 
| 
      
 450 
     | 
    
         
            +
              def test_rename_internal_metadata_table
         
     | 
| 
      
 451 
     | 
    
         
            +
                original_internal_metadata_table_name = ActiveRecord::Base.internal_metadata_table_name
         
     | 
| 
      
 452 
     | 
    
         
            +
             
     | 
| 
      
 453 
     | 
    
         
            +
                ActiveRecord::Base.internal_metadata_table_name = "active_record_internal_metadatas"
         
     | 
| 
      
 454 
     | 
    
         
            +
                Reminder.reset_table_name
         
     | 
| 
      
 455 
     | 
    
         
            +
             
     | 
| 
      
 456 
     | 
    
         
            +
                ActiveRecord::Base.internal_metadata_table_name = original_internal_metadata_table_name
         
     | 
| 
      
 457 
     | 
    
         
            +
                Reminder.reset_table_name
         
     | 
| 
      
 458 
     | 
    
         
            +
             
     | 
| 
      
 459 
     | 
    
         
            +
                assert_equal "ar_internal_metadata", ActiveRecord::InternalMetadata.table_name
         
     | 
| 
      
 460 
     | 
    
         
            +
              ensure
         
     | 
| 
      
 461 
     | 
    
         
            +
                ActiveRecord::Base.internal_metadata_table_name = original_internal_metadata_table_name
         
     | 
| 
      
 462 
     | 
    
         
            +
                Reminder.reset_table_name
         
     | 
| 
      
 463 
     | 
    
         
            +
              end
         
     | 
| 
      
 464 
     | 
    
         
            +
             
     | 
| 
       385 
465 
     | 
    
         
             
              def test_proper_table_name_on_migration
         
     | 
| 
       386 
466 
     | 
    
         
             
                reminder_class = new_isolated_reminder_class
         
     | 
| 
       387 
467 
     | 
    
         
             
                migration = ActiveRecord::Migration.new
         
     | 
| 
         @@ -417,6 +497,7 @@ class MigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       417 
497 
     | 
    
         
             
                Thing.reset_table_name
         
     | 
| 
       418 
498 
     | 
    
         
             
                Thing.reset_sequence_name
         
     | 
| 
       419 
499 
     | 
    
         
             
                WeNeedThings.up
         
     | 
| 
      
 500 
     | 
    
         
            +
                Thing.reset_column_information
         
     | 
| 
       420 
501 
     | 
    
         | 
| 
       421 
502 
     | 
    
         
             
                assert Thing.create("content" => "hello world")
         
     | 
| 
       422 
503 
     | 
    
         
             
                assert_equal "hello world", Thing.first.content
         
     | 
| 
         @@ -436,6 +517,7 @@ class MigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       436 
517 
     | 
    
         
             
                ActiveRecord::Base.table_name_suffix = '_suffix'
         
     | 
| 
       437 
518 
     | 
    
         
             
                Reminder.reset_table_name
         
     | 
| 
       438 
519 
     | 
    
         
             
                Reminder.reset_sequence_name
         
     | 
| 
      
 520 
     | 
    
         
            +
                Reminder.reset_column_information
         
     | 
| 
       439 
521 
     | 
    
         
             
                WeNeedReminders.up
         
     | 
| 
       440 
522 
     | 
    
         
             
                assert Reminder.create("content" => "hello world", "remind_at" => Time.now)
         
     | 
| 
       441 
523 
     | 
    
         
             
                assert_equal "hello world", Reminder.first.content
         
     | 
| 
         @@ -447,8 +529,6 @@ class MigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       447 
529 
     | 
    
         
             
              end
         
     | 
| 
       448 
530 
     | 
    
         | 
| 
       449 
531 
     | 
    
         
             
              def test_create_table_with_binary_column
         
     | 
| 
       450 
     | 
    
         
            -
                Person.connection.drop_table :binary_testings rescue nil
         
     | 
| 
       451 
     | 
    
         
            -
             
     | 
| 
       452 
532 
     | 
    
         
             
                assert_nothing_raised {
         
     | 
| 
       453 
533 
     | 
    
         
             
                  Person.connection.create_table :binary_testings do |t|
         
     | 
| 
       454 
534 
     | 
    
         
             
                    t.column "data", :binary, :null => false
         
     | 
| 
         @@ -459,13 +539,13 @@ class MigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       459 
539 
     | 
    
         
             
                data_column = columns.detect { |c| c.name == "data" }
         
     | 
| 
       460 
540 
     | 
    
         | 
| 
       461 
541 
     | 
    
         
             
                assert_nil data_column.default
         
     | 
| 
       462 
     | 
    
         
            -
             
     | 
| 
       463 
     | 
    
         
            -
                Person.connection.drop_table :binary_testings 
     | 
| 
      
 542 
     | 
    
         
            +
              ensure
         
     | 
| 
      
 543 
     | 
    
         
            +
                Person.connection.drop_table :binary_testings
         
     | 
| 
      
 544 
     | 
    
         
            +
            	#, if_exists: true
         
     | 
| 
       464 
545 
     | 
    
         
             
              end
         
     | 
| 
       465 
546 
     | 
    
         | 
| 
       466 
547 
     | 
    
         
             
              unless mysql_enforcing_gtid_consistency?
         
     | 
| 
       467 
548 
     | 
    
         
             
                def test_create_table_with_query
         
     | 
| 
       468 
     | 
    
         
            -
                  Person.connection.drop_table :table_from_query_testings rescue nil
         
     | 
| 
       469 
549 
     | 
    
         
             
                  Person.connection.create_table(:person, force: true)
         
     | 
| 
       470 
550 
     | 
    
         | 
| 
       471 
551 
     | 
    
         
             
                  Person.connection.create_table :table_from_query_testings, as: "SELECT id FROM person"
         
     | 
| 
         @@ -473,12 +553,11 @@ class MigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       473 
553 
     | 
    
         
             
                  columns = Person.connection.columns(:table_from_query_testings)
         
     | 
| 
       474 
554 
     | 
    
         
             
                  assert_equal 1, columns.length
         
     | 
| 
       475 
555 
     | 
    
         
             
                  assert_equal "id", columns.first.name
         
     | 
| 
       476 
     | 
    
         
            -
             
     | 
| 
      
 556 
     | 
    
         
            +
                ensure
         
     | 
| 
       477 
557 
     | 
    
         
             
                  Person.connection.drop_table :table_from_query_testings rescue nil
         
     | 
| 
       478 
558 
     | 
    
         
             
                end
         
     | 
| 
       479 
559 
     | 
    
         | 
| 
       480 
560 
     | 
    
         
             
                def test_create_table_with_query_from_relation
         
     | 
| 
       481 
     | 
    
         
            -
                  Person.connection.drop_table :table_from_query_testings rescue nil
         
     | 
| 
       482 
561 
     | 
    
         
             
                  Person.connection.create_table(:person, force: true)
         
     | 
| 
       483 
562 
     | 
    
         | 
| 
       484 
563 
     | 
    
         
             
                  Person.connection.create_table :table_from_query_testings, as: Person.select(:id)
         
     | 
| 
         @@ -486,11 +565,29 @@ class MigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       486 
565 
     | 
    
         
             
                  columns = Person.connection.columns(:table_from_query_testings)
         
     | 
| 
       487 
566 
     | 
    
         
             
                  assert_equal 1, columns.length
         
     | 
| 
       488 
567 
     | 
    
         
             
                  assert_equal "id", columns.first.name
         
     | 
| 
       489 
     | 
    
         
            -
             
     | 
| 
      
 568 
     | 
    
         
            +
                ensure
         
     | 
| 
       490 
569 
     | 
    
         
             
                  Person.connection.drop_table :table_from_query_testings rescue nil
         
     | 
| 
       491 
570 
     | 
    
         
             
                end
         
     | 
| 
       492 
571 
     | 
    
         
             
              end
         
     | 
| 
       493 
572 
     | 
    
         | 
| 
      
 573 
     | 
    
         
            +
              if current_adapter?(:SQLite3Adapter)
         
     | 
| 
      
 574 
     | 
    
         
            +
                def test_allows_sqlite3_rollback_on_invalid_column_type
         
     | 
| 
      
 575 
     | 
    
         
            +
                  Person.connection.create_table :something, force: true do |t|
         
     | 
| 
      
 576 
     | 
    
         
            +
                    t.column :number, :integer
         
     | 
| 
      
 577 
     | 
    
         
            +
                    t.column :name, :string
         
     | 
| 
      
 578 
     | 
    
         
            +
                    t.column :foo, :bar
         
     | 
| 
      
 579 
     | 
    
         
            +
                  end
         
     | 
| 
      
 580 
     | 
    
         
            +
                  assert Person.connection.column_exists?(:something, :foo)
         
     | 
| 
      
 581 
     | 
    
         
            +
                  assert_nothing_raised { Person.connection.remove_column :something, :foo, :bar }
         
     | 
| 
      
 582 
     | 
    
         
            +
                  assert !Person.connection.column_exists?(:something, :foo)
         
     | 
| 
      
 583 
     | 
    
         
            +
                  assert Person.connection.column_exists?(:something, :name)
         
     | 
| 
      
 584 
     | 
    
         
            +
                  assert Person.connection.column_exists?(:something, :number)
         
     | 
| 
      
 585 
     | 
    
         
            +
                ensure
         
     | 
| 
      
 586 
     | 
    
         
            +
                  Person.connection.drop_table :something
         
     | 
| 
      
 587 
     | 
    
         
            +
            	  #, if_exists: true
         
     | 
| 
      
 588 
     | 
    
         
            +
                end
         
     | 
| 
      
 589 
     | 
    
         
            +
              end
         
     | 
| 
      
 590 
     | 
    
         
            +
             
     | 
| 
       494 
591 
     | 
    
         
             
              if current_adapter? :OracleAdapter
         
     | 
| 
       495 
592 
     | 
    
         
             
                def test_create_table_with_custom_sequence_name
         
     | 
| 
       496 
593 
     | 
    
         
             
                  # table name is 29 chars, the standard sequence name will
         
     | 
| 
         @@ -528,24 +625,105 @@ class MigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       528 
625 
     | 
    
         
             
                end
         
     | 
| 
       529 
626 
     | 
    
         
             
              end
         
     | 
| 
       530 
627 
     | 
    
         | 
| 
       531 
     | 
    
         
            -
              if current_adapter?(: 
     | 
| 
       532 
     | 
    
         
            -
                def  
     | 
| 
       533 
     | 
    
         
            -
                   
     | 
| 
       534 
     | 
    
         
            -
                  assert_raise(ActiveRecord::ActiveRecordError, "integer limit didn't raise") do
         
     | 
| 
      
 628 
     | 
    
         
            +
              if current_adapter?(:Mysql2Adapter, :PostgreSQLAdapter)
         
     | 
| 
      
 629 
     | 
    
         
            +
                def test_out_of_range_integer_limit_should_raise
         
     | 
| 
      
 630 
     | 
    
         
            +
                  e = assert_raise(ActiveRecord::ActiveRecordError, "integer limit didn't raise") do
         
     | 
| 
       535 
631 
     | 
    
         
             
                    Person.connection.create_table :test_integer_limits, :force => true do |t|
         
     | 
| 
       536 
632 
     | 
    
         
             
                      t.column :bigone, :integer, :limit => 10
         
     | 
| 
       537 
633 
     | 
    
         
             
                    end
         
     | 
| 
       538 
634 
     | 
    
         
             
                  end
         
     | 
| 
       539 
635 
     | 
    
         | 
| 
       540 
     | 
    
         
            -
                   
     | 
| 
       541 
     | 
    
         
            -
             
     | 
| 
       542 
     | 
    
         
            -
             
     | 
| 
       543 
     | 
    
         
            -
             
     | 
| 
       544 
     | 
    
         
            -
             
     | 
| 
      
 636 
     | 
    
         
            +
                  assert_match(/No integer type has byte size 10/, e.message)
         
     | 
| 
      
 637 
     | 
    
         
            +
                ensure
         
     | 
| 
      
 638 
     | 
    
         
            +
                  Person.connection.drop_table :test_integer_limits
         
     | 
| 
      
 639 
     | 
    
         
            +
            	  #, if_exists: true
         
     | 
| 
      
 640 
     | 
    
         
            +
                end
         
     | 
| 
      
 641 
     | 
    
         
            +
              end
         
     | 
| 
      
 642 
     | 
    
         
            +
             
     | 
| 
      
 643 
     | 
    
         
            +
              if current_adapter?(:Mysql2Adapter)
         
     | 
| 
      
 644 
     | 
    
         
            +
                def test_out_of_range_text_limit_should_raise
         
     | 
| 
      
 645 
     | 
    
         
            +
                  e = assert_raise(ActiveRecord::ActiveRecordError, "text limit didn't raise") do
         
     | 
| 
      
 646 
     | 
    
         
            +
                    Person.connection.create_table :test_text_limits, force: true do |t|
         
     | 
| 
      
 647 
     | 
    
         
            +
                      t.text :bigtext, limit: 0xfffffffff
         
     | 
| 
       545 
648 
     | 
    
         
             
                    end
         
     | 
| 
       546 
649 
     | 
    
         
             
                  end
         
     | 
| 
       547 
650 
     | 
    
         | 
| 
       548 
     | 
    
         
            -
                   
     | 
| 
      
 651 
     | 
    
         
            +
                  assert_match(/No text type has byte length #{0xfffffffff}/, e.message)
         
     | 
| 
      
 652 
     | 
    
         
            +
                ensure
         
     | 
| 
      
 653 
     | 
    
         
            +
                  Person.connection.drop_table :test_text_limits
         
     | 
| 
      
 654 
     | 
    
         
            +
            	  #, if_exists: true
         
     | 
| 
      
 655 
     | 
    
         
            +
                end
         
     | 
| 
      
 656 
     | 
    
         
            +
              end
         
     | 
| 
      
 657 
     | 
    
         
            +
             
     | 
| 
      
 658 
     | 
    
         
            +
              if ActiveRecord::Base.connection.supports_advisory_locks?
         
     | 
| 
      
 659 
     | 
    
         
            +
                def test_migrator_generates_valid_lock_id
         
     | 
| 
      
 660 
     | 
    
         
            +
                  migration = Class.new(ActiveRecord::Migration::Current).new
         
     | 
| 
      
 661 
     | 
    
         
            +
                  migrator = ActiveRecord::Migrator.new(:up, [migration], 100)
         
     | 
| 
      
 662 
     | 
    
         
            +
             
     | 
| 
      
 663 
     | 
    
         
            +
                  lock_id = migrator.send(:generate_migrator_advisory_lock_id)
         
     | 
| 
      
 664 
     | 
    
         
            +
             
     | 
| 
      
 665 
     | 
    
         
            +
                  assert ActiveRecord::Base.connection.get_advisory_lock(lock_id),
         
     | 
| 
      
 666 
     | 
    
         
            +
                    "the Migrator should have generated a valid lock id, but it didn't"
         
     | 
| 
      
 667 
     | 
    
         
            +
                  assert ActiveRecord::Base.connection.release_advisory_lock(lock_id),
         
     | 
| 
      
 668 
     | 
    
         
            +
                    "the Migrator should have generated a valid lock id, but it didn't"
         
     | 
| 
      
 669 
     | 
    
         
            +
                end
         
     | 
| 
      
 670 
     | 
    
         
            +
             
     | 
| 
      
 671 
     | 
    
         
            +
                def test_generate_migrator_advisory_lock_id
         
     | 
| 
      
 672 
     | 
    
         
            +
                  # It is important we are consistent with how we generate this so that
         
     | 
| 
      
 673 
     | 
    
         
            +
                  # exclusive locking works across migrator versions
         
     | 
| 
      
 674 
     | 
    
         
            +
                  migration = Class.new(ActiveRecord::Migration::Current).new
         
     | 
| 
      
 675 
     | 
    
         
            +
                  migrator = ActiveRecord::Migrator.new(:up, [migration], 100)
         
     | 
| 
      
 676 
     | 
    
         
            +
             
     | 
| 
      
 677 
     | 
    
         
            +
                  lock_id = migrator.send(:generate_migrator_advisory_lock_id)
         
     | 
| 
      
 678 
     | 
    
         
            +
             
     | 
| 
      
 679 
     | 
    
         
            +
                  current_database = ActiveRecord::Base.connection.current_database
         
     | 
| 
      
 680 
     | 
    
         
            +
                  salt = ActiveRecord::Migrator::MIGRATOR_SALT
         
     | 
| 
      
 681 
     | 
    
         
            +
                  expected_id = Zlib.crc32(current_database) * salt
         
     | 
| 
      
 682 
     | 
    
         
            +
             
     | 
| 
      
 683 
     | 
    
         
            +
                  assert lock_id == expected_id, "expected lock id generated by the migrator to be #{expected_id}, but it was #{lock_id} instead"
         
     | 
| 
      
 684 
     | 
    
         
            +
                  assert lock_id.bit_length <= 63, "lock id must be a signed integer of max 63 bits magnitude"
         
     | 
| 
      
 685 
     | 
    
         
            +
                end
         
     | 
| 
      
 686 
     | 
    
         
            +
             
     | 
| 
      
 687 
     | 
    
         
            +
                def test_migrator_one_up_with_unavailable_lock
         
     | 
| 
      
 688 
     | 
    
         
            +
                  assert_no_column Person, :last_name
         
     | 
| 
      
 689 
     | 
    
         
            +
             
     | 
| 
      
 690 
     | 
    
         
            +
                  migration = Class.new(ActiveRecord::Migration::Current) {
         
     | 
| 
      
 691 
     | 
    
         
            +
                    def version; 100 end
         
     | 
| 
      
 692 
     | 
    
         
            +
                    def migrate(x)
         
     | 
| 
      
 693 
     | 
    
         
            +
                      add_column "people", "last_name", :string
         
     | 
| 
      
 694 
     | 
    
         
            +
                    end
         
     | 
| 
      
 695 
     | 
    
         
            +
                  }.new
         
     | 
| 
      
 696 
     | 
    
         
            +
             
     | 
| 
      
 697 
     | 
    
         
            +
                  migrator = ActiveRecord::Migrator.new(:up, [migration], 100)
         
     | 
| 
      
 698 
     | 
    
         
            +
                  lock_id = migrator.send(:generate_migrator_advisory_lock_id)
         
     | 
| 
      
 699 
     | 
    
         
            +
             
     | 
| 
      
 700 
     | 
    
         
            +
                  with_another_process_holding_lock(lock_id) do
         
     | 
| 
      
 701 
     | 
    
         
            +
                    assert_raise(ActiveRecord::ConcurrentMigrationError) { migrator.migrate }
         
     | 
| 
      
 702 
     | 
    
         
            +
                  end
         
     | 
| 
      
 703 
     | 
    
         
            +
             
     | 
| 
      
 704 
     | 
    
         
            +
                  assert_no_column Person, :last_name,
         
     | 
| 
      
 705 
     | 
    
         
            +
                    "without an advisory lock, the Migrator should not make any changes, but it did."
         
     | 
| 
      
 706 
     | 
    
         
            +
                end
         
     | 
| 
      
 707 
     | 
    
         
            +
             
     | 
| 
      
 708 
     | 
    
         
            +
                def test_migrator_one_up_with_unavailable_lock_using_run
         
     | 
| 
      
 709 
     | 
    
         
            +
                  assert_no_column Person, :last_name
         
     | 
| 
      
 710 
     | 
    
         
            +
             
     | 
| 
      
 711 
     | 
    
         
            +
                  migration = Class.new(ActiveRecord::Migration::Current) {
         
     | 
| 
      
 712 
     | 
    
         
            +
                    def version; 100 end
         
     | 
| 
      
 713 
     | 
    
         
            +
                    def migrate(x)
         
     | 
| 
      
 714 
     | 
    
         
            +
                      add_column "people", "last_name", :string
         
     | 
| 
      
 715 
     | 
    
         
            +
                    end
         
     | 
| 
      
 716 
     | 
    
         
            +
                  }.new
         
     | 
| 
      
 717 
     | 
    
         
            +
             
     | 
| 
      
 718 
     | 
    
         
            +
                  migrator = ActiveRecord::Migrator.new(:up, [migration], 100)
         
     | 
| 
      
 719 
     | 
    
         
            +
                  lock_id = migrator.send(:generate_migrator_advisory_lock_id)
         
     | 
| 
      
 720 
     | 
    
         
            +
             
     | 
| 
      
 721 
     | 
    
         
            +
                  with_another_process_holding_lock(lock_id) do
         
     | 
| 
      
 722 
     | 
    
         
            +
                    assert_raise(ActiveRecord::ConcurrentMigrationError) { migrator.run }
         
     | 
| 
      
 723 
     | 
    
         
            +
                  end
         
     | 
| 
      
 724 
     | 
    
         
            +
             
     | 
| 
      
 725 
     | 
    
         
            +
                  assert_no_column Person, :last_name,
         
     | 
| 
      
 726 
     | 
    
         
            +
                    "without an advisory lock, the Migrator should not make any changes, but it did."
         
     | 
| 
       549 
727 
     | 
    
         
             
                end
         
     | 
| 
       550 
728 
     | 
    
         
             
              end
         
     | 
| 
       551 
729 
     | 
    
         | 
| 
         @@ -558,6 +736,30 @@ class MigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       558 
736 
     | 
    
         
             
                    def self.base_class; self; end
         
     | 
| 
       559 
737 
     | 
    
         
             
                  }
         
     | 
| 
       560 
738 
     | 
    
         
             
                end
         
     | 
| 
      
 739 
     | 
    
         
            +
             
     | 
| 
      
 740 
     | 
    
         
            +
                def with_another_process_holding_lock(lock_id)
         
     | 
| 
      
 741 
     | 
    
         
            +
                  thread_lock = Concurrent::CountDownLatch.new
         
     | 
| 
      
 742 
     | 
    
         
            +
                  test_terminated = Concurrent::CountDownLatch.new
         
     | 
| 
      
 743 
     | 
    
         
            +
             
     | 
| 
      
 744 
     | 
    
         
            +
                  other_process = Thread.new do
         
     | 
| 
      
 745 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 746 
     | 
    
         
            +
                      conn = ActiveRecord::Base.connection_pool.checkout
         
     | 
| 
      
 747 
     | 
    
         
            +
                      conn.get_advisory_lock(lock_id)
         
     | 
| 
      
 748 
     | 
    
         
            +
                      thread_lock.count_down
         
     | 
| 
      
 749 
     | 
    
         
            +
                      test_terminated.wait # hold the lock open until we tested everything
         
     | 
| 
      
 750 
     | 
    
         
            +
                    ensure
         
     | 
| 
      
 751 
     | 
    
         
            +
                      conn.release_advisory_lock(lock_id)
         
     | 
| 
      
 752 
     | 
    
         
            +
                      ActiveRecord::Base.connection_pool.checkin(conn)
         
     | 
| 
      
 753 
     | 
    
         
            +
                    end
         
     | 
| 
      
 754 
     | 
    
         
            +
                  end
         
     | 
| 
      
 755 
     | 
    
         
            +
             
     | 
| 
      
 756 
     | 
    
         
            +
                  thread_lock.wait # wait until the 'other process' has the lock
         
     | 
| 
      
 757 
     | 
    
         
            +
             
     | 
| 
      
 758 
     | 
    
         
            +
                  yield
         
     | 
| 
      
 759 
     | 
    
         
            +
             
     | 
| 
      
 760 
     | 
    
         
            +
                  test_terminated.count_down
         
     | 
| 
      
 761 
     | 
    
         
            +
                  other_process.join
         
     | 
| 
      
 762 
     | 
    
         
            +
                end
         
     | 
| 
       561 
763 
     | 
    
         
             
            end
         
     | 
| 
       562 
764 
     | 
    
         | 
| 
       563 
765 
     | 
    
         
             
            class ReservedWordsMigrationTest < ActiveRecord::TestCase
         
     | 
| 
         @@ -571,7 +773,7 @@ class ReservedWordsMigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       571 
773 
     | 
    
         
             
                  connection.add_index :values, :value
         
     | 
| 
       572 
774 
     | 
    
         
             
                  connection.remove_index :values, :column => :value
         
     | 
| 
       573 
775 
     | 
    
         
             
                end
         
     | 
| 
       574 
     | 
    
         
            -
             
     | 
| 
      
 776 
     | 
    
         
            +
              ensure
         
     | 
| 
       575 
777 
     | 
    
         
             
                connection.drop_table :values rescue nil
         
     | 
| 
       576 
778 
     | 
    
         
             
              end
         
     | 
| 
       577 
779 
     | 
    
         
             
            end
         
     | 
| 
         @@ -583,11 +785,11 @@ class ExplicitlyNamedIndexMigrationTest < ActiveRecord::TestCase 
     | 
|
| 
       583 
785 
     | 
    
         
             
                  t.integer :value
         
     | 
| 
       584 
786 
     | 
    
         
             
                end
         
     | 
| 
       585 
787 
     | 
    
         | 
| 
       586 
     | 
    
         
            -
                assert_nothing_raised  
     | 
| 
      
 788 
     | 
    
         
            +
                assert_nothing_raised do
         
     | 
| 
       587 
789 
     | 
    
         
             
                  connection.add_index :values, :value, name: 'a_different_name'
         
     | 
| 
       588 
790 
     | 
    
         
             
                  connection.remove_index :values, column: :value, name: 'a_different_name'
         
     | 
| 
       589 
791 
     | 
    
         
             
                end
         
     | 
| 
       590 
     | 
    
         
            -
             
     | 
| 
      
 792 
     | 
    
         
            +
              ensure
         
     | 
| 
       591 
793 
     | 
    
         
             
                connection.drop_table :values rescue nil
         
     | 
| 
       592 
794 
     | 
    
         
             
              end
         
     | 
| 
       593 
795 
     | 
    
         
             
            end
         
     | 
| 
         @@ -738,6 +940,8 @@ if ActiveRecord::Base.connection.supports_bulk_alter? 
     | 
|
| 
       738 
940 
     | 
    
         
             
            end
         
     | 
| 
       739 
941 
     | 
    
         | 
| 
       740 
942 
     | 
    
         
             
            class CopyMigrationsTest < ActiveRecord::TestCase
         
     | 
| 
      
 943 
     | 
    
         
            +
              include ActiveSupport::Testing::Stream
         
     | 
| 
      
 944 
     | 
    
         
            +
             
     | 
| 
       741 
945 
     | 
    
         
             
              def setup
         
     | 
| 
       742 
946 
     | 
    
         
             
              end
         
     | 
| 
       743 
947 
     | 
    
         | 
| 
         @@ -947,13 +1151,7 @@ class CopyMigrationsTest < ActiveRecord::TestCase 
     | 
|
| 
       947 
1151 
     | 
    
         
             
                ActiveRecord::Base.logger = old
         
     | 
| 
       948 
1152 
     | 
    
         
             
              end
         
     | 
| 
       949 
1153 
     | 
    
         | 
| 
       950 
     | 
    
         
            -
               
     | 
| 
       951 
     | 
    
         
            -
             
     | 
| 
       952 
     | 
    
         
            -
              def quietly
         
     | 
| 
       953 
     | 
    
         
            -
                silence_stream(STDOUT) do
         
     | 
| 
       954 
     | 
    
         
            -
                  silence_stream(STDERR) do
         
     | 
| 
       955 
     | 
    
         
            -
                    yield
         
     | 
| 
       956 
     | 
    
         
            -
                  end
         
     | 
| 
       957 
     | 
    
         
            -
                end
         
     | 
| 
      
 1154 
     | 
    
         
            +
              def test_unknown_migration_version_should_raise_an_argument_error
         
     | 
| 
      
 1155 
     | 
    
         
            +
                assert_raise(ArgumentError) { ActiveRecord::Migration[1.0] }
         
     | 
| 
       958 
1156 
     | 
    
         
             
              end
         
     | 
| 
       959 
1157 
     | 
    
         
             
            end
         
     |