activerecord 5.0.7.2 → 6.0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +708 -2040
- data/MIT-LICENSE +3 -1
- data/README.rdoc +9 -7
- data/examples/performance.rb +31 -29
- data/examples/simple.rb +5 -3
- data/lib/active_record.rb +37 -22
- data/lib/active_record/advisory_lock_base.rb +18 -0
- data/lib/active_record/aggregations.rb +249 -247
- data/lib/active_record/association_relation.rb +18 -14
- data/lib/active_record/associations.rb +1603 -1592
- data/lib/active_record/associations/alias_tracker.rb +24 -34
- data/lib/active_record/associations/association.rb +114 -55
- data/lib/active_record/associations/association_scope.rb +94 -94
- data/lib/active_record/associations/belongs_to_association.rb +58 -42
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +8 -12
- data/lib/active_record/associations/builder/association.rb +18 -25
- data/lib/active_record/associations/builder/belongs_to.rb +43 -54
- data/lib/active_record/associations/builder/collection_association.rb +7 -18
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +41 -62
- data/lib/active_record/associations/builder/has_many.rb +4 -0
- data/lib/active_record/associations/builder/has_one.rb +37 -1
- data/lib/active_record/associations/builder/singular_association.rb +4 -0
- data/lib/active_record/associations/collection_association.rb +86 -254
- data/lib/active_record/associations/collection_proxy.rb +158 -122
- data/lib/active_record/associations/foreign_association.rb +9 -0
- data/lib/active_record/associations/has_many_association.rb +23 -30
- data/lib/active_record/associations/has_many_through_association.rb +58 -44
- data/lib/active_record/associations/has_one_association.rb +59 -54
- data/lib/active_record/associations/has_one_through_association.rb +20 -11
- data/lib/active_record/associations/join_dependency.rb +143 -176
- data/lib/active_record/associations/join_dependency/join_association.rb +38 -87
- data/lib/active_record/associations/join_dependency/join_base.rb +10 -9
- data/lib/active_record/associations/join_dependency/join_part.rb +12 -12
- data/lib/active_record/associations/preloader.rb +90 -103
- data/lib/active_record/associations/preloader/association.rb +86 -100
- data/lib/active_record/associations/preloader/through_association.rb +77 -76
- data/lib/active_record/associations/singular_association.rb +12 -45
- data/lib/active_record/associations/through_association.rb +26 -14
- data/lib/active_record/attribute_assignment.rb +54 -61
- data/lib/active_record/attribute_decorators.rb +38 -17
- data/lib/active_record/attribute_methods.rb +66 -106
- data/lib/active_record/attribute_methods/before_type_cast.rb +12 -8
- data/lib/active_record/attribute_methods/dirty.rb +179 -109
- data/lib/active_record/attribute_methods/primary_key.rb +85 -92
- data/lib/active_record/attribute_methods/query.rb +4 -3
- data/lib/active_record/attribute_methods/read.rb +20 -49
- data/lib/active_record/attribute_methods/serialization.rb +29 -7
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +39 -66
- data/lib/active_record/attribute_methods/write.rb +34 -33
- data/lib/active_record/attributes.rb +38 -25
- data/lib/active_record/autosave_association.rb +54 -35
- data/lib/active_record/base.rb +27 -24
- data/lib/active_record/callbacks.rb +64 -35
- data/lib/active_record/coders/json.rb +2 -0
- data/lib/active_record/coders/yaml_column.rb +11 -12
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +552 -323
- data/lib/active_record/connection_adapters/abstract/database_limits.rb +23 -5
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +215 -94
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +59 -35
- data/lib/active_record/connection_adapters/abstract/quoting.rb +119 -75
- data/lib/active_record/connection_adapters/abstract/savepoints.rb +2 -0
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +33 -28
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +228 -147
- data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +68 -80
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +400 -213
- data/lib/active_record/connection_adapters/abstract/transaction.rb +169 -79
- data/lib/active_record/connection_adapters/abstract_adapter.rb +367 -202
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +396 -562
- data/lib/active_record/connection_adapters/column.rb +41 -13
- data/lib/active_record/connection_adapters/connection_specification.rb +172 -139
- data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +11 -4
- data/lib/active_record/connection_adapters/mysql/column.rb +8 -31
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +137 -49
- data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +24 -23
- data/lib/active_record/connection_adapters/mysql/quoting.rb +50 -20
- data/lib/active_record/connection_adapters/mysql/schema_creation.rb +49 -45
- data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +58 -56
- data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +70 -36
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +264 -0
- data/lib/active_record/connection_adapters/mysql/type_metadata.rb +12 -13
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +48 -30
- data/lib/active_record/connection_adapters/postgresql/column.rb +19 -31
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +64 -54
- data/lib/active_record/connection_adapters/postgresql/explain_pretty_printer.rb +5 -3
- data/lib/active_record/connection_adapters/postgresql/oid.rb +24 -21
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +22 -11
- data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +6 -5
- data/lib/active_record/connection_adapters/postgresql/oid/bit_varying.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/bytea.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +3 -1
- data/lib/active_record/connection_adapters/postgresql/oid/date.rb +23 -0
- data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +4 -2
- data/lib/active_record/connection_adapters/postgresql/oid/decimal.rb +3 -1
- data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +5 -4
- data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +19 -18
- data/lib/active_record/connection_adapters/postgresql/oid/inet.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb +3 -11
- data/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb +44 -0
- data/lib/active_record/connection_adapters/postgresql/oid/money.rb +7 -5
- data/lib/active_record/connection_adapters/postgresql/oid/{json.rb → oid.rb} +6 -1
- data/lib/active_record/connection_adapters/postgresql/oid/point.rb +30 -9
- data/lib/active_record/connection_adapters/postgresql/oid/range.rb +34 -31
- data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +4 -1
- data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +58 -54
- data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +8 -4
- data/lib/active_record/connection_adapters/postgresql/oid/vector.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/xml.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +95 -35
- data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +20 -26
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +76 -0
- data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +147 -105
- data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +34 -32
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +378 -308
- data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +26 -25
- data/lib/active_record/connection_adapters/postgresql/utils.rb +9 -6
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +383 -275
- data/lib/active_record/connection_adapters/schema_cache.rb +46 -12
- data/lib/active_record/connection_adapters/sql_type_metadata.rb +13 -8
- data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +119 -0
- data/lib/active_record/connection_adapters/sqlite3/explain_pretty_printer.rb +3 -1
- data/lib/active_record/connection_adapters/sqlite3/quoting.rb +72 -18
- data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +3 -8
- data/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb +19 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_dumper.rb +18 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +137 -0
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +259 -266
- data/lib/active_record/connection_adapters/statement_pool.rb +9 -8
- data/lib/active_record/connection_handling.rb +143 -40
- data/lib/active_record/core.rb +201 -163
- data/lib/active_record/counter_cache.rb +60 -28
- data/lib/active_record/database_configurations.rb +233 -0
- data/lib/active_record/database_configurations/database_config.rb +37 -0
- data/lib/active_record/database_configurations/hash_config.rb +50 -0
- data/lib/active_record/database_configurations/url_config.rb +78 -0
- data/lib/active_record/define_callbacks.rb +22 -0
- data/lib/active_record/dynamic_matchers.rb +87 -87
- data/lib/active_record/enum.rb +60 -23
- data/lib/active_record/errors.rb +114 -18
- data/lib/active_record/explain.rb +4 -4
- data/lib/active_record/explain_registry.rb +3 -1
- data/lib/active_record/explain_subscriber.rb +9 -4
- data/lib/active_record/fixture_set/file.rb +13 -8
- data/lib/active_record/fixture_set/model_metadata.rb +33 -0
- data/lib/active_record/fixture_set/render_context.rb +17 -0
- data/lib/active_record/fixture_set/table_row.rb +152 -0
- data/lib/active_record/fixture_set/table_rows.rb +46 -0
- data/lib/active_record/fixtures.rb +194 -504
- data/lib/active_record/gem_version.rb +5 -3
- data/lib/active_record/inheritance.rb +150 -99
- data/lib/active_record/insert_all.rb +179 -0
- data/lib/active_record/integration.rb +116 -25
- data/lib/active_record/internal_metadata.rb +16 -19
- data/lib/active_record/legacy_yaml_adapter.rb +4 -2
- data/lib/active_record/locking/optimistic.rb +77 -87
- data/lib/active_record/locking/pessimistic.rb +18 -6
- data/lib/active_record/log_subscriber.rb +48 -29
- data/lib/active_record/middleware/database_selector.rb +74 -0
- data/lib/active_record/middleware/database_selector/resolver.rb +87 -0
- data/lib/active_record/middleware/database_selector/resolver/session.rb +45 -0
- data/lib/active_record/migration.rb +369 -302
- data/lib/active_record/migration/command_recorder.rb +134 -100
- data/lib/active_record/migration/compatibility.rb +174 -56
- data/lib/active_record/migration/join_table.rb +8 -7
- data/lib/active_record/model_schema.rb +131 -127
- data/lib/active_record/nested_attributes.rb +213 -202
- data/lib/active_record/no_touching.rb +12 -3
- data/lib/active_record/null_relation.rb +12 -34
- data/lib/active_record/persistence.rb +446 -77
- data/lib/active_record/query_cache.rb +13 -12
- data/lib/active_record/querying.rb +37 -24
- data/lib/active_record/railtie.rb +128 -36
- data/lib/active_record/railties/collection_cache_association_loading.rb +34 -0
- data/lib/active_record/railties/console_sandbox.rb +2 -0
- data/lib/active_record/railties/controller_runtime.rb +34 -33
- data/lib/active_record/railties/databases.rake +312 -177
- data/lib/active_record/readonly_attributes.rb +5 -4
- data/lib/active_record/reflection.rb +214 -252
- data/lib/active_record/relation.rb +440 -318
- data/lib/active_record/relation/batches.rb +98 -52
- data/lib/active_record/relation/batches/batch_enumerator.rb +3 -1
- data/lib/active_record/relation/calculations.rb +212 -173
- data/lib/active_record/relation/delegation.rb +72 -69
- data/lib/active_record/relation/finder_methods.rb +207 -247
- data/lib/active_record/relation/from_clause.rb +6 -8
- data/lib/active_record/relation/merger.rb +78 -62
- data/lib/active_record/relation/predicate_builder.rb +83 -105
- data/lib/active_record/relation/predicate_builder/array_handler.rb +20 -14
- data/lib/active_record/relation/predicate_builder/association_query_value.rb +43 -0
- data/lib/active_record/relation/predicate_builder/base_handler.rb +4 -3
- data/lib/active_record/relation/predicate_builder/basic_object_handler.rb +6 -4
- data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +53 -0
- data/lib/active_record/relation/predicate_builder/range_handler.rb +7 -18
- data/lib/active_record/relation/predicate_builder/relation_handler.rb +6 -0
- data/lib/active_record/relation/query_attribute.rb +33 -2
- data/lib/active_record/relation/query_methods.rb +476 -334
- data/lib/active_record/relation/record_fetch_warning.rb +5 -3
- data/lib/active_record/relation/spawn_methods.rb +8 -8
- data/lib/active_record/relation/where_clause.rb +111 -96
- data/lib/active_record/relation/where_clause_factory.rb +6 -11
- data/lib/active_record/result.rb +69 -40
- data/lib/active_record/runtime_registry.rb +5 -3
- data/lib/active_record/sanitization.rb +83 -99
- data/lib/active_record/schema.rb +7 -14
- data/lib/active_record/schema_dumper.rb +71 -69
- data/lib/active_record/schema_migration.rb +16 -6
- data/lib/active_record/scoping.rb +20 -20
- data/lib/active_record/scoping/default.rb +92 -95
- data/lib/active_record/scoping/named.rb +47 -27
- data/lib/active_record/secure_token.rb +4 -2
- data/lib/active_record/serialization.rb +2 -0
- data/lib/active_record/statement_cache.rb +63 -28
- data/lib/active_record/store.rb +121 -41
- data/lib/active_record/suppressor.rb +6 -3
- data/lib/active_record/table_metadata.rb +39 -18
- data/lib/active_record/tasks/database_tasks.rb +271 -81
- data/lib/active_record/tasks/mysql_database_tasks.rb +54 -91
- data/lib/active_record/tasks/postgresql_database_tasks.rb +77 -47
- data/lib/active_record/tasks/sqlite_database_tasks.rb +33 -16
- data/lib/active_record/test_databases.rb +23 -0
- data/lib/active_record/test_fixtures.rb +225 -0
- data/lib/active_record/timestamp.rb +70 -36
- data/lib/active_record/touch_later.rb +8 -6
- data/lib/active_record/transactions.rb +141 -157
- data/lib/active_record/translation.rb +3 -1
- data/lib/active_record/type.rb +23 -18
- data/lib/active_record/type/adapter_specific_registry.rb +44 -48
- data/lib/active_record/type/date.rb +2 -0
- data/lib/active_record/type/date_time.rb +2 -0
- data/lib/active_record/type/decimal_without_scale.rb +15 -0
- data/lib/active_record/type/hash_lookup_type_map.rb +5 -4
- data/lib/active_record/type/internal/timezone.rb +2 -0
- data/lib/active_record/type/json.rb +30 -0
- data/lib/active_record/type/serialized.rb +16 -9
- data/lib/active_record/type/text.rb +11 -0
- data/lib/active_record/type/time.rb +2 -1
- data/lib/active_record/type/type_map.rb +14 -17
- data/lib/active_record/type/unsigned_integer.rb +16 -0
- data/lib/active_record/type_caster.rb +4 -2
- data/lib/active_record/type_caster/connection.rb +17 -12
- data/lib/active_record/type_caster/map.rb +5 -4
- data/lib/active_record/validations.rb +7 -5
- data/lib/active_record/validations/absence.rb +2 -0
- data/lib/active_record/validations/associated.rb +4 -3
- data/lib/active_record/validations/length.rb +2 -0
- data/lib/active_record/validations/presence.rb +4 -2
- data/lib/active_record/validations/uniqueness.rb +29 -42
- data/lib/active_record/version.rb +3 -1
- data/lib/arel.rb +62 -0
- data/lib/arel/alias_predication.rb +9 -0
- data/lib/arel/attributes.rb +22 -0
- data/lib/arel/attributes/attribute.rb +37 -0
- data/lib/arel/collectors/bind.rb +24 -0
- data/lib/arel/collectors/composite.rb +31 -0
- data/lib/arel/collectors/plain_string.rb +20 -0
- data/lib/arel/collectors/sql_string.rb +20 -0
- data/lib/arel/collectors/substitute_binds.rb +28 -0
- data/lib/arel/crud.rb +42 -0
- data/lib/arel/delete_manager.rb +18 -0
- data/lib/arel/errors.rb +9 -0
- data/lib/arel/expressions.rb +29 -0
- data/lib/arel/factory_methods.rb +49 -0
- data/lib/arel/insert_manager.rb +49 -0
- data/lib/arel/math.rb +45 -0
- data/lib/arel/nodes.rb +68 -0
- data/lib/arel/nodes/and.rb +32 -0
- data/lib/arel/nodes/ascending.rb +23 -0
- data/lib/arel/nodes/binary.rb +52 -0
- data/lib/arel/nodes/bind_param.rb +36 -0
- data/lib/arel/nodes/case.rb +55 -0
- data/lib/arel/nodes/casted.rb +50 -0
- data/lib/arel/nodes/comment.rb +29 -0
- data/lib/arel/nodes/count.rb +12 -0
- data/lib/arel/nodes/delete_statement.rb +45 -0
- data/lib/arel/nodes/descending.rb +23 -0
- data/lib/arel/nodes/equality.rb +18 -0
- data/lib/arel/nodes/extract.rb +24 -0
- data/lib/arel/nodes/false.rb +16 -0
- data/lib/arel/nodes/full_outer_join.rb +8 -0
- data/lib/arel/nodes/function.rb +44 -0
- data/lib/arel/nodes/grouping.rb +8 -0
- data/lib/arel/nodes/in.rb +8 -0
- data/lib/arel/nodes/infix_operation.rb +80 -0
- data/lib/arel/nodes/inner_join.rb +8 -0
- data/lib/arel/nodes/insert_statement.rb +37 -0
- data/lib/arel/nodes/join_source.rb +20 -0
- data/lib/arel/nodes/matches.rb +18 -0
- data/lib/arel/nodes/named_function.rb +23 -0
- data/lib/arel/nodes/node.rb +50 -0
- data/lib/arel/nodes/node_expression.rb +13 -0
- data/lib/arel/nodes/outer_join.rb +8 -0
- data/lib/arel/nodes/over.rb +15 -0
- data/lib/arel/nodes/regexp.rb +16 -0
- data/lib/arel/nodes/right_outer_join.rb +8 -0
- data/lib/arel/nodes/select_core.rb +67 -0
- data/lib/arel/nodes/select_statement.rb +41 -0
- data/lib/arel/nodes/sql_literal.rb +16 -0
- data/lib/arel/nodes/string_join.rb +11 -0
- data/lib/arel/nodes/table_alias.rb +27 -0
- data/lib/arel/nodes/terminal.rb +16 -0
- data/lib/arel/nodes/true.rb +16 -0
- data/lib/arel/nodes/unary.rb +45 -0
- data/lib/arel/nodes/unary_operation.rb +20 -0
- data/lib/arel/nodes/unqualified_column.rb +22 -0
- data/lib/arel/nodes/update_statement.rb +41 -0
- data/lib/arel/nodes/values_list.rb +9 -0
- data/lib/arel/nodes/window.rb +126 -0
- data/lib/arel/nodes/with.rb +11 -0
- data/lib/arel/order_predications.rb +13 -0
- data/lib/arel/predications.rb +256 -0
- data/lib/arel/select_manager.rb +271 -0
- data/lib/arel/table.rb +110 -0
- data/lib/arel/tree_manager.rb +72 -0
- data/lib/arel/update_manager.rb +34 -0
- data/lib/arel/visitors.rb +20 -0
- data/lib/arel/visitors/depth_first.rb +203 -0
- data/lib/arel/visitors/dot.rb +296 -0
- data/lib/arel/visitors/ibm_db.rb +34 -0
- data/lib/arel/visitors/informix.rb +62 -0
- data/lib/arel/visitors/mssql.rb +156 -0
- data/lib/arel/visitors/mysql.rb +83 -0
- data/lib/arel/visitors/oracle.rb +158 -0
- data/lib/arel/visitors/oracle12.rb +65 -0
- data/lib/arel/visitors/postgresql.rb +109 -0
- data/lib/arel/visitors/sqlite.rb +38 -0
- data/lib/arel/visitors/to_sql.rb +888 -0
- data/lib/arel/visitors/visitor.rb +45 -0
- data/lib/arel/visitors/where_sql.rb +22 -0
- data/lib/arel/window_predications.rb +9 -0
- data/lib/rails/generators/active_record.rb +7 -5
- data/lib/rails/generators/active_record/application_record/application_record_generator.rb +26 -0
- data/lib/rails/generators/active_record/{model/templates/application_record.rb → application_record/templates/application_record.rb.tt} +0 -0
- data/lib/rails/generators/active_record/migration.rb +17 -3
- data/lib/rails/generators/active_record/migration/migration_generator.rb +37 -35
- data/lib/rails/generators/active_record/migration/templates/{create_table_migration.rb → create_table_migration.rb.tt} +1 -1
- data/lib/rails/generators/active_record/migration/templates/{migration.rb → migration.rb.tt} +4 -2
- data/lib/rails/generators/active_record/model/model_generator.rb +9 -30
- data/lib/rails/generators/active_record/model/templates/{model.rb → model.rb.tt} +10 -1
- data/lib/rails/generators/active_record/model/templates/{module.rb → module.rb.tt} +0 -0
- metadata +137 -52
- data/lib/active_record/associations/preloader/belongs_to.rb +0 -17
- data/lib/active_record/associations/preloader/collection_association.rb +0 -17
- data/lib/active_record/associations/preloader/has_many.rb +0 -17
- data/lib/active_record/associations/preloader/has_many_through.rb +0 -19
- data/lib/active_record/associations/preloader/has_one.rb +0 -15
- data/lib/active_record/associations/preloader/has_one_through.rb +0 -9
- data/lib/active_record/associations/preloader/singular_association.rb +0 -20
- data/lib/active_record/attribute.rb +0 -213
- data/lib/active_record/attribute/user_provided_default.rb +0 -28
- data/lib/active_record/attribute_mutation_tracker.rb +0 -70
- data/lib/active_record/attribute_set.rb +0 -110
- data/lib/active_record/attribute_set/builder.rb +0 -132
- data/lib/active_record/collection_cache_key.rb +0 -50
- data/lib/active_record/connection_adapters/postgresql/oid/rails_5_1_point.rb +0 -50
- data/lib/active_record/railties/jdbcmysql_error.rb +0 -16
- data/lib/active_record/relation/predicate_builder/association_query_handler.rb +0 -88
- data/lib/active_record/relation/predicate_builder/class_handler.rb +0 -27
- data/lib/active_record/relation/predicate_builder/polymorphic_array_handler.rb +0 -57
- data/lib/active_record/type/internal/abstract_json.rb +0 -33
@@ -1,32 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecord
|
2
4
|
module ConnectionAdapters #:nodoc:
|
3
5
|
# Abstract representation of an index definition on a table. Instances of
|
4
6
|
# this type are typically created and returned by methods in database
|
5
|
-
# adapters. e.g. ActiveRecord::ConnectionAdapters::
|
6
|
-
class IndexDefinition
|
7
|
+
# adapters. e.g. ActiveRecord::ConnectionAdapters::MySQL::SchemaStatements#indexes
|
8
|
+
class IndexDefinition # :nodoc:
|
9
|
+
attr_reader :table, :name, :unique, :columns, :lengths, :orders, :opclasses, :where, :type, :using, :comment
|
10
|
+
|
11
|
+
def initialize(
|
12
|
+
table, name,
|
13
|
+
unique = false,
|
14
|
+
columns = [],
|
15
|
+
lengths: {},
|
16
|
+
orders: {},
|
17
|
+
opclasses: {},
|
18
|
+
where: nil,
|
19
|
+
type: nil,
|
20
|
+
using: nil,
|
21
|
+
comment: nil
|
22
|
+
)
|
23
|
+
@table = table
|
24
|
+
@name = name
|
25
|
+
@unique = unique
|
26
|
+
@columns = columns
|
27
|
+
@lengths = concise_options(lengths)
|
28
|
+
@orders = concise_options(orders)
|
29
|
+
@opclasses = concise_options(opclasses)
|
30
|
+
@where = where
|
31
|
+
@type = type
|
32
|
+
@using = using
|
33
|
+
@comment = comment
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
def concise_options(options)
|
38
|
+
if columns.size == options.size && options.values.uniq.size == 1
|
39
|
+
options.values.first
|
40
|
+
else
|
41
|
+
options
|
42
|
+
end
|
43
|
+
end
|
7
44
|
end
|
8
45
|
|
9
46
|
# Abstract representation of a column definition. Instances of this type
|
10
47
|
# are typically created by methods in TableDefinition, and added to the
|
11
48
|
# +columns+ attribute of said TableDefinition object, in order to be used
|
12
49
|
# for generating a number of table creation or table changing SQL statements.
|
13
|
-
|
14
|
-
|
50
|
+
ColumnDefinition = Struct.new(:name, :type, :options, :sql_type) do # :nodoc:
|
15
51
|
def primary_key?
|
16
|
-
|
52
|
+
options[:primary_key]
|
17
53
|
end
|
18
|
-
end
|
19
54
|
|
20
|
-
|
21
|
-
|
55
|
+
[:limit, :precision, :scale, :default, :null, :collation, :comment].each do |option_name|
|
56
|
+
module_eval <<-CODE, __FILE__, __LINE__ + 1
|
57
|
+
def #{option_name}
|
58
|
+
options[:#{option_name}]
|
59
|
+
end
|
22
60
|
|
23
|
-
|
61
|
+
def #{option_name}=(value)
|
62
|
+
options[:#{option_name}] = value
|
63
|
+
end
|
64
|
+
CODE
|
65
|
+
end
|
24
66
|
end
|
25
67
|
|
26
|
-
|
27
|
-
|
68
|
+
AddColumnDefinition = Struct.new(:column) # :nodoc:
|
69
|
+
|
70
|
+
ChangeColumnDefinition = Struct.new(:column, :name) #:nodoc:
|
71
|
+
|
72
|
+
PrimaryKeyDefinition = Struct.new(:name) # :nodoc:
|
28
73
|
|
29
|
-
|
74
|
+
ForeignKeyDefinition = Struct.new(:from_table, :to_table, :options) do #:nodoc:
|
30
75
|
def name
|
31
76
|
options[:name]
|
32
77
|
end
|
@@ -51,19 +96,24 @@ module ActiveRecord
|
|
51
96
|
options[:primary_key] != default_primary_key
|
52
97
|
end
|
53
98
|
|
54
|
-
def
|
55
|
-
|
56
|
-
self.to_table == to_table_ord.to_s
|
57
|
-
else
|
58
|
-
(to_table.nil? || to_table.to_s == self.to_table) &&
|
59
|
-
options.all? { |k, v| self.options[k].to_s == v.to_s }
|
60
|
-
end
|
99
|
+
def validate?
|
100
|
+
options.fetch(:validate, true)
|
61
101
|
end
|
102
|
+
alias validated? validate?
|
62
103
|
|
63
|
-
|
64
|
-
|
65
|
-
"id"
|
104
|
+
def export_name_on_schema_dump?
|
105
|
+
!ActiveRecord::SchemaDumper.fk_ignore_pattern.match?(name) if name
|
66
106
|
end
|
107
|
+
|
108
|
+
def defined_for?(to_table: nil, **options)
|
109
|
+
(to_table.nil? || to_table.to_s == self.to_table) &&
|
110
|
+
options.all? { |k, v| self.options[k].to_s == v.to_s }
|
111
|
+
end
|
112
|
+
|
113
|
+
private
|
114
|
+
def default_primary_key
|
115
|
+
"id"
|
116
|
+
end
|
67
117
|
end
|
68
118
|
|
69
119
|
class ReferenceDefinition # :nodoc:
|
@@ -72,7 +122,7 @@ module ActiveRecord
|
|
72
122
|
polymorphic: false,
|
73
123
|
index: true,
|
74
124
|
foreign_key: false,
|
75
|
-
type: :
|
125
|
+
type: :bigint,
|
76
126
|
**options
|
77
127
|
)
|
78
128
|
@name = name
|
@@ -89,7 +139,8 @@ module ActiveRecord
|
|
89
139
|
|
90
140
|
def add_to(table)
|
91
141
|
columns.each do |column_options|
|
92
|
-
|
142
|
+
kwargs = column_options.extract_options!
|
143
|
+
table.column(*column_options, **kwargs)
|
93
144
|
end
|
94
145
|
|
95
146
|
if index
|
@@ -97,89 +148,91 @@ module ActiveRecord
|
|
97
148
|
end
|
98
149
|
|
99
150
|
if foreign_key
|
100
|
-
table.foreign_key(foreign_table_name, foreign_key_options)
|
151
|
+
table.foreign_key(foreign_table_name, **foreign_key_options)
|
101
152
|
end
|
102
153
|
end
|
103
154
|
|
104
|
-
protected
|
105
|
-
|
106
|
-
attr_reader :name, :polymorphic, :index, :foreign_key, :type, :options
|
107
|
-
|
108
155
|
private
|
156
|
+
attr_reader :name, :polymorphic, :index, :foreign_key, :type, :options
|
109
157
|
|
110
|
-
|
111
|
-
|
112
|
-
|
158
|
+
def as_options(value)
|
159
|
+
value.is_a?(Hash) ? value : {}
|
160
|
+
end
|
113
161
|
|
114
|
-
|
115
|
-
|
116
|
-
|
162
|
+
def polymorphic_options
|
163
|
+
as_options(polymorphic).merge(options.slice(:null, :first, :after))
|
164
|
+
end
|
117
165
|
|
118
|
-
|
119
|
-
|
120
|
-
|
166
|
+
def index_options
|
167
|
+
as_options(index)
|
168
|
+
end
|
121
169
|
|
122
|
-
|
123
|
-
|
124
|
-
|
170
|
+
def foreign_key_options
|
171
|
+
as_options(foreign_key).merge(column: column_name)
|
172
|
+
end
|
125
173
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
174
|
+
def columns
|
175
|
+
result = [[column_name, type, options]]
|
176
|
+
if polymorphic
|
177
|
+
result.unshift(["#{name}_type", :string, polymorphic_options])
|
178
|
+
end
|
179
|
+
result
|
130
180
|
end
|
131
|
-
result
|
132
|
-
end
|
133
181
|
|
134
|
-
|
135
|
-
|
136
|
-
|
182
|
+
def column_name
|
183
|
+
"#{name}_id"
|
184
|
+
end
|
137
185
|
|
138
|
-
|
139
|
-
|
140
|
-
|
186
|
+
def column_names
|
187
|
+
columns.map(&:first)
|
188
|
+
end
|
141
189
|
|
142
|
-
|
143
|
-
|
144
|
-
|
190
|
+
def foreign_table_name
|
191
|
+
foreign_key_options.fetch(:to_table) do
|
192
|
+
Base.pluralize_table_names ? name.to_s.pluralize : name
|
193
|
+
end
|
145
194
|
end
|
146
|
-
end
|
147
195
|
end
|
148
196
|
|
149
197
|
module ColumnMethods
|
198
|
+
extend ActiveSupport::Concern
|
199
|
+
|
150
200
|
# Appends a primary key definition to the table definition.
|
151
201
|
# Can be called multiple times, but this is probably not a good idea.
|
152
202
|
def primary_key(name, type = :primary_key, **options)
|
153
|
-
column(name, type, options.merge(primary_key: true))
|
203
|
+
column(name, type, **options.merge(primary_key: true))
|
154
204
|
end
|
155
205
|
|
206
|
+
##
|
207
|
+
# :method: column
|
208
|
+
# :call-seq: column(name, type, **options)
|
209
|
+
#
|
156
210
|
# Appends a column or columns of a specified type.
|
157
211
|
#
|
158
212
|
# t.string(:goat)
|
159
213
|
# t.string(:goat, :sheep)
|
160
214
|
#
|
161
215
|
# See TableDefinition#column
|
162
|
-
|
163
|
-
|
164
|
-
:binary,
|
165
|
-
|
166
|
-
|
167
|
-
:
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
:
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
216
|
+
|
217
|
+
included do
|
218
|
+
define_column_methods :bigint, :binary, :boolean, :date, :datetime, :decimal,
|
219
|
+
:float, :integer, :json, :string, :text, :time, :timestamp, :virtual
|
220
|
+
|
221
|
+
alias :numeric :decimal
|
222
|
+
end
|
223
|
+
|
224
|
+
class_methods do
|
225
|
+
private def define_column_methods(*column_types) # :nodoc:
|
226
|
+
column_types.each do |column_type|
|
227
|
+
module_eval <<-RUBY, __FILE__, __LINE__ + 1
|
228
|
+
def #{column_type}(*names, **options)
|
229
|
+
raise ArgumentError, "Missing column name(s) for #{column_type}" if names.empty?
|
230
|
+
names.each { |name| column(name, :#{column_type}, **options) }
|
231
|
+
end
|
232
|
+
RUBY
|
179
233
|
end
|
180
|
-
|
234
|
+
end
|
181
235
|
end
|
182
|
-
alias_method :numeric, :decimal
|
183
236
|
end
|
184
237
|
|
185
238
|
# Represents the schema of an SQL table in an abstract way. This class
|
@@ -203,15 +256,25 @@ module ActiveRecord
|
|
203
256
|
class TableDefinition
|
204
257
|
include ColumnMethods
|
205
258
|
|
206
|
-
|
207
|
-
attr_reader :name, :temporary, :options, :as, :foreign_keys, :comment
|
259
|
+
attr_reader :name, :temporary, :if_not_exists, :options, :as, :comment, :indexes, :foreign_keys
|
208
260
|
|
209
|
-
def initialize(
|
261
|
+
def initialize(
|
262
|
+
conn,
|
263
|
+
name,
|
264
|
+
temporary: false,
|
265
|
+
if_not_exists: false,
|
266
|
+
options: nil,
|
267
|
+
as: nil,
|
268
|
+
comment: nil,
|
269
|
+
**
|
270
|
+
)
|
271
|
+
@conn = conn
|
210
272
|
@columns_hash = {}
|
211
273
|
@indexes = []
|
212
274
|
@foreign_keys = []
|
213
275
|
@primary_keys = nil
|
214
276
|
@temporary = temporary
|
277
|
+
@if_not_exists = if_not_exists
|
215
278
|
@options = options
|
216
279
|
@as = as
|
217
280
|
@name = name
|
@@ -295,21 +358,24 @@ module ActiveRecord
|
|
295
358
|
#
|
296
359
|
# create_table :taggings do |t|
|
297
360
|
# t.references :tag, index: { name: 'index_taggings_on_tag_id' }
|
298
|
-
# t.references :tagger, polymorphic: true
|
299
|
-
# t.references :taggable, polymorphic: { default: 'Photo' }
|
361
|
+
# t.references :tagger, polymorphic: true
|
362
|
+
# t.references :taggable, polymorphic: { default: 'Photo' }, index: false
|
300
363
|
# end
|
301
|
-
def column(name, type, options
|
364
|
+
def column(name, type, **options)
|
302
365
|
name = name.to_s
|
303
366
|
type = type.to_sym if type
|
304
|
-
options = options.dup
|
305
367
|
|
306
|
-
if @columns_hash[name]
|
307
|
-
|
368
|
+
if @columns_hash[name]
|
369
|
+
if @columns_hash[name].primary_key?
|
370
|
+
raise ArgumentError, "you can't redefine the primary key column '#{name}'. To define a custom primary key, pass { id: false } to create_table."
|
371
|
+
else
|
372
|
+
raise ArgumentError, "you can't define an already defined column '#{name}'."
|
373
|
+
end
|
308
374
|
end
|
309
375
|
|
310
376
|
index_options = options.delete(:index)
|
311
377
|
index(name, index_options.is_a?(Hash) ? index_options : {}) if index_options
|
312
|
-
@columns_hash[name] = new_column_definition(name, type, options)
|
378
|
+
@columns_hash[name] = new_column_definition(name, type, **options)
|
313
379
|
self
|
314
380
|
end
|
315
381
|
|
@@ -327,65 +393,65 @@ module ActiveRecord
|
|
327
393
|
indexes << [column_name, options]
|
328
394
|
end
|
329
395
|
|
330
|
-
def foreign_key(table_name, options
|
331
|
-
|
332
|
-
table_name_suffix = ActiveRecord::Base.table_name_suffix
|
333
|
-
table_name = "#{table_name_prefix}#{table_name}#{table_name_suffix}"
|
334
|
-
foreign_keys.push([table_name, options])
|
396
|
+
def foreign_key(table_name, **options) # :nodoc:
|
397
|
+
foreign_keys << [table_name, options]
|
335
398
|
end
|
336
399
|
|
337
400
|
# Appends <tt>:datetime</tt> columns <tt>:created_at</tt> and
|
338
401
|
# <tt>:updated_at</tt> to the table. See {connection.add_timestamps}[rdoc-ref:SchemaStatements#add_timestamps]
|
339
402
|
#
|
340
403
|
# t.timestamps null: false
|
341
|
-
def timestamps(
|
342
|
-
options = args.extract_options!
|
343
|
-
|
404
|
+
def timestamps(**options)
|
344
405
|
options[:null] = false if options[:null].nil?
|
345
406
|
|
346
|
-
|
347
|
-
|
407
|
+
if !options.key?(:precision) && @conn.supports_datetime_with_precision?
|
408
|
+
options[:precision] = 6
|
409
|
+
end
|
410
|
+
|
411
|
+
column(:created_at, :datetime, **options)
|
412
|
+
column(:updated_at, :datetime, **options)
|
348
413
|
end
|
349
414
|
|
350
415
|
# Adds a reference.
|
351
416
|
#
|
352
417
|
# t.references(:user)
|
353
418
|
# t.belongs_to(:supplier, foreign_key: true)
|
419
|
+
# t.belongs_to(:supplier, foreign_key: true, type: :integer)
|
354
420
|
#
|
355
421
|
# See {connection.add_reference}[rdoc-ref:SchemaStatements#add_reference] for details of the options you can use.
|
356
422
|
def references(*args, **options)
|
357
|
-
args.each do |
|
358
|
-
ReferenceDefinition.new(
|
423
|
+
args.each do |ref_name|
|
424
|
+
ReferenceDefinition.new(ref_name, **options).add_to(self)
|
359
425
|
end
|
360
426
|
end
|
361
427
|
alias :belongs_to :references
|
362
428
|
|
363
|
-
def new_column_definition(name, type, options) # :nodoc:
|
429
|
+
def new_column_definition(name, type, **options) # :nodoc:
|
430
|
+
if integer_like_primary_key?(type, options)
|
431
|
+
type = integer_like_primary_key_type(type, options)
|
432
|
+
end
|
364
433
|
type = aliased_types(type.to_s, type)
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
column.precision = options[:precision]
|
369
|
-
column.scale = options[:scale]
|
370
|
-
column.default = options[:default]
|
371
|
-
column.null = options[:null]
|
372
|
-
column.first = options[:first]
|
373
|
-
column.after = options[:after]
|
374
|
-
column.auto_increment = options[:auto_increment]
|
375
|
-
column.primary_key = type == :primary_key || options[:primary_key]
|
376
|
-
column.collation = options[:collation]
|
377
|
-
column.comment = options[:comment]
|
378
|
-
column
|
434
|
+
options[:primary_key] ||= type == :primary_key
|
435
|
+
options[:null] = false if options[:primary_key]
|
436
|
+
create_column_definition(name, type, options)
|
379
437
|
end
|
380
438
|
|
381
439
|
private
|
382
|
-
|
383
|
-
|
384
|
-
|
440
|
+
def create_column_definition(name, type, options)
|
441
|
+
ColumnDefinition.new(name, type, options)
|
442
|
+
end
|
385
443
|
|
386
|
-
|
387
|
-
|
388
|
-
|
444
|
+
def aliased_types(name, fallback)
|
445
|
+
"timestamp" == name ? :datetime : fallback
|
446
|
+
end
|
447
|
+
|
448
|
+
def integer_like_primary_key?(type, options)
|
449
|
+
options[:primary_key] && [:integer, :bigint].include?(type) && !options.key?(:default)
|
450
|
+
end
|
451
|
+
|
452
|
+
def integer_like_primary_key_type(type, options)
|
453
|
+
type
|
454
|
+
end
|
389
455
|
end
|
390
456
|
|
391
457
|
class AlterTable # :nodoc:
|
@@ -410,10 +476,10 @@ module ActiveRecord
|
|
410
476
|
@foreign_key_drops << name
|
411
477
|
end
|
412
478
|
|
413
|
-
def add_column(name, type, options)
|
479
|
+
def add_column(name, type, **options)
|
414
480
|
name = name.to_s
|
415
481
|
type = type.to_sym
|
416
|
-
@adds << AddColumnDefinition.new(@td.new_column_definition(name, type, options))
|
482
|
+
@adds << AddColumnDefinition.new(@td.new_column_definition(name, type, **options))
|
417
483
|
end
|
418
484
|
end
|
419
485
|
|
@@ -446,7 +512,11 @@ module ActiveRecord
|
|
446
512
|
# t.date
|
447
513
|
# t.binary
|
448
514
|
# t.boolean
|
515
|
+
# t.foreign_key
|
516
|
+
# t.json
|
517
|
+
# t.virtual
|
449
518
|
# t.remove
|
519
|
+
# t.remove_foreign_key
|
450
520
|
# t.remove_references
|
451
521
|
# t.remove_belongs_to
|
452
522
|
# t.remove_index
|
@@ -468,17 +538,19 @@ module ActiveRecord
|
|
468
538
|
# t.column(:name, :string)
|
469
539
|
#
|
470
540
|
# See TableDefinition#column for details of the options you can use.
|
471
|
-
def column(column_name, type, options
|
472
|
-
|
541
|
+
def column(column_name, type, **options)
|
542
|
+
index_options = options.delete(:index)
|
543
|
+
@base.add_column(name, column_name, type, **options)
|
544
|
+
index(column_name, index_options.is_a?(Hash) ? index_options : {}) if index_options
|
473
545
|
end
|
474
546
|
|
475
547
|
# Checks to see if a column exists.
|
476
548
|
#
|
477
|
-
#
|
549
|
+
# t.string(:name) unless t.column_exists?(:name, :string)
|
478
550
|
#
|
479
551
|
# See {connection.column_exists?}[rdoc-ref:SchemaStatements#column_exists?]
|
480
|
-
def column_exists?(column_name, type = nil, options
|
481
|
-
@base.column_exists?(name, column_name, type, options)
|
552
|
+
def column_exists?(column_name, type = nil, **options)
|
553
|
+
@base.column_exists?(name, column_name, type, **options)
|
482
554
|
end
|
483
555
|
|
484
556
|
# Adds a new index to the table. +column_name+ can be a single Symbol, or
|
@@ -495,9 +567,9 @@ module ActiveRecord
|
|
495
567
|
|
496
568
|
# Checks to see if an index exists.
|
497
569
|
#
|
498
|
-
#
|
499
|
-
#
|
500
|
-
#
|
570
|
+
# unless t.index_exists?(:branch_id)
|
571
|
+
# t.index(:branch_id)
|
572
|
+
# end
|
501
573
|
#
|
502
574
|
# See {connection.index_exists?}[rdoc-ref:SchemaStatements#index_exists?]
|
503
575
|
def index_exists?(column_name, options = {})
|
@@ -518,8 +590,8 @@ module ActiveRecord
|
|
518
590
|
# t.timestamps(null: false)
|
519
591
|
#
|
520
592
|
# See {connection.add_timestamps}[rdoc-ref:SchemaStatements#add_timestamps]
|
521
|
-
def timestamps(options
|
522
|
-
@base.add_timestamps(name, options)
|
593
|
+
def timestamps(**options)
|
594
|
+
@base.add_timestamps(name, **options)
|
523
595
|
end
|
524
596
|
|
525
597
|
# Changes the column's definition according to the new options.
|
@@ -569,8 +641,8 @@ module ActiveRecord
|
|
569
641
|
# t.remove_timestamps
|
570
642
|
#
|
571
643
|
# See {connection.remove_timestamps}[rdoc-ref:SchemaStatements#remove_timestamps]
|
572
|
-
def remove_timestamps(options
|
573
|
-
@base.remove_timestamps(name, options)
|
644
|
+
def remove_timestamps(**options)
|
645
|
+
@base.remove_timestamps(name, **options)
|
574
646
|
end
|
575
647
|
|
576
648
|
# Renames a column.
|
@@ -588,10 +660,9 @@ module ActiveRecord
|
|
588
660
|
# t.belongs_to(:supplier, foreign_key: true)
|
589
661
|
#
|
590
662
|
# See {connection.add_reference}[rdoc-ref:SchemaStatements#add_reference] for details of the options you can use.
|
591
|
-
def references(*args)
|
592
|
-
options = args.extract_options!
|
663
|
+
def references(*args, **options)
|
593
664
|
args.each do |ref_name|
|
594
|
-
@base.add_reference(name, ref_name, options)
|
665
|
+
@base.add_reference(name, ref_name, **options)
|
595
666
|
end
|
596
667
|
end
|
597
668
|
alias :belongs_to :references
|
@@ -602,30 +673,40 @@ module ActiveRecord
|
|
602
673
|
# t.remove_belongs_to(:supplier, polymorphic: true)
|
603
674
|
#
|
604
675
|
# See {connection.remove_reference}[rdoc-ref:SchemaStatements#remove_reference]
|
605
|
-
def remove_references(*args)
|
606
|
-
options = args.extract_options!
|
676
|
+
def remove_references(*args, **options)
|
607
677
|
args.each do |ref_name|
|
608
|
-
@base.remove_reference(name, ref_name, options)
|
678
|
+
@base.remove_reference(name, ref_name, **options)
|
609
679
|
end
|
610
680
|
end
|
611
681
|
alias :remove_belongs_to :remove_references
|
612
682
|
|
613
|
-
# Adds a foreign key.
|
683
|
+
# Adds a foreign key to the table using a supplied table name.
|
614
684
|
#
|
615
|
-
#
|
685
|
+
# t.foreign_key(:authors)
|
686
|
+
# t.foreign_key(:authors, column: :author_id, primary_key: "id")
|
616
687
|
#
|
617
688
|
# See {connection.add_foreign_key}[rdoc-ref:SchemaStatements#add_foreign_key]
|
618
|
-
def foreign_key(*args)
|
619
|
-
@base.add_foreign_key(name, *args)
|
689
|
+
def foreign_key(*args, **options)
|
690
|
+
@base.add_foreign_key(name, *args, **options)
|
691
|
+
end
|
692
|
+
|
693
|
+
# Removes the given foreign key from the table.
|
694
|
+
#
|
695
|
+
# t.remove_foreign_key(:authors)
|
696
|
+
# t.remove_foreign_key(column: :author_id)
|
697
|
+
#
|
698
|
+
# See {connection.remove_foreign_key}[rdoc-ref:SchemaStatements#remove_foreign_key]
|
699
|
+
def remove_foreign_key(*args, **options)
|
700
|
+
@base.remove_foreign_key(name, *args, **options)
|
620
701
|
end
|
621
702
|
|
622
703
|
# Checks to see if a foreign key exists.
|
623
704
|
#
|
624
|
-
#
|
705
|
+
# t.foreign_key(:authors) unless t.foreign_key_exists?(:authors)
|
625
706
|
#
|
626
707
|
# See {connection.foreign_key_exists?}[rdoc-ref:SchemaStatements#foreign_key_exists?]
|
627
|
-
def foreign_key_exists?(*args)
|
628
|
-
@base.foreign_key_exists?(name, *args)
|
708
|
+
def foreign_key_exists?(*args, **options)
|
709
|
+
@base.foreign_key_exists?(name, *args, **options)
|
629
710
|
end
|
630
711
|
end
|
631
712
|
end
|