diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2015-12-15 05:26:14 +0900 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2017-02-01 22:13:46 -0700 |
commit | 65bf1c60053e727835e06392d27a2fb49665484c (patch) | |
tree | 02a5a5b0cead003b2d24c2419585748830b4416e /activerecord/test/cases/migration | |
parent | c98e08df7a303f4c7d6d37aa638d4ce97bb1ec9c (diff) | |
download | rails-65bf1c60053e727835e06392d27a2fb49665484c.tar.gz rails-65bf1c60053e727835e06392d27a2fb49665484c.tar.bz2 rails-65bf1c60053e727835e06392d27a2fb49665484c.zip |
Virtual/generated column support for MySQL 5.7.5+ and MariaDB 5.2.0+
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
Diffstat (limited to 'activerecord/test/cases/migration')
-rw-r--r-- | activerecord/test/cases/migration/change_table_test.rb | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/activerecord/test/cases/migration/change_table_test.rb b/activerecord/test/cases/migration/change_table_test.rb index 8a4242cf1d..ec817a579b 100644 --- a/activerecord/test/cases/migration/change_table_test.rb +++ b/activerecord/test/cases/migration/change_table_test.rb @@ -101,12 +101,7 @@ module ActiveRecord def test_primary_key_creates_primary_key_column with_change_table do |t| - if current_adapter?(:Mysql2Adapter) - @connection.expect :add_column, nil, [:delete_me, :id, :primary_key, { first: true, auto_increment: true, limit: 8, primary_key: true }] - else - @connection.expect :add_column, nil, [:delete_me, :id, :primary_key, primary_key: true, first: true] - end - + @connection.expect :add_column, nil, [:delete_me, :id, :primary_key, primary_key: true, first: true] t.primary_key :id, first: true end end |