activerecord 4.2.0 → 6.1.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (374) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +1221 -796
  3. data/MIT-LICENSE +4 -2
  4. data/README.rdoc +15 -14
  5. data/examples/performance.rb +33 -32
  6. data/examples/simple.rb +5 -4
  7. data/lib/active_record/aggregations.rb +267 -249
  8. data/lib/active_record/association_relation.rb +45 -7
  9. data/lib/active_record/associations/alias_tracker.rb +40 -43
  10. data/lib/active_record/associations/association.rb +172 -67
  11. data/lib/active_record/associations/association_scope.rb +105 -129
  12. data/lib/active_record/associations/belongs_to_association.rb +85 -59
  13. data/lib/active_record/associations/belongs_to_polymorphic_association.rb +13 -12
  14. data/lib/active_record/associations/builder/association.rb +57 -43
  15. data/lib/active_record/associations/builder/belongs_to.rb +74 -57
  16. data/lib/active_record/associations/builder/collection_association.rb +15 -33
  17. data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +57 -70
  18. data/lib/active_record/associations/builder/has_many.rb +13 -5
  19. data/lib/active_record/associations/builder/has_one.rb +44 -6
  20. data/lib/active_record/associations/builder/singular_association.rb +16 -10
  21. data/lib/active_record/associations/collection_association.rb +168 -279
  22. data/lib/active_record/associations/collection_proxy.rb +263 -155
  23. data/lib/active_record/associations/foreign_association.rb +33 -0
  24. data/lib/active_record/associations/has_many_association.rb +57 -84
  25. data/lib/active_record/associations/has_many_through_association.rb +70 -82
  26. data/lib/active_record/associations/has_one_association.rb +74 -47
  27. data/lib/active_record/associations/has_one_through_association.rb +20 -11
  28. data/lib/active_record/associations/join_dependency/join_association.rb +54 -73
  29. data/lib/active_record/associations/join_dependency/join_base.rb +10 -9
  30. data/lib/active_record/associations/join_dependency/join_part.rb +14 -14
  31. data/lib/active_record/associations/join_dependency.rb +175 -164
  32. data/lib/active_record/associations/preloader/association.rb +107 -112
  33. data/lib/active_record/associations/preloader/through_association.rb +85 -65
  34. data/lib/active_record/associations/preloader.rb +99 -96
  35. data/lib/active_record/associations/singular_association.rb +18 -45
  36. data/lib/active_record/associations/through_association.rb +49 -24
  37. data/lib/active_record/associations.rb +1845 -1597
  38. data/lib/active_record/attribute_assignment.rb +59 -185
  39. data/lib/active_record/attribute_methods/before_type_cast.rb +20 -7
  40. data/lib/active_record/attribute_methods/dirty.rb +168 -138
  41. data/lib/active_record/attribute_methods/primary_key.rb +93 -83
  42. data/lib/active_record/attribute_methods/query.rb +8 -10
  43. data/lib/active_record/attribute_methods/read.rb +19 -79
  44. data/lib/active_record/attribute_methods/serialization.rb +49 -24
  45. data/lib/active_record/attribute_methods/time_zone_conversion.rb +59 -36
  46. data/lib/active_record/attribute_methods/write.rb +25 -56
  47. data/lib/active_record/attribute_methods.rb +153 -162
  48. data/lib/active_record/attributes.rb +234 -70
  49. data/lib/active_record/autosave_association.rb +157 -69
  50. data/lib/active_record/base.rb +49 -50
  51. data/lib/active_record/callbacks.rb +234 -79
  52. data/lib/active_record/coders/json.rb +3 -1
  53. data/lib/active_record/coders/yaml_column.rb +46 -13
  54. data/lib/active_record/connection_adapters/abstract/connection_pool.rb +887 -317
  55. data/lib/active_record/connection_adapters/abstract/database_limits.rb +17 -41
  56. data/lib/active_record/connection_adapters/abstract/database_statements.rb +301 -113
  57. data/lib/active_record/connection_adapters/abstract/query_cache.rb +78 -24
  58. data/lib/active_record/connection_adapters/abstract/quoting.rb +187 -60
  59. data/lib/active_record/connection_adapters/abstract/savepoints.rb +9 -7
  60. data/lib/active_record/connection_adapters/abstract/schema_creation.rb +157 -93
  61. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +485 -253
  62. data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +79 -36
  63. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +909 -263
  64. data/lib/active_record/connection_adapters/abstract/transaction.rb +254 -92
  65. data/lib/active_record/connection_adapters/abstract_adapter.rb +492 -221
  66. data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +580 -608
  67. data/lib/active_record/connection_adapters/column.rb +67 -40
  68. data/lib/active_record/connection_adapters/deduplicable.rb +29 -0
  69. data/lib/active_record/connection_adapters/legacy_pool_manager.rb +35 -0
  70. data/lib/active_record/connection_adapters/mysql/column.rb +27 -0
  71. data/lib/active_record/connection_adapters/mysql/database_statements.rb +196 -0
  72. data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +71 -0
  73. data/lib/active_record/connection_adapters/mysql/quoting.rb +96 -0
  74. data/lib/active_record/connection_adapters/mysql/schema_creation.rb +97 -0
  75. data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +103 -0
  76. data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +91 -0
  77. data/lib/active_record/connection_adapters/mysql/schema_statements.rb +271 -0
  78. data/lib/active_record/connection_adapters/mysql/type_metadata.rb +40 -0
  79. data/lib/active_record/connection_adapters/mysql2_adapter.rb +81 -199
  80. data/lib/active_record/connection_adapters/pool_config.rb +73 -0
  81. data/lib/active_record/connection_adapters/pool_manager.rb +47 -0
  82. data/lib/active_record/connection_adapters/postgresql/column.rb +44 -11
  83. data/lib/active_record/connection_adapters/postgresql/database_statements.rb +78 -161
  84. data/lib/active_record/connection_adapters/postgresql/explain_pretty_printer.rb +44 -0
  85. data/lib/active_record/connection_adapters/postgresql/oid/array.rb +49 -57
  86. data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +9 -8
  87. data/lib/active_record/connection_adapters/postgresql/oid/bit_varying.rb +2 -0
  88. data/lib/active_record/connection_adapters/postgresql/oid/bytea.rb +5 -2
  89. data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +8 -6
  90. data/lib/active_record/connection_adapters/postgresql/oid/date.rb +13 -1
  91. data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +17 -13
  92. data/lib/active_record/connection_adapters/postgresql/oid/decimal.rb +3 -1
  93. data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +6 -3
  94. data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +31 -20
  95. data/lib/active_record/connection_adapters/postgresql/oid/inet.rb +2 -0
  96. data/lib/active_record/connection_adapters/postgresql/oid/interval.rb +49 -0
  97. data/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb +3 -11
  98. data/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb +44 -0
  99. data/lib/active_record/connection_adapters/postgresql/oid/macaddr.rb +25 -0
  100. data/lib/active_record/connection_adapters/postgresql/oid/money.rb +7 -9
  101. data/lib/active_record/connection_adapters/postgresql/oid/{infinity.rb → oid.rb} +5 -3
  102. data/lib/active_record/connection_adapters/postgresql/oid/point.rb +32 -11
  103. data/lib/active_record/connection_adapters/postgresql/oid/range.rb +70 -34
  104. data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +4 -1
  105. data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +67 -51
  106. data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +18 -4
  107. data/lib/active_record/connection_adapters/postgresql/oid/vector.rb +3 -1
  108. data/lib/active_record/connection_adapters/postgresql/oid/xml.rb +3 -1
  109. data/lib/active_record/connection_adapters/postgresql/oid.rb +25 -25
  110. data/lib/active_record/connection_adapters/postgresql/quoting.rb +171 -48
  111. data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +27 -14
  112. data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +80 -0
  113. data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +178 -108
  114. data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +49 -0
  115. data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +499 -293
  116. data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +44 -0
  117. data/lib/active_record/connection_adapters/postgresql/utils.rb +11 -8
  118. data/lib/active_record/connection_adapters/postgresql_adapter.rb +595 -382
  119. data/lib/active_record/connection_adapters/schema_cache.rb +191 -29
  120. data/lib/active_record/connection_adapters/sql_type_metadata.rb +45 -0
  121. data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +146 -0
  122. data/lib/active_record/connection_adapters/sqlite3/explain_pretty_printer.rb +21 -0
  123. data/lib/active_record/connection_adapters/sqlite3/quoting.rb +102 -0
  124. data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +21 -0
  125. data/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb +19 -0
  126. data/lib/active_record/connection_adapters/sqlite3/schema_dumper.rb +18 -0
  127. data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +170 -0
  128. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +322 -389
  129. data/lib/active_record/connection_adapters/statement_pool.rb +33 -13
  130. data/lib/active_record/connection_adapters.rb +52 -0
  131. data/lib/active_record/connection_handling.rb +314 -41
  132. data/lib/active_record/core.rb +488 -243
  133. data/lib/active_record/counter_cache.rb +71 -50
  134. data/lib/active_record/database_configurations/connection_url_resolver.rb +99 -0
  135. data/lib/active_record/database_configurations/database_config.rb +80 -0
  136. data/lib/active_record/database_configurations/hash_config.rb +96 -0
  137. data/lib/active_record/database_configurations/url_config.rb +53 -0
  138. data/lib/active_record/database_configurations.rb +273 -0
  139. data/lib/active_record/delegated_type.rb +209 -0
  140. data/lib/active_record/destroy_association_async_job.rb +36 -0
  141. data/lib/active_record/dynamic_matchers.rb +87 -106
  142. data/lib/active_record/enum.rb +212 -94
  143. data/lib/active_record/errors.rb +225 -54
  144. data/lib/active_record/explain.rb +27 -11
  145. data/lib/active_record/explain_registry.rb +4 -2
  146. data/lib/active_record/explain_subscriber.rb +11 -6
  147. data/lib/active_record/fixture_set/file.rb +33 -14
  148. data/lib/active_record/fixture_set/model_metadata.rb +32 -0
  149. data/lib/active_record/fixture_set/render_context.rb +17 -0
  150. data/lib/active_record/fixture_set/table_row.rb +152 -0
  151. data/lib/active_record/fixture_set/table_rows.rb +46 -0
  152. data/lib/active_record/fixtures.rb +273 -496
  153. data/lib/active_record/gem_version.rb +6 -4
  154. data/lib/active_record/inheritance.rb +175 -110
  155. data/lib/active_record/insert_all.rb +212 -0
  156. data/lib/active_record/integration.rb +121 -29
  157. data/lib/active_record/internal_metadata.rb +64 -0
  158. data/lib/active_record/legacy_yaml_adapter.rb +52 -0
  159. data/lib/active_record/locale/en.yml +3 -2
  160. data/lib/active_record/locking/optimistic.rb +103 -95
  161. data/lib/active_record/locking/pessimistic.rb +22 -6
  162. data/lib/active_record/log_subscriber.rb +93 -31
  163. data/lib/active_record/middleware/database_selector/resolver/session.rb +48 -0
  164. data/lib/active_record/middleware/database_selector/resolver.rb +92 -0
  165. data/lib/active_record/middleware/database_selector.rb +77 -0
  166. data/lib/active_record/migration/command_recorder.rb +185 -90
  167. data/lib/active_record/migration/compatibility.rb +298 -0
  168. data/lib/active_record/migration/join_table.rb +8 -7
  169. data/lib/active_record/migration.rb +685 -309
  170. data/lib/active_record/model_schema.rb +420 -113
  171. data/lib/active_record/nested_attributes.rb +265 -216
  172. data/lib/active_record/no_touching.rb +15 -2
  173. data/lib/active_record/null_relation.rb +24 -38
  174. data/lib/active_record/persistence.rb +574 -135
  175. data/lib/active_record/query_cache.rb +29 -23
  176. data/lib/active_record/querying.rb +50 -31
  177. data/lib/active_record/railtie.rb +175 -54
  178. data/lib/active_record/railties/console_sandbox.rb +3 -3
  179. data/lib/active_record/railties/controller_runtime.rb +34 -33
  180. data/lib/active_record/railties/databases.rake +533 -216
  181. data/lib/active_record/readonly_attributes.rb +9 -4
  182. data/lib/active_record/reflection.rb +485 -310
  183. data/lib/active_record/relation/batches/batch_enumerator.rb +85 -0
  184. data/lib/active_record/relation/batches.rb +217 -59
  185. data/lib/active_record/relation/calculations.rb +326 -244
  186. data/lib/active_record/relation/delegation.rb +76 -84
  187. data/lib/active_record/relation/finder_methods.rb +318 -256
  188. data/lib/active_record/relation/from_clause.rb +30 -0
  189. data/lib/active_record/relation/merger.rb +99 -84
  190. data/lib/active_record/relation/predicate_builder/array_handler.rb +26 -25
  191. data/lib/active_record/relation/predicate_builder/association_query_value.rb +42 -0
  192. data/lib/active_record/relation/predicate_builder/basic_object_handler.rb +19 -0
  193. data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +57 -0
  194. data/lib/active_record/relation/predicate_builder/range_handler.rb +22 -0
  195. data/lib/active_record/relation/predicate_builder/relation_handler.rb +7 -1
  196. data/lib/active_record/relation/predicate_builder.rb +139 -96
  197. data/lib/active_record/relation/query_attribute.rb +50 -0
  198. data/lib/active_record/relation/query_methods.rb +757 -409
  199. data/lib/active_record/relation/record_fetch_warning.rb +51 -0
  200. data/lib/active_record/relation/spawn_methods.rb +23 -21
  201. data/lib/active_record/relation/where_clause.rb +239 -0
  202. data/lib/active_record/relation.rb +554 -342
  203. data/lib/active_record/result.rb +91 -47
  204. data/lib/active_record/runtime_registry.rb +6 -4
  205. data/lib/active_record/sanitization.rb +134 -122
  206. data/lib/active_record/schema.rb +21 -24
  207. data/lib/active_record/schema_dumper.rb +141 -92
  208. data/lib/active_record/schema_migration.rb +24 -26
  209. data/lib/active_record/scoping/default.rb +96 -82
  210. data/lib/active_record/scoping/named.rb +78 -36
  211. data/lib/active_record/scoping.rb +45 -27
  212. data/lib/active_record/secure_token.rb +48 -0
  213. data/lib/active_record/serialization.rb +8 -6
  214. data/lib/active_record/signed_id.rb +116 -0
  215. data/lib/active_record/statement_cache.rb +89 -36
  216. data/lib/active_record/store.rb +133 -43
  217. data/lib/active_record/suppressor.rb +61 -0
  218. data/lib/active_record/table_metadata.rb +81 -0
  219. data/lib/active_record/tasks/database_tasks.rb +366 -129
  220. data/lib/active_record/tasks/mysql_database_tasks.rb +68 -100
  221. data/lib/active_record/tasks/postgresql_database_tasks.rb +87 -39
  222. data/lib/active_record/tasks/sqlite_database_tasks.rb +44 -19
  223. data/lib/active_record/test_databases.rb +24 -0
  224. data/lib/active_record/test_fixtures.rb +291 -0
  225. data/lib/active_record/timestamp.rb +86 -43
  226. data/lib/active_record/touch_later.rb +65 -0
  227. data/lib/active_record/transactions.rb +181 -152
  228. data/lib/active_record/translation.rb +3 -1
  229. data/lib/active_record/type/adapter_specific_registry.rb +126 -0
  230. data/lib/active_record/type/date.rb +4 -41
  231. data/lib/active_record/type/date_time.rb +4 -38
  232. data/lib/active_record/type/decimal_without_scale.rb +6 -2
  233. data/lib/active_record/type/hash_lookup_type_map.rb +12 -5
  234. data/lib/active_record/type/internal/timezone.rb +17 -0
  235. data/lib/active_record/type/json.rb +30 -0
  236. data/lib/active_record/type/serialized.rb +33 -15
  237. data/lib/active_record/type/text.rb +2 -2
  238. data/lib/active_record/type/time.rb +21 -16
  239. data/lib/active_record/type/type_map.rb +16 -19
  240. data/lib/active_record/type/unsigned_integer.rb +9 -8
  241. data/lib/active_record/type.rb +84 -23
  242. data/lib/active_record/type_caster/connection.rb +33 -0
  243. data/lib/active_record/type_caster/map.rb +23 -0
  244. data/lib/active_record/type_caster.rb +9 -0
  245. data/lib/active_record/validations/absence.rb +25 -0
  246. data/lib/active_record/validations/associated.rb +12 -4
  247. data/lib/active_record/validations/length.rb +26 -0
  248. data/lib/active_record/validations/numericality.rb +35 -0
  249. data/lib/active_record/validations/presence.rb +14 -13
  250. data/lib/active_record/validations/uniqueness.rb +65 -48
  251. data/lib/active_record/validations.rb +39 -35
  252. data/lib/active_record/version.rb +3 -1
  253. data/lib/active_record.rb +44 -28
  254. data/lib/arel/alias_predication.rb +9 -0
  255. data/lib/arel/attributes/attribute.rb +41 -0
  256. data/lib/arel/collectors/bind.rb +29 -0
  257. data/lib/arel/collectors/composite.rb +39 -0
  258. data/lib/arel/collectors/plain_string.rb +20 -0
  259. data/lib/arel/collectors/sql_string.rb +27 -0
  260. data/lib/arel/collectors/substitute_binds.rb +35 -0
  261. data/lib/arel/crud.rb +42 -0
  262. data/lib/arel/delete_manager.rb +18 -0
  263. data/lib/arel/errors.rb +9 -0
  264. data/lib/arel/expressions.rb +29 -0
  265. data/lib/arel/factory_methods.rb +49 -0
  266. data/lib/arel/insert_manager.rb +49 -0
  267. data/lib/arel/math.rb +45 -0
  268. data/lib/arel/nodes/and.rb +32 -0
  269. data/lib/arel/nodes/ascending.rb +23 -0
  270. data/lib/arel/nodes/binary.rb +126 -0
  271. data/lib/arel/nodes/bind_param.rb +44 -0
  272. data/lib/arel/nodes/case.rb +55 -0
  273. data/lib/arel/nodes/casted.rb +62 -0
  274. data/lib/arel/nodes/comment.rb +29 -0
  275. data/lib/arel/nodes/count.rb +12 -0
  276. data/lib/arel/nodes/delete_statement.rb +45 -0
  277. data/lib/arel/nodes/descending.rb +23 -0
  278. data/lib/arel/nodes/equality.rb +15 -0
  279. data/lib/arel/nodes/extract.rb +24 -0
  280. data/lib/arel/nodes/false.rb +16 -0
  281. data/lib/arel/nodes/full_outer_join.rb +8 -0
  282. data/lib/arel/nodes/function.rb +44 -0
  283. data/lib/arel/nodes/grouping.rb +11 -0
  284. data/lib/arel/nodes/homogeneous_in.rb +76 -0
  285. data/lib/arel/nodes/in.rb +15 -0
  286. data/lib/arel/nodes/infix_operation.rb +92 -0
  287. data/lib/arel/nodes/inner_join.rb +8 -0
  288. data/lib/arel/nodes/insert_statement.rb +37 -0
  289. data/lib/arel/nodes/join_source.rb +20 -0
  290. data/lib/arel/nodes/matches.rb +18 -0
  291. data/lib/arel/nodes/named_function.rb +23 -0
  292. data/lib/arel/nodes/node.rb +51 -0
  293. data/lib/arel/nodes/node_expression.rb +13 -0
  294. data/lib/arel/nodes/ordering.rb +27 -0
  295. data/lib/arel/nodes/outer_join.rb +8 -0
  296. data/lib/arel/nodes/over.rb +15 -0
  297. data/lib/arel/nodes/regexp.rb +16 -0
  298. data/lib/arel/nodes/right_outer_join.rb +8 -0
  299. data/lib/arel/nodes/select_core.rb +67 -0
  300. data/lib/arel/nodes/select_statement.rb +41 -0
  301. data/lib/arel/nodes/sql_literal.rb +19 -0
  302. data/lib/arel/nodes/string_join.rb +11 -0
  303. data/lib/arel/nodes/table_alias.rb +31 -0
  304. data/lib/arel/nodes/terminal.rb +16 -0
  305. data/lib/arel/nodes/true.rb +16 -0
  306. data/lib/arel/nodes/unary.rb +44 -0
  307. data/lib/arel/nodes/unary_operation.rb +20 -0
  308. data/lib/arel/nodes/unqualified_column.rb +22 -0
  309. data/lib/arel/nodes/update_statement.rb +41 -0
  310. data/lib/arel/nodes/values_list.rb +9 -0
  311. data/lib/arel/nodes/window.rb +126 -0
  312. data/lib/arel/nodes/with.rb +11 -0
  313. data/lib/arel/nodes.rb +70 -0
  314. data/lib/arel/order_predications.rb +13 -0
  315. data/lib/arel/predications.rb +250 -0
  316. data/lib/arel/select_manager.rb +270 -0
  317. data/lib/arel/table.rb +118 -0
  318. data/lib/arel/tree_manager.rb +72 -0
  319. data/lib/arel/update_manager.rb +34 -0
  320. data/lib/arel/visitors/dot.rb +308 -0
  321. data/lib/arel/visitors/mysql.rb +93 -0
  322. data/lib/arel/visitors/postgresql.rb +120 -0
  323. data/lib/arel/visitors/sqlite.rb +38 -0
  324. data/lib/arel/visitors/to_sql.rb +899 -0
  325. data/lib/arel/visitors/visitor.rb +45 -0
  326. data/lib/arel/visitors.rb +13 -0
  327. data/lib/arel/window_predications.rb +9 -0
  328. data/lib/arel.rb +54 -0
  329. data/lib/rails/generators/active_record/application_record/application_record_generator.rb +26 -0
  330. data/lib/rails/generators/active_record/application_record/templates/application_record.rb.tt +5 -0
  331. data/lib/rails/generators/active_record/migration/migration_generator.rb +43 -37
  332. data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb.tt +26 -0
  333. data/lib/rails/generators/active_record/migration/templates/{migration.rb → migration.rb.tt} +13 -10
  334. data/lib/rails/generators/active_record/migration.rb +35 -1
  335. data/lib/rails/generators/active_record/model/model_generator.rb +55 -22
  336. data/lib/rails/generators/active_record/model/templates/abstract_base_class.rb.tt +7 -0
  337. data/lib/rails/generators/active_record/model/templates/model.rb.tt +22 -0
  338. data/lib/rails/generators/active_record.rb +7 -5
  339. metadata +175 -65
  340. data/lib/active_record/associations/preloader/belongs_to.rb +0 -17
  341. data/lib/active_record/associations/preloader/collection_association.rb +0 -24
  342. data/lib/active_record/associations/preloader/has_many.rb +0 -17
  343. data/lib/active_record/associations/preloader/has_many_through.rb +0 -19
  344. data/lib/active_record/associations/preloader/has_one.rb +0 -23
  345. data/lib/active_record/associations/preloader/has_one_through.rb +0 -9
  346. data/lib/active_record/associations/preloader/singular_association.rb +0 -21
  347. data/lib/active_record/attribute.rb +0 -149
  348. data/lib/active_record/attribute_decorators.rb +0 -66
  349. data/lib/active_record/attribute_set/builder.rb +0 -86
  350. data/lib/active_record/attribute_set.rb +0 -77
  351. data/lib/active_record/connection_adapters/connection_specification.rb +0 -275
  352. data/lib/active_record/connection_adapters/mysql_adapter.rb +0 -491
  353. data/lib/active_record/connection_adapters/postgresql/array_parser.rb +0 -93
  354. data/lib/active_record/connection_adapters/postgresql/oid/float.rb +0 -21
  355. data/lib/active_record/connection_adapters/postgresql/oid/integer.rb +0 -11
  356. data/lib/active_record/connection_adapters/postgresql/oid/json.rb +0 -35
  357. data/lib/active_record/connection_adapters/postgresql/oid/time.rb +0 -11
  358. data/lib/active_record/railties/jdbcmysql_error.rb +0 -16
  359. data/lib/active_record/serializers/xml_serializer.rb +0 -193
  360. data/lib/active_record/type/big_integer.rb +0 -13
  361. data/lib/active_record/type/binary.rb +0 -50
  362. data/lib/active_record/type/boolean.rb +0 -30
  363. data/lib/active_record/type/decimal.rb +0 -40
  364. data/lib/active_record/type/decorator.rb +0 -14
  365. data/lib/active_record/type/float.rb +0 -19
  366. data/lib/active_record/type/integer.rb +0 -55
  367. data/lib/active_record/type/mutable.rb +0 -16
  368. data/lib/active_record/type/numeric.rb +0 -36
  369. data/lib/active_record/type/string.rb +0 -36
  370. data/lib/active_record/type/time_value.rb +0 -38
  371. data/lib/active_record/type/value.rb +0 -101
  372. data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb +0 -22
  373. data/lib/rails/generators/active_record/model/templates/model.rb +0 -10
  374. /data/lib/rails/generators/active_record/model/templates/{module.rb → module.rb.tt} +0 -0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveRecord
2
4
  class Migration
3
5
  # <tt>ActiveRecord::Migration::CommandRecorder</tt> records commands done during
@@ -5,15 +7,43 @@ module ActiveRecord
5
7
  # knows how to invert the following commands:
6
8
  #
7
9
  # * add_column
10
+ # * add_foreign_key
11
+ # * add_check_constraint
8
12
  # * add_index
13
+ # * add_reference
9
14
  # * add_timestamps
10
- # * create_table
15
+ # * change_column
16
+ # * change_column_default (must supply a :from and :to option)
17
+ # * change_column_null
18
+ # * change_column_comment (must supply a :from and :to option)
19
+ # * change_table_comment (must supply a :from and :to option)
11
20
  # * create_join_table
21
+ # * create_table
22
+ # * disable_extension
23
+ # * drop_join_table
24
+ # * drop_table (must supply a block)
25
+ # * enable_extension
26
+ # * remove_column (must supply a type)
27
+ # * remove_columns (must specify at least one column name or more)
28
+ # * remove_foreign_key (must supply a second table)
29
+ # * remove_check_constraint
30
+ # * remove_index
31
+ # * remove_reference
12
32
  # * remove_timestamps
13
33
  # * rename_column
14
34
  # * rename_index
15
35
  # * rename_table
16
36
  class CommandRecorder
37
+ ReversibleAndIrreversibleMethods = [
38
+ :create_table, :create_join_table, :rename_table, :add_column, :remove_column,
39
+ :rename_index, :rename_column, :add_index, :remove_index, :add_timestamps, :remove_timestamps,
40
+ :change_column_default, :add_reference, :remove_reference, :transaction,
41
+ :drop_join_table, :drop_table, :execute_block, :enable_extension, :disable_extension,
42
+ :change_column, :execute, :remove_columns, :change_column_null,
43
+ :add_foreign_key, :remove_foreign_key,
44
+ :change_column_comment, :change_table_comment,
45
+ :add_check_constraint, :remove_check_constraint
46
+ ]
17
47
  include JoinTable
18
48
 
19
49
  attr_accessor :commands, :delegate, :reverting
@@ -41,7 +71,7 @@ module ActiveRecord
41
71
  @reverting = !@reverting
42
72
  end
43
73
 
44
- # record +command+. +command+ should be a method name and arguments.
74
+ # Record +command+. +command+ should be a method name and arguments.
45
75
  # For example:
46
76
  #
47
77
  # recorder.record(:method_name, [:arg1, :arg2])
@@ -58,140 +88,205 @@ module ActiveRecord
58
88
  # recorder.inverse_of(:rename_table, [:old, :new])
59
89
  # # => [:rename_table, [:new, :old]]
60
90
  #
91
+ # If the inverse of a command requires several commands, returns array of commands.
92
+ #
93
+ # recorder.inverse_of(:remove_columns, [:some_table, :foo, :bar, type: :string])
94
+ # # => [[:add_column, :some_table, :foo, :string], [:add_column, :some_table, :bar, :string]]
95
+ #
61
96
  # This method will raise an +IrreversibleMigration+ exception if it cannot
62
97
  # invert the +command+.
63
98
  def inverse_of(command, args, &block)
64
99
  method = :"invert_#{command}"
65
- raise IrreversibleMigration unless respond_to?(method, true)
100
+ raise IrreversibleMigration, <<~MSG unless respond_to?(method, true)
101
+ This migration uses #{command}, which is not automatically reversible.
102
+ To make the migration reversible you can either:
103
+ 1. Define #up and #down methods in place of the #change method.
104
+ 2. Use the #reversible method to define reversible behavior.
105
+ MSG
66
106
  send(method, args, &block)
67
107
  end
68
108
 
69
- def respond_to?(*args) # :nodoc:
70
- super || delegate.respond_to?(*args)
71
- end
72
-
73
- [:create_table, :create_join_table, :rename_table, :add_column, :remove_column,
74
- :rename_index, :rename_column, :add_index, :remove_index, :add_timestamps, :remove_timestamps,
75
- :change_column_default, :add_reference, :remove_reference, :transaction,
76
- :drop_join_table, :drop_table, :execute_block, :enable_extension,
77
- :change_column, :execute, :remove_columns, :change_column_null,
78
- :add_foreign_key, :remove_foreign_key
79
- # irreversible methods need to be here too
80
- ].each do |method|
109
+ ReversibleAndIrreversibleMethods.each do |method|
81
110
  class_eval <<-EOV, __FILE__, __LINE__ + 1
82
111
  def #{method}(*args, &block) # def create_table(*args, &block)
83
112
  record(:"#{method}", args, &block) # record(:create_table, args, &block)
84
113
  end # end
85
114
  EOV
115
+ ruby2_keywords(method) if respond_to?(:ruby2_keywords, true)
86
116
  end
87
117
  alias :add_belongs_to :add_reference
88
118
  alias :remove_belongs_to :remove_reference
89
119
 
90
- def change_table(table_name, options = {}) # :nodoc:
120
+ def change_table(table_name, **options) # :nodoc:
91
121
  yield delegate.update_table_definition(table_name, self)
92
122
  end
93
123
 
124
+ def replay(migration)
125
+ commands.each do |cmd, args, block|
126
+ migration.send(cmd, *args, &block)
127
+ end
128
+ end
129
+
94
130
  private
131
+ module StraightReversions # :nodoc:
132
+ private
133
+ {
134
+ execute_block: :execute_block,
135
+ create_table: :drop_table,
136
+ create_join_table: :drop_join_table,
137
+ add_column: :remove_column,
138
+ add_index: :remove_index,
139
+ add_timestamps: :remove_timestamps,
140
+ add_reference: :remove_reference,
141
+ add_foreign_key: :remove_foreign_key,
142
+ add_check_constraint: :remove_check_constraint,
143
+ enable_extension: :disable_extension
144
+ }.each do |cmd, inv|
145
+ [[inv, cmd], [cmd, inv]].uniq.each do |method, inverse|
146
+ class_eval <<-EOV, __FILE__, __LINE__ + 1
147
+ def invert_#{method}(args, &block) # def invert_create_table(args, &block)
148
+ [:#{inverse}, args, block] # [:drop_table, args, block]
149
+ end # end
150
+ EOV
151
+ end
152
+ end
153
+ end
95
154
 
96
- module StraightReversions
97
- private
98
- { transaction: :transaction,
99
- execute_block: :execute_block,
100
- create_table: :drop_table,
101
- create_join_table: :drop_join_table,
102
- add_column: :remove_column,
103
- add_timestamps: :remove_timestamps,
104
- add_reference: :remove_reference,
105
- enable_extension: :disable_extension
106
- }.each do |cmd, inv|
107
- [[inv, cmd], [cmd, inv]].uniq.each do |method, inverse|
108
- class_eval <<-EOV, __FILE__, __LINE__ + 1
109
- def invert_#{method}(args, &block) # def invert_create_table(args, &block)
110
- [:#{inverse}, args, block] # [:drop_table, args, block]
111
- end # end
112
- EOV
155
+ include StraightReversions
156
+
157
+ def invert_transaction(args)
158
+ sub_recorder = CommandRecorder.new(delegate)
159
+ sub_recorder.revert { yield }
160
+
161
+ invertions_proc = proc {
162
+ sub_recorder.replay(self)
163
+ }
164
+
165
+ [:transaction, args, invertions_proc]
166
+ end
167
+
168
+ def invert_drop_table(args, &block)
169
+ if args.size == 1 && block == nil
170
+ raise ActiveRecord::IrreversibleMigration, "To avoid mistakes, drop_table is only reversible if given options or a block (can be empty)."
113
171
  end
172
+ super
114
173
  end
115
- end
116
174
 
117
- include StraightReversions
175
+ def invert_rename_table(args)
176
+ [:rename_table, args.reverse]
177
+ end
118
178
 
119
- def invert_drop_table(args, &block)
120
- if args.size == 1 && block == nil
121
- raise ActiveRecord::IrreversibleMigration, "To avoid mistakes, drop_table is only reversible if given options or a block (can be empty)."
179
+ def invert_remove_column(args)
180
+ raise ActiveRecord::IrreversibleMigration, "remove_column is only reversible if given a type." if args.size <= 2
181
+ super
122
182
  end
123
- super
124
- end
125
183
 
126
- def invert_rename_table(args)
127
- [:rename_table, args.reverse]
128
- end
184
+ def invert_remove_columns(args)
185
+ unless args[-1].is_a?(Hash) && args[-1].has_key?(:type)
186
+ raise ActiveRecord::IrreversibleMigration, "remove_columns is only reversible if given a type."
187
+ end
129
188
 
130
- def invert_remove_column(args)
131
- raise ActiveRecord::IrreversibleMigration, "remove_column is only reversible if given a type." if args.size <= 2
132
- super
133
- end
189
+ [:add_columns, args]
190
+ end
134
191
 
135
- def invert_rename_index(args)
136
- [:rename_index, [args.first] + args.last(2).reverse]
137
- end
192
+ def invert_rename_index(args)
193
+ table_name, old_name, new_name = args
194
+ [:rename_index, [table_name, new_name, old_name]]
195
+ end
138
196
 
139
- def invert_rename_column(args)
140
- [:rename_column, [args.first] + args.last(2).reverse]
141
- end
197
+ def invert_rename_column(args)
198
+ table_name, old_name, new_name = args
199
+ [:rename_column, [table_name, new_name, old_name]]
200
+ end
142
201
 
143
- def invert_add_index(args)
144
- table, columns, options = *args
145
- options ||= {}
202
+ def invert_remove_index(args)
203
+ options = args.extract_options!
204
+ table, columns = args
146
205
 
147
- index_name = options[:name]
148
- options_hash = index_name ? { name: index_name } : { column: columns }
206
+ columns ||= options.delete(:column)
149
207
 
150
- [:remove_index, [table, options_hash]]
151
- end
208
+ unless columns
209
+ raise ActiveRecord::IrreversibleMigration, "remove_index is only reversible if given a :column option."
210
+ end
211
+
212
+ options.delete(:if_exists)
152
213
 
153
- def invert_remove_index(args)
154
- table, options = *args
214
+ args = [table, columns]
215
+ args << options unless options.empty?
155
216
 
156
- unless options && options.is_a?(Hash) && options[:column]
157
- raise ActiveRecord::IrreversibleMigration, "remove_index is only reversible if given a :column option."
217
+ [:add_index, args]
158
218
  end
159
219
 
160
- options = options.dup
161
- [:add_index, [table, options.delete(:column), options]]
162
- end
220
+ alias :invert_add_belongs_to :invert_add_reference
221
+ alias :invert_remove_belongs_to :invert_remove_reference
163
222
 
164
- alias :invert_add_belongs_to :invert_add_reference
165
- alias :invert_remove_belongs_to :invert_remove_reference
223
+ def invert_change_column_default(args)
224
+ table, column, options = args
166
225
 
167
- def invert_change_column_null(args)
168
- args[2] = !args[2]
169
- [:change_column_null, args]
170
- end
226
+ unless options.is_a?(Hash) && options.has_key?(:from) && options.has_key?(:to)
227
+ raise ActiveRecord::IrreversibleMigration, "change_column_default is only reversible if given a :from and :to option."
228
+ end
171
229
 
172
- def invert_add_foreign_key(args)
173
- from_table, to_table, add_options = args
174
- add_options ||= {}
230
+ [:change_column_default, [table, column, from: options[:to], to: options[:from]]]
231
+ end
175
232
 
176
- if add_options[:name]
177
- options = { name: add_options[:name] }
178
- elsif add_options[:column]
179
- options = { column: add_options[:column] }
180
- else
181
- options = to_table
233
+ def invert_change_column_null(args)
234
+ args[2] = !args[2]
235
+ [:change_column_null, args]
182
236
  end
183
237
 
184
- [:remove_foreign_key, [from_table, options]]
185
- end
238
+ def invert_remove_foreign_key(args)
239
+ options = args.extract_options!
240
+ from_table, to_table = args
186
241
 
187
- # Forwards any missing method call to the \target.
188
- def method_missing(method, *args, &block)
189
- if @delegate.respond_to?(method)
190
- @delegate.send(method, *args, &block)
191
- else
242
+ to_table ||= options.delete(:to_table)
243
+
244
+ raise ActiveRecord::IrreversibleMigration, "remove_foreign_key is only reversible if given a second table" if to_table.nil?
245
+
246
+ reversed_args = [from_table, to_table]
247
+ reversed_args << options unless options.empty?
248
+
249
+ [:add_foreign_key, reversed_args]
250
+ end
251
+
252
+ def invert_change_column_comment(args)
253
+ table, column, options = args
254
+
255
+ unless options.is_a?(Hash) && options.has_key?(:from) && options.has_key?(:to)
256
+ raise ActiveRecord::IrreversibleMigration, "change_column_comment is only reversible if given a :from and :to option."
257
+ end
258
+
259
+ [:change_column_comment, [table, column, from: options[:to], to: options[:from]]]
260
+ end
261
+
262
+ def invert_change_table_comment(args)
263
+ table, options = args
264
+
265
+ unless options.is_a?(Hash) && options.has_key?(:from) && options.has_key?(:to)
266
+ raise ActiveRecord::IrreversibleMigration, "change_table_comment is only reversible if given a :from and :to option."
267
+ end
268
+
269
+ [:change_table_comment, [table, from: options[:to], to: options[:from]]]
270
+ end
271
+
272
+ def invert_remove_check_constraint(args)
273
+ raise ActiveRecord::IrreversibleMigration, "remove_check_constraint is only reversible if given an expression." if args.size < 2
192
274
  super
193
275
  end
194
- end
276
+
277
+ def respond_to_missing?(method, _)
278
+ super || delegate.respond_to?(method)
279
+ end
280
+
281
+ # Forwards any missing method call to the \target.
282
+ def method_missing(method, *args, &block)
283
+ if delegate.respond_to?(method)
284
+ delegate.public_send(method, *args, &block)
285
+ else
286
+ super
287
+ end
288
+ end
289
+ ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
195
290
  end
196
291
  end
197
292
  end
@@ -0,0 +1,298 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord
4
+ class Migration
5
+ module Compatibility # :nodoc: all
6
+ def self.find(version)
7
+ version = version.to_s
8
+ name = "V#{version.tr('.', '_')}"
9
+ unless const_defined?(name)
10
+ versions = constants.grep(/\AV[0-9_]+\z/).map { |s| s.to_s.delete("V").tr("_", ".").inspect }
11
+ raise ArgumentError, "Unknown migration version #{version.inspect}; expected one of #{versions.sort.join(', ')}"
12
+ end
13
+ const_get(name)
14
+ end
15
+
16
+ V6_1 = Current
17
+
18
+ class V6_0 < V6_1
19
+ class ReferenceDefinition < ConnectionAdapters::ReferenceDefinition
20
+ def index_options(table_name)
21
+ as_options(index)
22
+ end
23
+ end
24
+
25
+ module TableDefinition
26
+ def references(*args, **options)
27
+ options[:_uses_legacy_reference_index_name] = true
28
+ super
29
+ end
30
+ alias :belongs_to :references
31
+ end
32
+
33
+ def create_table(table_name, **options)
34
+ if block_given?
35
+ super { |t| yield compatible_table_definition(t) }
36
+ else
37
+ super
38
+ end
39
+ end
40
+
41
+ def change_table(table_name, **options)
42
+ if block_given?
43
+ super { |t| yield compatible_table_definition(t) }
44
+ else
45
+ super
46
+ end
47
+ end
48
+
49
+ def create_join_table(table_1, table_2, **options)
50
+ if block_given?
51
+ super { |t| yield compatible_table_definition(t) }
52
+ else
53
+ super
54
+ end
55
+ end
56
+
57
+ def add_reference(table_name, ref_name, **options)
58
+ if connection.adapter_name == "SQLite"
59
+ options[:type] = :integer
60
+ end
61
+
62
+ options[:_uses_legacy_reference_index_name] = true
63
+ super
64
+ end
65
+ alias :add_belongs_to :add_reference
66
+
67
+ private
68
+ def compatible_table_definition(t)
69
+ class << t
70
+ prepend TableDefinition
71
+ end
72
+ t
73
+ end
74
+ end
75
+
76
+ class V5_2 < V6_0
77
+ module TableDefinition
78
+ def timestamps(**options)
79
+ options[:precision] ||= nil
80
+ super
81
+ end
82
+ end
83
+
84
+ module CommandRecorder
85
+ def invert_transaction(args, &block)
86
+ [:transaction, args, block]
87
+ end
88
+
89
+ def invert_change_column_comment(args)
90
+ [:change_column_comment, args]
91
+ end
92
+
93
+ def invert_change_table_comment(args)
94
+ [:change_table_comment, args]
95
+ end
96
+ end
97
+
98
+ def create_table(table_name, **options)
99
+ if block_given?
100
+ super { |t| yield compatible_table_definition(t) }
101
+ else
102
+ super
103
+ end
104
+ end
105
+
106
+ def change_table(table_name, **options)
107
+ if block_given?
108
+ super { |t| yield compatible_table_definition(t) }
109
+ else
110
+ super
111
+ end
112
+ end
113
+
114
+ def create_join_table(table_1, table_2, **options)
115
+ if block_given?
116
+ super { |t| yield compatible_table_definition(t) }
117
+ else
118
+ super
119
+ end
120
+ end
121
+
122
+ def add_timestamps(table_name, **options)
123
+ options[:precision] ||= nil
124
+ super
125
+ end
126
+
127
+ private
128
+ def compatible_table_definition(t)
129
+ class << t
130
+ prepend TableDefinition
131
+ end
132
+ super
133
+ end
134
+
135
+ def command_recorder
136
+ recorder = super
137
+ class << recorder
138
+ prepend CommandRecorder
139
+ end
140
+ recorder
141
+ end
142
+ end
143
+
144
+ class V5_1 < V5_2
145
+ def change_column(table_name, column_name, type, **options)
146
+ if connection.adapter_name == "PostgreSQL"
147
+ super(table_name, column_name, type, **options.except(:default, :null, :comment))
148
+ connection.change_column_default(table_name, column_name, options[:default]) if options.key?(:default)
149
+ connection.change_column_null(table_name, column_name, options[:null], options[:default]) if options.key?(:null)
150
+ connection.change_column_comment(table_name, column_name, options[:comment]) if options.key?(:comment)
151
+ else
152
+ super
153
+ end
154
+ end
155
+
156
+ def create_table(table_name, **options)
157
+ if connection.adapter_name == "Mysql2"
158
+ super(table_name, options: "ENGINE=InnoDB", **options)
159
+ else
160
+ super
161
+ end
162
+ end
163
+ end
164
+
165
+ class V5_0 < V5_1
166
+ module TableDefinition
167
+ def primary_key(name, type = :primary_key, **options)
168
+ type = :integer if type == :primary_key
169
+ super
170
+ end
171
+
172
+ def references(*args, **options)
173
+ super(*args, type: :integer, **options)
174
+ end
175
+ alias :belongs_to :references
176
+ end
177
+
178
+ def create_table(table_name, **options)
179
+ if connection.adapter_name == "PostgreSQL"
180
+ if options[:id] == :uuid && !options.key?(:default)
181
+ options[:default] = "uuid_generate_v4()"
182
+ end
183
+ end
184
+
185
+ unless connection.adapter_name == "Mysql2" && options[:id] == :bigint
186
+ if [:integer, :bigint].include?(options[:id]) && !options.key?(:default)
187
+ options[:default] = nil
188
+ end
189
+ end
190
+
191
+ # Since 5.1 PostgreSQL adapter uses bigserial type for primary
192
+ # keys by default and MySQL uses bigint. This compat layer makes old migrations utilize
193
+ # serial/int type instead -- the way it used to work before 5.1.
194
+ unless options.key?(:id)
195
+ options[:id] = :integer
196
+ end
197
+
198
+ super
199
+ end
200
+
201
+ def create_join_table(table_1, table_2, column_options: {}, **options)
202
+ column_options.reverse_merge!(type: :integer)
203
+ super
204
+ end
205
+
206
+ def add_column(table_name, column_name, type, **options)
207
+ if type == :primary_key
208
+ type = :integer
209
+ options[:primary_key] = true
210
+ end
211
+ super
212
+ end
213
+
214
+ def add_reference(table_name, ref_name, **options)
215
+ super(table_name, ref_name, type: :integer, **options)
216
+ end
217
+ alias :add_belongs_to :add_reference
218
+
219
+ private
220
+ def compatible_table_definition(t)
221
+ class << t
222
+ prepend TableDefinition
223
+ end
224
+ super
225
+ end
226
+ end
227
+
228
+ class V4_2 < V5_0
229
+ module TableDefinition
230
+ def references(*, **options)
231
+ options[:index] ||= false
232
+ super
233
+ end
234
+ alias :belongs_to :references
235
+
236
+ def timestamps(**options)
237
+ options[:null] = true if options[:null].nil?
238
+ super
239
+ end
240
+ end
241
+
242
+ def add_reference(table_name, ref_name, **options)
243
+ options[:index] ||= false
244
+ super
245
+ end
246
+ alias :add_belongs_to :add_reference
247
+
248
+ def add_timestamps(table_name, **options)
249
+ options[:null] = true if options[:null].nil?
250
+ super
251
+ end
252
+
253
+ def index_exists?(table_name, column_name, **options)
254
+ column_names = Array(column_name).map(&:to_s)
255
+ options[:name] =
256
+ if options[:name].present?
257
+ options[:name].to_s
258
+ else
259
+ connection.index_name(table_name, column: column_names)
260
+ end
261
+ super
262
+ end
263
+
264
+ def remove_index(table_name, column_name = nil, **options)
265
+ options[:name] = index_name_for_remove(table_name, column_name, options)
266
+ super
267
+ end
268
+
269
+ private
270
+ def compatible_table_definition(t)
271
+ class << t
272
+ prepend TableDefinition
273
+ end
274
+ super
275
+ end
276
+
277
+ def index_name_for_remove(table_name, column_name, options)
278
+ index_name = connection.index_name(table_name, column_name || options)
279
+
280
+ unless connection.index_name_exists?(table_name, index_name)
281
+ if options.key?(:name)
282
+ options_without_column = options.except(:column)
283
+ index_name_without_column = connection.index_name(table_name, options_without_column)
284
+
285
+ if connection.index_name_exists?(table_name, index_name_without_column)
286
+ return index_name_without_column
287
+ end
288
+ end
289
+
290
+ raise ArgumentError, "Index name '#{index_name}' on table '#{table_name}' does not exist"
291
+ end
292
+
293
+ index_name
294
+ end
295
+ end
296
+ end
297
+ end
298
+ end
@@ -1,15 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveRecord
2
4
  class Migration
3
5
  module JoinTable #:nodoc:
4
6
  private
7
+ def find_join_table_name(table_1, table_2, options = {})
8
+ options.delete(:table_name) || join_table_name(table_1, table_2)
9
+ end
5
10
 
6
- def find_join_table_name(table_1, table_2, options = {})
7
- options.delete(:table_name) || join_table_name(table_1, table_2)
8
- end
9
-
10
- def join_table_name(table_1, table_2)
11
- ModelSchema.derive_join_table_name(table_1, table_2).to_sym
12
- end
11
+ def join_table_name(table_1, table_2)
12
+ ModelSchema.derive_join_table_name(table_1, table_2).to_sym
13
+ end
13
14
  end
14
15
  end
15
16
  end