aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/migration
Commit message (Collapse)AuthorAgeFilesLines
* Replace `if exists` with `table_exists?` and drop table statement with ↵Yasuo Honda2015-01-211-2/+2
| | | | | | | `drop_table` since 'drop table if exists' statement does not always work with some databases such as Oracle. also Oracle drop table statement will not drop sequence objects.
* tests, use `drop_table if_exists: true` in our test suite.Yves Senn2015-01-204-7/+7
|
* Add an `:if_exists` option to `drop_table`Stefan Kanev2015-01-191-0/+11
| | | | | | | | | | | If set to `if_exists: true`, it generates a statement like: DROP TABLE IF EXISTS posts This syntax is supported in the popular SQL servers, that is (at least) SQLite, PostgreSQL, MySQL, Oracle and MS SQL Sever. Closes #16366.
* Remove unused accessorRyuta Kamizono2015-01-191-1/+1
|
* Use IO::NULL alwaysNobuyoshi Nakada2015-01-101-1/+1
|
* Add firebird support to test suiteRay Zane2015-01-051-18/+20
|
* Change the default `null` value for `timestamps` to `false`Rafael Mendonça França2015-01-041-10/+7
|
* Remove deprecated methods at `Kernel`.Rafael Mendonça França2015-01-041-1/+13
| | | | `silence_stderr`, `silence_stream`, `capture` and `quietly`.
* Prefer `array?` rather than `array`Ryuta Kamizono2015-01-041-2/+2
| | | | | | Slightly refactoring `PostgreSQLColumn`. `array` should be readonly. `default_function` should be initialized by `super`. `sql_type` has been removed `[]`. Since we already choose to remove it we should not change.
* Don't wrap `create_table` in a transaction for tests which run on MySQLSean Griffin2014-12-221-3/+1
| | | | PG will warn without it, but mysql2 errors out.
* Add `foreign_key` as an option to `references` for `change_table`Sean Griffin2014-12-221-0/+43
| | | | | | | | | | | This has the same comments as 9af90ffa00ba35bdee888e3e1ab775ba0bdbe72c, however it affects the `add_reference` method, and `t.references` in the context of a `change_table` block. There is a lot of duplication of code between creating and updating tables. We should re-evaluate the structure of this code from a high level so changes like this don't need to be made in two places. (Note to self)
* Add a `foreign_key` option to `references` while creating the tableSean Griffin2014-12-221-0/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than having to do: create_table :posts do |t| t.references :user end add_foreign_key :posts, :users You can instead do: create_table :posts do |t| t.references :user, foreign_key: true end Similar to the `index` option, you can also pass a hash. This will be passed as the options to `add_foreign_key`. e.g.: create_table :posts do |t| t.references :user, foreign_key: { primary_key: :other_id } end is equivalent to create_table :posts do |t| t.references :user end add_foreign_key :posts, :users, primary_key: :other_id
* `force: :cascade` to recreate tables referenced by foreign-keys.Yves Senn2014-12-191-0/+31
|
* Failure to rollback t.timestamps when within a change_table migrationnoam2014-12-032-4/+4
| | | | | | | | | | | | | When running the following migration: change_table(:table_name) { |t| t/timestamps } The following error was produced: wrong number of arguments (2 for 1) .... /connection_adapters/abstract/schema_statements.rb:851:in `remove_timestamps' This is due to `arguments` containing an empty hash as its second argument.
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-6/+6
|
* raise a better exception for renaming long indexesAaron Patterson2014-11-201-0/+14
|
* Support symbol foreign key to deletedtaniwaki2014-11-191-0/+8
|
* Force table creation in testsSean Griffin2014-11-171-2/+2
| | | | | | If something causes the teardown block to not get run (errors, interrupting test runs), we have to manually delete them, which is a pain.
* add a Table#name accessor like TableDefinition#nameCody Cutrer2014-11-101-0/+6
|
* 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
|