Commit Graph

67 Commits

Author SHA1 Message Date
Vipul A M
f23cdd4f83
Merge pull request #32872 from utilum/soften_migrations_guide_generator_section
Expand intro to generator in Migrations Guide
2018-12-15 11:23:52 +09:00
bogdanvlviv
e1817f80b4
Clarify "Old Migrations" in "Active Record Migrations" guide [ci skip]
- 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
2018-08-12 22:25:29 +03:00
bogdanvlviv
e3ae53f92c
Clarify note that SQLite3 adapter doesn't support add_foreign_key [ci skip]
Context https://github.com/rails/rails/pull/33563#discussion_r208891486.

Follow up #33563
2018-08-12 22:25:11 +03:00
Richard Schneeman
bddab1fc86
Merge pull request #33474 from olivierlacan/old-migrations
Document best practices with old migrations
2018-08-11 14:54:37 -05:00
Lukas Zapletal
847e691526 ActiveRecord Guide - sqlite3 foreign keys note 2018-08-09 11:14:56 +02:00
Olivier Lacan
4a2d5efa94 Document best practices with old migrations
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.
2018-08-03 12:59:04 +02:00
Matthew Draper
ec387c6dd9
Merge pull request #33229 from albertoalmagro/albertoalmagro/prefer-rails-command-over-bin-rails
Prefer rails command over bin/rails
2018-07-25 04:10:29 +09:30
Paul McMahon
7b9c19d94b Rails guides are now served over https
http links will be redirected to the https version, but still better to
just directly link to the https version.
2018-07-24 11:29:31 +09:00
Alberto Almagro
2e194d0c9e Substitute references to task for command
This commit substitutes references to rails/rake task for rails command
2018-07-06 22:46:54 +02:00
Alberto Almagro
40b209db53 Recommend use of rails over bin/rails
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.
2018-07-06 22:46:35 +02:00
George Semenov
7be279a644 Remove erroneous remove_column option from example 2018-06-29 19:04:15 +03:00
utilum
8b0d29bcf2 Expand intro to Migration generator in Migrations Guide
[ci skip]
2018-05-11 15:36:12 +02:00
Anthony Crumley
258670244d Added a lot of Oxford commas
[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) "
2018-05-10 12:46:06 -05:00
Daniel Colson
cc6d2dc0de Fix typo in migrations guide [ci skip]
Introduced in #32646
2018-04-24 12:54:33 -04:00
Derek Prior
84718df860
Update schema.rb documentation [CI SKIP]
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>
2018-04-24 11:18:11 -04:00
Yauheni Dakuka
f1b1494484 Fix note marks [ci skip] 2018-03-12 15:36:26 +03:00
Alberto Almagro
95b6a198ef Remove default ENGINE documentation for MySQL and MariaDB
Removes default ENGINE documentation hint for MySQL and MariaDB as we
aren't taking measures to set the default ENGINE anymore.
2017-12-11 10:46:25 +01:00
Yoshiyuki Hirano
bf48e90e69 Use https instead of http in guide [ci skip] 2017-08-23 09:39:45 +09:00
Jon Moss
54fa07f2c8 Reword sentence
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]
2017-04-19 15:40:25 -04:00
vishalzambre
e2648c42ab [ci skip] Changed plain text to NOTE. 2017-04-19 11:31:00 +05:30
bogdanvlviv
2339466542 Add missing spaces [ci skip] 2016-11-07 01:43:59 +02:00
Benny
32d0d971eb Add missing space in Migrations guide [ci skip] 2016-10-31 11:32:29 +08:00
Yves Senn
dba9ce8ec8 guides, include note about modifiers when using the CLI.
[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
2016-10-20 20:34:46 +02:00
Yves Senn
fb2f8d2b75 remove trailing whitespace [ci skip] 2016-10-20 20:32:24 +02:00
Josh Justice
65132b9087 Update references generation docs to exclude index
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]
2016-07-16 05:23:17 -04:00
Prathamesh Sonpatki
a469f72208
Fix wording related to adapters supporting database comments [ci skip] 2016-04-18 11:34:55 +05:30
Jeremy Daer
3b0a627a94 Merge pull request #22911 from Envek/database_comments
Add support for specifying comments for tables, columns, and indexes in database itself
2016-04-16 22:19:47 -07:00
Vipul A M
bca1872198 documentation for add_references index option [ci skip]
documentation for add_references index option [ci skip]
2016-04-17 02:06:25 +05:30
Alex Handley
d9565811f0
[ci skip] docs for add_references index option
- 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.
2016-04-16 21:32:22 +01:00
Andrey Novikov
c690b9ce39
Add support for specifying comments for tables, columns, and indexes.
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
2016-04-16 10:17:26 +03:00
iangilfillan
48ef9408bc MariaDB Documentation 2016-04-14 14:06:29 +02:00
Vijay Dev
598816f630 Merge branch 'master' of github.com:rails/docrails
Conflicts:
	guides/source/association_basics.md
2016-03-06 06:58:36 +00:00
Prathamesh Sonpatki
b5bdcaa838 [ci skip] Update all guides with null: false change in migrations
- We no longer add `null: false` for timestamps columns as per
  rails/rails@a939506.
- Followup of
  14867b1a9a.
2016-03-03 13:54:04 +05:30
Mehmet Emin İNAÇ
57dbf45675 Changed behaviour of timestamps helper by create_table migration generator [ci skip] 2016-03-03 02:31:29 +02:00
Matt Michnal
767f168772 Fixed grammatical errors in rails docs [ci skip]
Fixed errors in rails migrations docs [ci skip]

Fixed errors in rails security docs [ci skip]
2016-02-09 17:57:16 -07:00
Gaurav Sharma
352a8892fd use bin/rails default instead of rake commands [ci skip]
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 …`
2016-01-19 23:47:14 +05:30
David Heinemeier Hansson
ea4f0e2bab Refer to rails command instead of rake in a bunch of places
Still more to do. Please assist!
2015-12-18 13:01:10 +01:00
Matthew Draper
97c77160cd Use a real migration version number in docs
Even though this means more things to change when we bump after a
release, it's more important that our examples are directly copyable.
2015-12-15 17:18:10 +10:30
Matthew Draper
c0af95e0ab Use a deliberately-invalid migration version in all doc examples
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.
2015-12-15 17:18:09 +10:30
atul-shimpi
2d53593ae6 Issue #22139 : Edge Guides - ActiveRecord Migrations - Remove required option for column 2015-11-01 07:59:15 +05:30
Anna Ershova
5cde56e173 Update active_record_migrations.md
Add 'db/'; corrects structure.rb to structure.sql
2015-10-15 16:37:11 -04:00
AnnaErshova
0166adcee8 Clarifies db can be set up from structure.sql also
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.
2015-10-15 09:36:57 -04:00
yui-knk
df9cfc055a [ci skip] Update what methods Migration#change can reverse
* 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.
2015-08-31 10:08:38 +09:00
yui-knk
454e0c1c8d [ci skip] Fix migration file's timestamp
In rails generally migration file's timestamp is "YYYYMMDDHHMMSS".
2015-08-24 21:21:44 +09:00
Brooks Reese
4445e79157 [ci skip] Give in-depth explanation of migrations vs. seeds.rb 2015-08-08 14:37:21 -05:00
r11runner
d73a524b6e [ci skip] migration and association guides: added some remarks about join tables 2015-08-04 00:09:38 +02:00
Jordon Dornbos
f5d6aaa31b fix pluralization in doc [ci skip] 2015-06-29 16:54:57 -07:00
Prem Sichanugrist
f9c841927a Update guide for new change_column_default syntax 2015-06-26 16:25:13 -04:00
yuuji.yaginuma
95de0f01e0 fix doc about foreign key name [ci skip]
this behavior was changed in b8e1f202676b4788c56241b124c401beff9f4014
2015-06-12 09:39:18 +09:00
Tim Wade
4cebcaeb2f
[ci skip] Improve phrasing in AR migrations docs.
* insert 'and' into a poorly formed sentence.
* avoid using 'reverse' twice in the same sentence (which would indicate
  the opposite of what is meant)
2015-05-13 21:05:48 -07:00