- 17 10月, 2018 1 次提交
-
-
由 Ryuta Kamizono 提交于
Follow up #32146.
-
- 22 9月, 2018 1 次提交
-
-
由 Mehmet Emin INAC 提交于
In case if we want to add a column into the existing table with index on it, we have to add column and index in two seperate lines. With this feature we don't need to write an extra line to add index for column. We can just use `index` option. Old behaviour in action: ``` change_table(:languages) do |t| t.string :country_code t.index: :country_code end ``` New behaviour in action: ``` change_table(:languages) do |t| t.string :country_code, index: true end ``` Exactly same behaviour is already exist for `create_table` migrations.
-
- 02 6月, 2018 1 次提交
-
-
由 Federico Martinez 提交于
-
- 15 5月, 2018 1 次提交
-
-
由 Ryuta Kamizono 提交于
Follow up of #19171 and #26825.
-
- 13 5月, 2018 1 次提交
-
-
由 wata_mac 提交于
`foreign_key`, `json` and `virtual` are also available.
-
- 22 3月, 2018 1 次提交
-
-
由 David Stosik 提交于
This makes more sense, as the foreign key ignore pattern is only used by the schema dumper.
-
- 20 3月, 2018 1 次提交
-
-
由 David Stosik 提交于
When dumping the database schema, Rails will dump foreign key names only if those names were not generate by Rails. Currently this is determined by checking if the foreign key name is `fk_rails_` followed by a 10-character hash. At [Cookpad](https://github.com/cookpad), we use [Departure](https://github.com/departurerb/departure) (Percona's pt-online-schema-change runner for ActiveRecord migrations) to run migrations. Often, `pt-osc` will make a copy of a table in order to run a long migration without blocking it. In this copy process, foreign keys are copied too, but [their name is prefixed with an underscore to prevent name collision ](https://www.percona.com/doc/percona-toolkit/LATEST/pt-online-schema-change.html#cmdoption-pt-online-schema-change-alter-foreign-keys-method). In the process described above, we often end up with a development database that contains foreign keys which name starts with `_fk_rails_`. That name does not match the ignore pattern, so next time Rails dumps the database schema (eg. when running `rake db:migrate`), our `db/schema.rb` file ends up containing those unwanted foreign key names. This also produces an unwanted git diff that we'd prefer not to commit. In this PR, I'd like to suggest a way to expose the foreign key name ignore pattern to the Rails configuration, so that individual projects can decide on a different pattern of foreign keys that will not get their names dumped in `schema.rb`.
-
- 18 2月, 2018 1 次提交
-
-
由 Jeremy Daer 提交于
-
- 03 12月, 2017 2 次提交
-
-
由 Ryuta Kamizono 提交于
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.
-
由 Ryuta Kamizono 提交于
-
- 01 12月, 2017 1 次提交
-
-
由 Travis Hunter 提交于
Add validate_constraint and update naming
-
- 30 11月, 2017 1 次提交
-
-
由 Greg Navis 提交于
Add support for specifying non-default operator classes in PostgreSQL indexes. An example CREATE INDEX query that becomes possible is: CREATE INDEX users_name ON users USING gist (name gist_trgm_ops); Previously it was possible to specify the `gist` index but not the custom operator class. The `add_index` call for the above query is: add_index :users, :name, using: :gist, opclasses: {name: :gist_trgm_ops}
-
- 25 9月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
-
- 23 9月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
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.
-
- 01 9月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
Fixes #30496.
-
- 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 提交于
-
- 19 5月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
This is a regression due to #28282. Fixes #29136.
-
- 17 4月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
Since 1a92ae83 all `indexes` methods are under the `SchemaStatements`.
-
- 16 4月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
* Use keyword arguments in `IndexDefinition` to ease to ignore unused options and to avoid to initialize incorrect empty value. * Place it in `SchemaStatements` for consistency. * And tiny tweaks.
-
- 04 3月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
Sharing `options` causes some unexpected behavior. If `limit: 2` is specified, this means that 2 bytes integer for a reference id column and 2 chars string for a reference type column. Another example, if `unsigned: true` is specified, this means that unsigned integer for a reference id column, but a invalid option for a reference type column. So `options` should not be shared with a reference type column.
-
- 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.
-
- 07 2月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
Follow up to #26266. The default type of `primary_key` and `references` were changed to `bigint` since #26266. But legacy migration and sqlite3 adapter should keep its previous behavior.
-
- 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
-
- 13 1月, 2017 1 次提交
-
-
由 Akira Matsuda 提交于
because Struct.new returns a Class, we just can give it a name and use it directly without inheriting from it
-
- 23 12月, 2016 1 次提交
-
-
由 Akira Matsuda 提交于
-
- 06 12月, 2016 1 次提交
-
-
由 Jon McCartie 提交于
-
- 20 10月, 2016 1 次提交
-
-
由 Orhan Toy 提交于
This commit fixes the generated HTML of the two code examples.
-
- 18 8月, 2016 1 次提交
-
-
invalid column type /activerecord/lib/active_record/connection_adapters /abstract/schema_definitions.rb:306 type = type.to_sym Changed to the following to handle nil case: type = type.to_sym if type Added regression test for this case: /activerecord/test/cases/migration_test.rb:554 if current_adapter?(:SQLite3Adapter) def test_allows_sqlite3_rollback_on_invalid_column_type Person.connection.create_table :something, force: true do |t| t.column :number, :integer t.column :name, :string t.column :foo, :bar end assert Person.connection.column_exists?(:something, :foo) assert_nothing_raised { Person.connection.remove_column :something, :foo, :bar } assert !Person.connection.column_exists?(:something, :foo) assert Person.connection.column_exists?(:something, :name) assert Person.connection.column_exists?(:something, :number) ensure Person.connection.drop_table :something, if_exists: true end end
-
- 14 8月, 2016 1 次提交
-
-
由 Ryuta Kamizono 提交于
Unfortunately `t.timestamps` in `create_table` allows unused splat args. But the same one in `change_table` does not allow them. This commit fixes the inconsistent behavior.
-
- 07 8月, 2016 3 次提交
-
-
由 Xavier Noria 提交于
-
由 Xavier Noria 提交于
-
由 Xavier Noria 提交于
The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
-
- 02 8月, 2016 1 次提交
-
-
由 Alex Robbin 提交于
-
- 02 6月, 2016 1 次提交
-
-
由 Sean Griffin 提交于
Currently CI is broken due to 56a61e0c and c4cb6862. This occurred because the failures are not present on SQLite which is what I normally run locally before pushing. The optimizations to our YAML size were dropping mutations, as `with_type` didn't set the previous value if it'd already been read (that method was never really designed to be used with values on individual objects, it was previously only used for defaults). I'm questioning whether there's a better place to be handling the exclusion of the type, but this will fix the failing build. Additionally, there was a bug in `remove_foreign_key` if you passed it an options hash containing `to_table`. This now occurs whenever removing a reference, as we always normalize to a hash. [Sean Griffin & Ryuta Kamizono]
-
- 19 4月, 2016 2 次提交
-
-
由 Ryuta Kamizono 提交于
-
由 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
-
- 16 2月, 2016 1 次提交
-
-
由 George Millo 提交于
Previously if you used `t.foreign_key` twice within the same `create_table` block using the same `to_table`, all statements except the final one would fail silently. For example, the following code: def change create_table :flights do |t| t.integer :from_id, index: true, null: false t.integer :to_id, index: true, null: false t.foreign_key :airports, column: :from_id t.foreign_key :airports, column: :to_id end end Would only create one foreign key, on the column `from_id`. This commit allows multiple foreign keys to the same table to be created within one `create_table` block.
-