- 24 5月, 2020 1 次提交
-
-
由 Ryuta Kamizono 提交于
5 years ago, I made dumping full table options at #17569, especially to dump `ENGINE=InnoDB ROW_FORMAT=DYNAMIC` to use utf8mb4 with large key prefix. In that time, omitting the default engine `ENGINE=InnoDB` was not useful since `ROW_FORMAT=DYNAMIC` always remains as long as using utf8mb4 with large key prefix. But now, MySQL 5.7.9 has finally changed the default row format to DYNAMIC, utf8mb4 with large key prefix can be used without dumping the default engine and the row format explicitly. So now is a good time to make the default engine is omitted. Before: ```ruby create_table "accounts", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci", force: :cascade do |t| end ``` After: ```ruby create_table "accounts", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| end ``` To entirely omit `:options` option to make schema agnostic, I've added `:charset` and `:collation` table options to exclude `CHARSET` and `COLLATE` from `:options`. Fixes #26209. Closes #29472. See also #33608, #33853, and #34742.
-
- 10 5月, 2020 1 次提交
-
-
由 Ryuta Kamizono 提交于
Current SQL generation code is hard to maintenance, I've found a bug that create index comment in bulk change table when I'm refactoring that.
-
- 15 9月, 2019 1 次提交
-
-
由 Akira Matsuda 提交于
-
- 13 9月, 2019 1 次提交
-
-
由 Eugene Kenny 提交于
In 7254d237, an autoload for `ConnectionAdapters::AbstractAdapter` was added to `active_record.rb`. Later in d6b923ad, a manual require for that class was added to `active_record/base.rb` as some constants under `ConnectionAdapters` weren't defined until `AbstractAdapter` was loaded. In 1efd8828, the require was removed and replaced with an autoload in `active_record.rb`, above the previous one. Because the first autoload was for the `ConnectionAdapters` constant and the second one tried to create it, the autoload would fire immediately. Rather than fixing the autoload problem, the require had effectively just been moved from `active_record/base.rb` to `active_record.rb`. Instead of defining autoloads for constants under `ConnectionAdapters` in the `abstract_adapter.rb` file, we can create a separate, autoloaded `connection_adapters.rb` file for this purpose. To avoid a "circular require considered harmful" warning from Ruby, we have to fix the module nesting in `schema_creation.rb`, as a followup to e4108fc6. `AbstractAdapter` loads many other dependencies, so making it autoload properly has a noticeable impact on the load time of `active_record.rb`. Benchmark: $ cat test.rb require "bundler/setup" before = ObjectSpace.each_object(Module).count start = Process.clock_gettime(Process::CLOCK_MONOTONIC) require "active_record" finish = Process.clock_gettime(Process::CLOCK_MONOTONIC) after = ObjectSpace.each_object(Module).count puts "took #{finish - start} and created #{after - before} modules" Before: $ ruby test.rb took 0.47532399999909103 and created 901 modules After: $ ruby test.rb took 0.3299509999342263 and created 608 modules
-
- 13 6月, 2019 1 次提交
-
-
由 Ryuta Kamizono 提交于
We sometimes say "
✂ ️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost.
-
- 11 2月, 2019 2 次提交
-
-
由 Ryuta Kamizono 提交于
I implemented Foreign key create in `create_table` for SQLite3 at #24743. This follows #24743 to implement `add_foreign_key` and `remove_foreign_key`. Unfortunately SQLite3 has one limitation that `PRAGMA foreign_key_list(table-name)` doesn't have constraint name. So we couldn't implement find/remove foreign key by name for now. Fixes #35207. Closes #31343.
-
由 Ryuta Kamizono 提交于
-
- 13 11月, 2018 1 次提交
-
-
由 Jacob Evelyn 提交于
This commit adds support for the `ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.create_unlogged_tables` setting, which turns `CREATE TABLE` SQL statements into `CREATE UNLOGGED TABLE` statements. This can improve PostgreSQL performance but at the cost of data durability, and thus it is highly recommended that you *DO NOT* enable this in a production environment.
-
- 08 11月, 2018 1 次提交
-
-
由 fatkodima 提交于
[fatkodima & Stefan Kanev]
-
- 23 9月, 2018 1 次提交
-
-
由 yuuji.yaginuma 提交于
In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`. ```ruby # frozen_string_literal: true require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "benchmark-ips" end Benchmark.ips do |x| x.report('+@') { +"" } x.report('dup') { "".dup } x.compare! end ``` ``` $ ruby -v benchmark.rb ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] Warming up -------------------------------------- +@ 282.289k i/100ms dup 187.638k i/100ms Calculating ------------------------------------- +@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s Comparison: +@: 6775299.3 i/s dup: 3320400.7 i/s - 2.04x slower ```
-
- 02 3月, 2018 1 次提交
-
-
由 Ryuta Kamizono 提交于
Duplicated method name list is no longer needed.
-
- 17 2月, 2018 2 次提交
-
-
由 Jeremy Daer 提交于
References 89bcca59
-
由 Rafael Mendonça França 提交于
Some places we can't remove because Ruby still don't have a method equivalent to strip_heredoc to be called in an already existent string.
-
- 20 12月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
Follow up of #31177.
-
- 04 9月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
Otherwise using reserved words as composite primary key names will be failed as an invalid SQL. Fixes #30518.
-
- 20 7月, 2017 1 次提交
-
-
由 Kir Shatrov 提交于
-
- 02 7月, 2017 1 次提交
-
-
由 Matthew Draper 提交于
This reverts commit 3420a145, reversing changes made to afb66a5a.
-
- 01 7月, 2017 1 次提交
-
-
由 Kir Shatrov 提交于
-
- 20 6月, 2017 1 次提交
-
-
由 Pat Allan 提交于
-
- 13 6月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
If a relation has binds, `connection.to_sql(relation)` without binds will generate invalid SQL. It should use `relation.to_sql` in that case.
-
- 26 3月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
-
- 09 2月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
Column options are passed as an hash args then used as `options` hash in `add_column_options!`. Converting args to attributes is inconvinient for using options as an hash.
-
- 02 2月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
MySQL generated columns: https://dev.mysql.com/doc/refman/5.7/en/create-table-generated-columns.html MariaDB virtual columns: https://mariadb.com/kb/en/mariadb/virtual-computed-columns/ Declare virtual columns with `t.virtual name, type: …, as: "expression"`. Pass `stored: true` to persist the generated value (false by default). Example: create_table :generated_columns do |t| t.string :name t.virtual :upper_name, type: :string, as: "UPPER(name)" t.virtual :name_length, type: :integer, as: "LENGTH(name)", stored: true t.index :name_length # May be indexed, too! end Closes #22589
-
- 17 1月, 2017 1 次提交
-
-
- 07 8月, 2016 1 次提交
-
-
由 Xavier Noria 提交于
The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
-
- 19 4月, 2016 1 次提交
-
-
由 Jeremy Daer 提交于
* Switch to keyword args where we can without breaking compat. * Use add_table_options! for :options, too. * Some code polish.
-
- 16 4月, 2016 1 次提交
-
-
由 Andrey Novikov 提交于
Comments are specified in migrations, stored in database itself (in its schema), and dumped into db/schema.rb file. This allows to generate good documentation and explain columns and tables' purpose to everyone from new developers to database administrators. For PostgreSQL and MySQL only. SQLite does not support comments at the moment. See docs for PostgreSQL: http://www.postgresql.org/docs/current/static/sql-comment.html See docs for MySQL: http://dev.mysql.com/doc/refman/5.7/en/create-table.html
-
- 20 9月, 2015 2 次提交
-
-
由 Ryuta Kamizono 提交于
If foreign keys specified in create table, generated SQL is slightly more efficient. Definition: ``` create_table :testings do |t| t.references :testing_parent, foreign_key: true end ``` Before: ``` CREATE TABLE "testings" ("id" serial primary key, "testing_parent_id" integer); ALTER TABLE "testings" ADD CONSTRAINT "fk_rails_a196c353b2" FOREIGN KEY ("testing_parent_id") REFERENCES "testing_parents" ("id"); ``` After: ``` CREATE TABLE "testings" ("id" serial primary key, "testing_parent_id" integer, CONSTRAINT "fk_rails_a196c353b2" FOREIGN KEY ("testing_parent_id") REFERENCES "testing_parents" ("id")); ```
-
由 Ryuta Kamizono 提交于
Example: create_table :barcodes, primary_key: ["region", "code"] do |t| t.string :region t.integer :code end
-
- 16 9月, 2015 1 次提交
-
-
由 Ryuta Kamizono 提交于
-
- 13 9月, 2015 1 次提交
-
-
由 Ryuta Kamizono 提交于
Follow up 7ba2cd06.
-
- 04 5月, 2015 1 次提交
-
-
由 Ryuta Kamizono 提交于
Some databases like MySQL allow defining collation charset for specific columns.
-
- 03 5月, 2015 1 次提交
-
-
由 Ryuta Kamizono 提交于
-
- 19 2月, 2015 1 次提交
-
-
由 Ryuta Kamizono 提交于
-
- 11 2月, 2015 1 次提交
-
-
由 Ryuta Kamizono 提交于
`quote_default_expression` and `quote_default_value` are almost the same handling for do not quote default function of `:uuid` columns. Rename `quote_default_value` to `quote_default_expression`, and remove duplicate code.
-
- 08 2月, 2015 1 次提交
-
-
由 Ryuta Kamizono 提交于
`sql_type` is reused in `lookup_cast_type`. If making it a part of `sql_type` when handled array option first, it isn't necessary to do again.
-
- 04 1月, 2015 1 次提交
-
-
由 Ryuta Kamizono 提交于
No need to call `type_to_sql` again.
-
- 02 1月, 2015 1 次提交
-
-
由 Sean Griffin 提交于
The column is no longer used for anything besides type casting, which is what we're trying to remove from the column entirely.
-
- 28 12月, 2014 2 次提交
-
-
由 Ryuta Kamizono 提交于
Example: create_table :foos, id: :bigint do |t| end
-
由 Ryuta Kamizono 提交于
-