aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/migration
Commit message (Collapse)AuthorAgeFilesLines
* Use type column first in multi-column indexesDerek Prior2014-10-242-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | `add_reference` can very helpfully add a multi-column index when you use it to add a polymorphic reference. However, the first column in the index is the `id` column, which is less than ideal. The [PostgreSQL docs][1] say: > A multicolumn B-tree index can be used with query conditions that > involve any subset of the index's columns, but the index is most > efficient when there are constraints on the leading (leftmost) > columns. The [MySQL docs][2] say: > MySQL can use multiple-column indexes for queries that test all the > columns in the index, or queries that test just the first column, the > first two columns, the first three columns, and so on. If you specify > the columns in the right order in the index definition, a single > composite index can speed up several kinds of queries on the same > table. In a polymorphic relationship, the type column is much more likely to be useful as the first column in an index than the id column. That is, I'm more likely to query on type without an id than I am to query on id without a type. [1]: http://www.postgresql.org/docs/9.3/static/indexes-multicolumn.html [2]: http://dev.mysql.com/doc/refman/5.0/en/multiple-column-indexes.html
* add table.bigint supportAaron Patterson2014-10-151-0/+19
| | | | | | | | In the DSL you can now do: create_table(:foos) do |t| t.bigint :hi end
* Replace drop sql statement to drop_table methodYasuo Honda2014-09-111-2/+2
| | | | to drop sequences at the same time each tables dropped for Oracle
* Added enable_extension! to helperAbdelkader Boudih2014-09-051-1/+2
|
* Remove 'if exists' from drop table statement then use `table_exists?`Yasuo Honda2014-09-031-2/+2
| | | | | Since 'drop table if exists' statement does not always work with some databases such as Oracle.
* Bring original puts back after finishing testsAkira Matsuda2014-08-291-4/+0
|
* Merge pull request #16481 from sgrif/sg-change-default-timestampsDavid Heinemeier Hansson2014-08-173-5/+8
|\ | | | | Change the default `null` value for timestamps
| * Change the default `null` value for timestampsSean Griffin2014-08-123-5/+8
| | | | | | | | | | | | | | As per discussion, this changes the model generators to specify `null: false` for timestamp columns. A warning is now emitted if `timestamps` is called without a `null` option specified, so we can safely change the behavior when no option is specified in Rails 5.
* | Be sure to reset PK name renamed in the testAkira Matsuda2014-08-151-0/+3
| |
* | `index_exists?` with `:name` checks specified columns.Yves Senn2014-08-131-0/+6
|/ | | | | | | | | | | | | | | [Yves Senn & Matthew Draper] The column check was embodied in the defaul index name. If the :name option was used, the specified columns were not verified at all. Given: ``` assert connection.index_exists?(table_name, :foo_id, :name => :index_testings_on_yo_momma) ``` That index could have been defined on any field, not necessarily on `:foo_id`.
* rename MiniTest to MinitestRajarshi Das2014-08-021-2/+2
|
* Merge pull request #16231 from Envek/type_in_referencesYves Senn2014-07-222-0/+19
|\ | | | | | | | | | | * Allow to specify a type for foreign key column in migrations * unified the docs * some cleanup in CHANGELOG
| * Allow to specify a type for foreign key column in migrationsAndrey Novikov2014-07-222-0/+24
|/ | | | [Andrey Novikov & Łukasz Sarnacki]
* create_join_table uses same logic as HABTM reflectionsStefan Kanev2014-07-181-0/+24
| | | | | | | | Before this change, create_join_table would not remove the common prefix in the join table name, unlike ActiveRecord::Reflections. A HABTM between Music::Artist and Music::Record would use a table music_artists_records, while create_join table would create music_artists_music_records.
* Disable some tests on SQLiteRafael Mendonça França2014-07-171-77/+77
| | | | | These tests were passing before because the precision were not using to cast the value. Not it is being used so it would fail on sqlite3
* do not hold on to a stale connection object. fixes #15998Aaron Patterson2014-07-011-2/+5
|
* rename sequence only if it existsAbdelkader Boudih2014-06-271-0/+10
|
* fk: use random digest namesYves Senn2014-06-261-14/+17
| | | | | | The name of the foreign key is not relevant from a users perspective. Using random names resolves the urge to rename the foreign key when the respective table or column is renamed.
* fk: raise for invalid :on_update / :on_delete valuesYves Senn2014-06-261-0/+10
|
* fk: `add/remove_foreign_key` are noop for adapters that don't support fkYves Senn2014-06-261-0/+24
|
* fk: raise when identifiers are longer than `allowed_index_name_length`.Yves Senn2014-06-261-0/+9
|
* fk: support for on_updateYves Senn2014-06-261-3/+13
|
* fk: rename `dependent` to `on_delete`Yves Senn2014-06-261-13/+13
|
* fk: infere column name from table names.Yves Senn2014-06-262-2/+29
| | | | This allows to create and remove foreign keys without specifying a column.
* fk: make `add_foreign_key` reversible.Yves Senn2014-06-262-0/+39
|
* fk: support dependent option (:delete, :nullify and :restrict).Yves Senn2014-06-261-0/+42
|
* fk: dump foreign keys to schema.rbYves Senn2014-06-261-0/+7
| | | | respect `table_name_prefix` and `table_name_suffix`.
* fk: `:primary_key` option for non-standard pk's.Yves Senn2014-06-261-0/+20
|
* fk: generalize using `AlterTable` and `SchemaCreation`.Yves Senn2014-06-261-2/+4
|
* fk: `foreign_keys`, `add_foreign_key` and `remove_foreign_key` for MySQLYves Senn2014-06-261-0/+5
|
* fk: add `foreign_keys` for PostgreSQL adapter.Yves Senn2014-06-261-7/+27
|
* fk: `add_foreign_key` and `remove_foreign_key` for PostgreSQL adapter.Yves Senn2014-06-261-0/+49
|
* Merge pull request #15782 from sgrif/sg-column-defaultsMatthew Draper2014-06-182-12/+19
|\ | | | | Don't type cast the default on the column
| * Don't type cast the default on the columnSean Griffin2014-06-172-12/+19
| | | | | | | | | | | | | | If we want to have type decorators mess with the attribute, but not the column, we need to stop type casting on the column. Where possible, we changed the tests to test the value of `column_defaults`, which is public API. `Column#default` is not.
* | Merge pull request #15727 from aditya-kapoor/add-tests-for-migrationMatthew Draper2014-06-181-0/+17
|\ \ | |/ |/| Add test cases for Migration#inverse_of
| * Add test cases for Migration#inverse_ofAditya Kapoor2014-06-171-0/+17
| |
* | Merge pull request #13963 from lucas-clemente/pending_migrationsRafael Mendonça França2014-06-161-0/+50
|\ \ | | | | | | Skip migration check if adapter doesn't support it
| * | skip migration check if adapter doesn't support itLucas Clemente2014-04-191-0/+50
| | |
* | | /mysql/i -> MySQL, Spell correct in continuation to #15555Akshay Vishnoi2014-06-142-2/+2
| |/ |/|
* | pg, `reset_pk_sequence!` respects schemas. Closes #14719.Yves Senn2014-05-301-1/+1
| |
* | fix `rake test_sqlite3_mem`.Yves Senn2014-05-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While running Sqlite3 memory tests I encountered the following error: ``` Finished in 69.416366s, 58.0267 runs/s, 162.3681 assertions/s. 1) Error: ActiveRecord::Migration::ChangeSchemaTest#test_add_column_with_timestamp_type: NoMethodError: undefined method `type' for nil:NilClass /Users/senny/Projects/rails/activerecord/test/cases/migration/change_schema_test.rb:244:in `test_add_column_with_timestamp_type' 4028 runs, 11271 assertions, 0 failures, 1 errors, 1 skips ``` This was because the table `testings` was used in multiple test-cases. This resulted in a wrongly cached schema on `ActiveRecord::Base.schema_chae`. /cc @zuhao
* | Remove :timestamp column typeSean Griffin2014-05-191-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | The `:timestamp` type for columns is unused. All database adapters treat them as the same database type. All code in `ActiveRecord` which changes its behavior based on the column's type acts the same in both cases. However, when the type is passed to code that checks for the `:datetime` type, but not `:timestamp` (such as XML serialization), the result is unexpected behavior. Existing schema definitions will continue to work, and the `timestamp` type is transparently aliased to `datetime`.
* | Make `:index` in migrations work with all column typesMarc Schütz2014-05-181-0/+10
| |
* | Remove dead test code for unsupported adaptersSean Griffin2014-05-174-76/+45
|/
* test, show current adapter behavior for `add_column limit: nil`.Yves Senn2014-04-041-0/+8
| | | | | | This is an illustration of https://github.com/rails/rails/pull/13435#issuecomment-33789752 Removing the limit from the PG and SQLite adapter solves the issue. MySQL is still affected by the issue.
* Use teardown helper method.Guo Xiang Tan2014-03-147-13/+7
| | | | | | | | Follow-Up to https://github.com/rails/rails/pull/14348 Ensure that SQLCounter.clear_log is called after each test. This is a step to prevent side effects when running tests. This will allow us to run them in random order.
* Drop the correct index after reverting a migrationHubert Dąbrowski2014-02-131-3/+3
| | | | | | Previously when reverting a migration which added a named index it would instead drop a corresponding index with matching columns but without a name.
* make `change_column_null` reversible. Closes #13576.Yves Senn2014-01-081-0/+16
| | | | Closes #13623.
* Make change_table use object of current database adapterNishant Modak2014-01-071-1/+2
| | | | | | | | | - Earlier, change_table was creating database-agnostic object. - After this change, it will create correct object based on current database adapter. - This will ensure that create_table and change_table will get same objects. - This makes update_table_definition method public and nodoc. - Fixes #13577 and #13503
* Change all `MiniTest` to `Minitest` since, `MiniTest` namespace has been ↵Vipul A M2013-12-181-1/+1
| | | | | | renamed to `Minitest` Ref: https://github.com/seattlerb/minitest/blob/master/History.txt