aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/active_record_migrations.md
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #32872 from utilum/soften_migrations_guide_generator_sectionVipul A M2018-12-151-4/+9
|\ | | | | Expand intro to generator in Migrations Guide
| * Expand intro to Migration generator in Migrations Guideutilum2018-05-111-4/+9
| | | | | | | | [ci skip]
* | Clarify "Old Migrations" in "Active Record Migrations" guide [ci skip]bogdanvlviv2018-08-121-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | - Name rails app' files relatively to its root - `structure.sql` => `db/structure.sql` - `schema.rb` => `db/schema.rb` - Clarify rails commands - `db:migrate` => `rails db:migrate` - `db:migrate:status` => `rails db:migrate:status` - Add `/` to the end of `db/migrate` in order to express that it is directory and to keep consistency with `db/migrate/` above. Follow up #33474
* | Clarify note that SQLite3 adapter doesn't support `add_foreign_key` [ci skip]bogdanvlviv2018-08-121-3/+2
| | | | | | | | | | | | Context https://github.com/rails/rails/pull/33563#discussion_r208891486. Follow up #33563
* | Merge pull request #33474 from olivierlacan/old-migrationsRichard Schneeman2018-08-111-3/+22
|\ \ | | | | | | Document best practices with old migrations
| * | Document best practices with old migrationsOlivier Lacan2018-08-031-3/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The copy here is of course up for discussion but it feels like we need to address the issue of old migrations in the Migration guide because other than mentioning the canonical nature of schema.rb/structure.sql or the actual database compared to migration files, it seems like more guidance would help. Here's a sample of the kinds of question people seem to often ask about old Rails migrations: - https://stackoverflow.com/questions/20119391/delete-old-migrations-files-in-a-rails-app - https://www.reddit.com/r/rails/comments/4ayosd/compacting_migrations_files_or_delete_them/ - https://stackoverflow.com/questions/4248682/is-it-a-good-idea-to-purge-old-rails-migration-files - https://stackoverflow.com/questions/707013/is-it-a-good-idea-to-collapse-old-rails-migrations - https://stackoverflow.com/questions/1981777/rails-remove-old-models-with-migrations - https://stackoverflow.com/questions/3343534/rebase-rails-migrations-in-a-long-running-project The common theme seems to be: "I've got old migrations, should I keep them around on an old project?". My personal stance is that as long as migrations run and don't take too long do so, you should keep them around since it allows people working on the Rails project with you to seamlessly upgrade their local development database without having to do a `db:drop db:schema:load` and lose all their seed data. While writing down this suggested new section it felt like I was describing a very cumbersome process that could be address with a rake task like: ```bash rails db:migrate:remove VERSION=20121201123456 ``` It rollback to the version just before `20121201123456`, delete the migration file, and run `db:migrate` to get back to the latest migration. This of course doesn't address a situation when someone would want to delete or merge all migrations prior to a certain date, which is addressed by [squasher](https://github.com/jalkoby/squasher). I'm not sure this is something we want to encourage people to do. Although I feel like with more and more production Rails apps over 5-years old, it's definitely a concern we should address.
* | | ActiveRecord Guide - sqlite3 foreign keys noteLukas Zapletal2018-08-091-0/+4
|/ /
* | Merge pull request #33229 from ↵Matthew Draper2018-07-251-29/+29
|\ \ | | | | | | | | | | | | albertoalmagro/albertoalmagro/prefer-rails-command-over-bin-rails Prefer rails command over bin/rails
| * | Substitute references to task for commandAlberto Almagro2018-07-061-11/+11
| | | | | | | | | | | | This commit substitutes references to rails/rake task for rails command
| * | Recommend use of rails over bin/railsAlberto Almagro2018-07-061-22/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | As discussed in #33203 rails command already looks for, and runs, bin/rails if it is present. We were mixing recommendations within guides and USAGE guidelines, in some files we recommended using rails, in others bin/rails and in some cases we even had both options mixed together.
* | | Rails guides are now served over httpsPaul McMahon2018-07-241-1/+1
|/ / | | | | | | | | http links will be redirected to the https version, but still better to just directly link to the https version.
* / Remove erroneous remove_column option from exampleGeorge Semenov2018-06-291-1/+1
|/
* Added a lot of Oxford commasAnthony Crumley2018-05-101-2/+2
| | | | | | | [ci skip] A regular expression was used to find a lot of missing Oxford commas and add them. The regular expression was as follows. ", ([a-zA-Z0-9.\`:'\"]+ ){1,6}(or|and) "
* Fix typo in migrations guide [ci skip]Daniel Colson2018-04-241-1/+1
| | | | Introduced in #32646
* Update schema.rb documentation [CI SKIP]Derek Prior2018-04-241-45/+35
| | | | | | | | | | | | | | | | | | | | | The documentation previously claimed that `db/schema.rb` was "the authoritative source for your database schema" while simultaneously also acknowledging that the file is generated. These two statements are incongruous and the guides accurately call out that many database constructs are unsupported by `schema.rb`. This change updates the comment at the top of `schema.rb` to remove the assertion that the file is authoritative. The documentation also previously referred vaguely to "issues" when re-running old migrations. This has been updated slightly to hint at the types of problems that one can encounter with old migrations. In sum, this change attempts to more accurately capture the pros, cons, and shortcomings of the two schema formats in the guides and in the comment at the top of `schema.rb`. [Derek Prior & Sean Griffin] Co-authored-by: Sean Griffin <sean@seantheprogrammer.com>
* Fix note marks [ci skip]Yauheni Dakuka2018-03-121-1/+1
|
* Remove default ENGINE documentation for MySQL and MariaDBAlberto Almagro2017-12-111-2/+1
| | | | | Removes default ENGINE documentation hint for MySQL and MariaDB as we aren't taking measures to set the default ENGINE anymore.
* Use https instead of http in guide [ci skip]Yoshiyuki Hirano2017-08-231-1/+1
|
* Reword sentenceJon Moss2017-04-191-3/+3
| | | | | | | Sentence had some awkward grammar and was kind of confusing, tried to make it easier to understand what it was trying to say :) [ci skip]
* [ci skip] Changed plain text to NOTE.vishalzambre2017-04-191-5/+5
|
* Add missing spaces [ci skip]bogdanvlviv2016-11-071-2/+2
|
* Add missing space in Migrations guide [ci skip]Benny2016-10-311-1/+1
|
* guides, include note about modifiers when using the CLI.Yves Senn2016-10-201-0/+2
| | | | | | | | | | | [ci skip] This was pointed out on https://github.com/rails/rails/issues/15583#issuecomment-239212831 The comment was lost in the changes made by fcd0ac066e0959a9f4fa4459a27e041abe8eb52a and 3e1373a773085d5f19cb6a466ab2736cc1ca2713
* remove trailing whitespace [ci skip]Yves Senn2016-10-201-8/+8
|
* Update references generation docs to exclude indexJosh Justice2016-07-161-2/+2
| | | | | | In #23179 the migration generator was changed to no longer output `index: true` for `references` migrations. This updates the migrations guide to remove `index: true` from relevant examples. [ci skip]
* Fix wording related to adapters supporting database comments [ci skip]Prathamesh Sonpatki2016-04-181-2/+2
|
* Merge pull request #22911 from Envek/database_commentsJeremy Daer2016-04-161-0/+8
|\ | | | | | | Add support for specifying comments for tables, columns, and indexes in database itself
| * Add support for specifying comments for tables, columns, and indexes.Andrey Novikov2016-04-161-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | documentation for add_references index option [ci skip]Vipul A M2016-04-171-1/+2
|\ \ | |/ |/| documentation for add_references index option [ci skip]
| * [ci skip] docs for add_references index optionAlex Handley2016-04-161-1/+2
| | | | | | | | | | | | - Add link for finding the addional options for index. - Add example for unique index as this is a common requirement. - Add link in guide for index options.
* | MariaDB Documentationiangilfillan2016-04-141-2/+2
|/
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2016-03-061-2/+2
|\ | | | | | | | | Conflicts: guides/source/association_basics.md
| * [ci skip] Update all guides with `null: false` change in migrationsPrathamesh Sonpatki2016-03-031-3/+3
| | | | | | | | | | | | | | - We no longer add `null: false` for timestamps columns as per rails/rails@a939506. - Followup of https://github.com/rails/docrails/commit/14867b1a9af813b0147bba2ae06675137d61d77b.
* | Changed behaviour of timestamps helper by create_table migration generator ↵Mehmet Emin İNAÇ2016-03-031-1/+1
| | | | | | | | [ci skip]
* | Fixed grammatical errors in rails docs [ci skip]Matt Michnal2016-02-091-2/+2
|/ | | | | | Fixed errors in rails migrations docs [ci skip] Fixed errors in rails security docs [ci skip]
* use bin/rails default instead of rake commands [ci skip]Gaurav Sharma2016-01-191-7/+7
| | | I go through the `http://edgeguides.rubyonrails.org/` and found `rake` commands in various files that are in RAILS 5.0 implement by `bin/rails` command. I try to change all that can be directly use `bin/rails …`
* Refer to rails command instead of rake in a bunch of placesDavid Heinemeier Hansson2015-12-181-15/+15
| | | | Still more to do. Please assist!
* Use a real migration version number in docsMatthew Draper2015-12-151-19/+19
| | | | | Even though this means more things to change when we bump after a release, it's more important that our examples are directly copyable.
* Use a deliberately-invalid migration version in all doc examplesMatthew Draper2015-12-151-19/+19
| | | | | | | | | | If we use a real version, at best that'll be an onerous update required for each release; at worst, it will encourage users to write new migrations against an older version than they're using. The other option would be to leave these bare, without any version specifier. But as that's just a variant spelling of "4.2", it would seem to raise the same concerns as above.
* Issue #22139 : Edge Guides - ActiveRecord Migrations - Remove required ↵atul-shimpi2015-11-011-2/+0
| | | | option for column
* Update active_record_migrations.mdAnna Ershova2015-10-151-1/+1
| | | Add 'db/'; corrects structure.rb to structure.sql
* Clarifies db can be set up from structure.sql alsoAnnaErshova2015-10-151-1/+1
| | | | | | | | I added that *structure.sql* file can be used when *db:reset* is run. *db:reset* tasks states *db:reset* loads database from *db/schema.rb* or *db/structure.sql* depending on the configuration (although *db/schema.rb* is the default), hence the change.
* [ci skip] Update what methods `Migration#change` can reverseyui-knk2015-08-311-14/+21
| | | | | | | | | | * Documentations and comments about what methods `Migration#change` can reverse is out of date. For example `change_column_default` is now reversible by this [commit](https://github.com/rails/rails/pull/20018). * Comments about `CommandRecorder` dose not match with Rails Guide. For example `add_foreign_key` is listed only on Rails Guide.
* [ci skip] Fix migration file's timestampyui-knk2015-08-241-1/+1
| | | | In rails generally migration file's timestamp is "YYYYMMDDHHMMSS".
* [ci skip] Give in-depth explanation of migrations vs. seeds.rbBrooks Reese2015-08-081-4/+9
|
* [ci skip] migration and association guides: added some remarks about join tablesr11runner2015-08-041-10/+8
|
* fix pluralization in doc [ci skip]Jordon Dornbos2015-06-291-1/+1
|
* Update guide for new change_column_default syntaxPrem Sichanugrist2015-06-261-6/+8
|
* fix doc about foreign key name [ci skip]yuuji.yaginuma2015-06-121-1/+2
| | | | this behavior was changed in b8e1f202676b4788c56241b124c401beff9f4014
* [ci skip] Improve phrasing in AR migrations docs.Tim Wade2015-05-131-2/+2
| | | | | | * insert 'and' into a poorly formed sentence. * avoid using 'reverse' twice in the same sentence (which would indicate the opposite of what is meant)