aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/mysql/schema_definitions.rb
Commit message (Collapse)AuthorAgeFilesLines
* Refactor `type_to_sql` to handle converting `limit` to `size` in itselfRyuta Kamizono2019-02-261-10/+0
| | | | | Also, improving an argument error message for `limit`, extracting around `type_to_sql` code into schema statements, and more exercise tests.
* Refactor to extract defining column methods as `define_column_methods`Ryuta Kamizono2019-02-091-32/+40
| | | | | It makes to ease to handle all short-hand methods (e.g. validates arguments etc).
* Allow changing text and blob size without giving the `limit` optionRyuta Kamizono2019-01-291-0/+10
| | | | | | | | | | | | | | In MySQL, the text column size is 65,535 bytes by default (1 GiB in PostgreSQL). It is sometimes too short when people want to use a text column, so they sometimes change the text size to mediumtext (16 MiB) or longtext (4 GiB) by giving the `limit` option. Unlike MySQL, PostgreSQL doesn't allow the `limit` option for a text column (raises ERROR: type modifier is not allowed for type "text"). So `limit: 4294967295` (longtext) couldn't be used in Action Text. I've allowed changing text and blob size without giving the `limit` option, it prevents that migration failure on PostgreSQL.
* Emulate JSON types for SQLite3 adapter (#29664)Ryuta Kamizono2017-12-031-4/+0
| | | | | Actually SQLite3 doesn't have JSON storage class (so it is stored as a TEXT like Date and Time). But emulating JSON types is convinient for making database agnostic migrations.
* Extract `integer_like_primary_key_type` to ease to handle it for adaptersRyuta Kamizono2017-09-251-5/+5
|
* Move integer-like primary key normalization to `new_column_definition`Ryuta Kamizono2017-09-231-5/+4
| | | | | | Currently the normalization only exists in `primary_key` shorthand. It should be moved to `new_column_definition` to also affect to `add_column` with primary key.
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Correctly dump native timestamp types for MySQLRyuta Kamizono2017-02-231-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The native timestamp type in MySQL is different from datetime type. Internal representation of the timestamp type is UNIX time, This means that timestamp columns are affected by time zone. ``` > SET time_zone = '+00:00'; Query OK, 0 rows affected (0.00 sec) > INSERT INTO time_with_zone(ts,dt) VALUES (NOW(),NOW()); Query OK, 1 row affected (0.02 sec) > SELECT * FROM time_with_zone; +---------------------+---------------------+ | ts | dt | +---------------------+---------------------+ | 2016-02-07 22:11:44 | 2016-02-07 22:11:44 | +---------------------+---------------------+ 1 row in set (0.00 sec) > SET time_zone = '-08:00'; Query OK, 0 rows affected (0.00 sec) > SELECT * FROM time_with_zone; +---------------------+---------------------+ | ts | dt | +---------------------+---------------------+ | 2016-02-07 14:11:44 | 2016-02-07 22:11:44 | +---------------------+---------------------+ 1 row in set (0.00 sec) ```
* Refactor `ColumnDefinition` to contain `options` hashRyuta Kamizono2017-02-091-16/+3
| | | | | | 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.
* Virtual/generated column support for MySQL 5.7.5+ and MariaDB 5.2.0+Ryuta Kamizono2017-02-011-10/+14
| | | | | | | | | | | | | | | | | | | 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
* Tweak bigint PK handlingMatthew Draper2017-01-181-4/+2
| | | | | | * Don't force PKs on tables that have explicitly opted out * All integer-like PKs are autoincrement unless they have an explicit default
* Change MySQL and Postgresql to use Bigint primary keysJon McCartie2016-12-051-1/+4
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-3/+3
|
* Add short-hand methods for text and blob types in MySQLRyuta Kamizono2016-01-051-0/+24
| | | | | | | | | | | | | | | | | In Pg and Sqlite3, `:text` and `:binary` have variable unlimited length. But in MySQL, these have limited length for each types (ref #21591, #21619). This change adds short-hand methods for each text and blob types. Example: create_table :foos do |t| t.tinyblob :tiny_blob t.mediumblob :medium_blob t.longblob :long_blob t.tinytext :tiny_text t.mediumtext :medium_text t.longtext :long_text end
* Allow bigint with default nil for avoiding auto increment primary keyRyuta Kamizono2015-11-021-1/+1
| | | | Such as #10404, #18206.
* Fix to correctly schema dump the `tinyblob`Ryuta Kamizono2015-10-151-0/+4
| | | | | | Currently `tinyblob` is dumped to `t.binary "tiny_blob", limit: 255`. But `t.binary ... limit: 255` is generating SQL to `varchar(255)`. It is incorrect. This commit fixes this problem.
* Move schema definition classes into `mysql/schema_definitions.rb`Ryuta Kamizono2015-10-111-0/+65
Current master branch includes many schema definition improvements in MySQL. It extract these features to the appropriate file.