Conversation
a3b47f5 to
4f8edc7
Compare
4296a73 to
87bdb2f
Compare
|
Thank you for Pull Request 😃 If ridgepole users use Active Record 6.1, I think ridgepole users should use Active Record 6.1 DSL. |
87bdb2f to
a023667
Compare
| module UseAlterIndex | ||
| def add_index(table_name, column_name, options = {}) | ||
| index_name, index_type, index_columns, index_options, _index_algorithm, index_using = add_index_options(table_name, column_name, **options) | ||
| if ActiveRecord.gem_version >= Gem::Version.new('6.1.0') |
There was a problem hiding this comment.
I think it would be better to remove the --mysql-use-alter option.
This option was added to alter add index to add an algorithm_option/lock_option (LOCK=NONE, ALGORITHM=INPLACE).
However, CREATE INDEX can also add algorithm_option/lock_option, so modify the --alter-extra option.
(Please wait a moment while I create a pull request.)
|
I think it's better to tolerate incompatibilities for AR 6.1 support, so I created a 0.9 branch. @alpaca-tc Would you please change the base branch of the pull request? |
Okay, I'll try to fix. 😄 |
|
@winebarrel hmm... 🤔 I'll try to add new options to set default hash parameters because I want to set Ooops, |
How about adding an option to pass a hash parameter? |
related: ridgepole#323 (comment) Added option `--table-hash-options` to set default hash table options. ``` ridgepole --table-hash-options='{ unsigned: true, charset: "utf8mb4" }' ```
related: ridgepole#323 (comment) Added option `--table-hash-options` to set default hash table options. ``` ridgepole --table-hash-options='{ unsigned: true, charset: "utf8mb4" }' ```
related: ridgepole#323 (comment) Added option `--table-hash-options` to set default hash table options. ``` ridgepole --table-hash-options='{ unsigned: true, charset: "utf8mb4" }' ```
related: ridgepole#323 (comment) Added option `--table-hash-options` to set default hash table options. ``` ridgepole --table-hash-options='{ unsigned: true, charset: "utf8mb4" }' ```
a023667 to
43ab113
Compare
related: ridgepole#323 (comment) Added option `--table-hash-options` to set default hash table options. ``` ridgepole --table-hash-options='{ "id": { "unsigned": true }, "charset": "utf8mb4" }' ```
c5bb5e1 to
a028f00
Compare
related: ridgepole#323 (comment) Added option `--table-hash-options` to set default hash table options. ``` ridgepole --table-hash-options='{ "id": { "unsigned": true }, "charset": "utf8mb4" }' ```
a028f00 to
0e18f30
Compare
table options are parsed charset/collation in 6.1.0. related: rails/rails#39365 ``` // before // < 6.1.0 create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci" do |t| end // after // >= 6.1.0 create_table "users", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci" do |t| end ``` If `dump_without_table_options` is disabled, ridgepole doesn't dump charset/collation.
In 6.1, table options are parsed to charset/collation. rails/rails#39365 The following cases should be same result. ``` create_table "items", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci" do |t| end create_table "items", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci" do |t| end ``` To solve this I handled that if new-style `charset/collation` given, it converts to old-style `options`. By doing so, I solved the problem by a little changes. https://github.com/rails/rails/pull/39365/files#diff-868f1dccfcbed26a288bf9f3fd8a39c863a4413ab0075e12b6805d9798f556d1R427
rails/rails#39365 introduced new-style id options like the followings. ``` // < 6.1 old-style create_table(:items, id: :bigint, unsigned: true) {} // >= 6.1 new-style create_table(:items, id: { type: :bigint, unsigned: true }) {} ``` To compare those styles to get diff, I handled that I normalizes id options from those styles.
Unary plus operator is faster than `dup`.
fc7df19 to
eaf9fa0
Compare
eaf9fa0 to
e2dbafe
Compare
|
The test code is redundant, why don't you modify it as follows? ERBh.define_method(:cond) do |conds, m, e = nil|
if conds.is_a?(Hash)
return conds.find do |c, _|
condition(*Array(c))
end&.last || m
end
if condition(*Array(conds))
m
else
e || (begin
m.class.new
rescue StandardError
nil
end)
end
endusage create_table "employee_clubs", <%= i cond(">= 5.1, < 6.1" => {id: :bigint}, ">= 6.1" => { id: { type: :bigint, unsigned: true } }, { unsigned: true }) %>, force: :cascade do |t| |
67ffbb5 to
ee90f98
Compare
f4d2db0 to
1121e64
Compare
1121e64 to
fd3e271
Compare
|
@winebarrel all done 🎉 |
| end | ||
|
|
||
| ERBh.define_method(:cond) do |conds, m, e = nil| | ||
| if condition(*Array(conds)) |
There was a problem hiding this comment.
Currently conds is only Numeric or String so *Array() is not needed.
|
v0.9.0.beta has been released |
previous PR #331
Affected changes in 6.1.0
Deprecate
connection_configActiveRecord::Base. connection_configis deprecated. UseActiveRecord::Base.connection_db_config.configuration_hashinstead of.Default engine
ENGINE=InnoDBis no longer dumped to make schema more agnostic"ENGINE=InnoDB"is deleted because it is default engine.id: { type: :bigint, unsigned: true }Refactor index creation to use index definition visitor
add_indexhave been refactored. Currently,add_index_optionsreturns only three parameters.remove_indexcalls.Summary
Add support for Rails 6.1.
ActiveRecord::Base.connection_db_config.configuration_hashinstead ofActiveRecord::Base. connection_config.add_index/remove_indexmethods inUseAlterIndexbecause it doesn't work in 6.1.0.without_table_optionsis enabled. Because charset/collations options are same as old-style raw table options.charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci") with old-styleoptions: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci". New style table options will be converted to old-style options inRidgepole::Diff.id: { type: :bigint, unsigned: true }orid: :bigint, unsigned: true) to same result to compare those styles.I'm not sure test policy, so I did not add new test. But if need, please let me know.