Commit Graph

69804 Commits

Author SHA1 Message Date
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
Ryuta Kamizono
2088b10b1f retrieve_connection_pool return a pool, not a connection 2018-08-03 06:43:03 +09:00
George Claghorn
bba4d2dd8c Remove another unused require 2018-08-02 14:38:33 -04:00
Alireza Bashiri
dc16cdd89a Call build when extend with nested attributes defined
What?
From now on when `accepts_nested_attributes_for` defined and `extend` option
added the overwritten `build` method being called.

[Alireza Bashiri, Martins Polakovs]
2018-08-02 08:27:03 +04:30
Ryuta Kamizono
67fa1ad0c3
Merge pull request #33513 from twitnithegirl/only_connect_once_in_parallel_tests
remove redundant establish_connection call in test_databases.rb
2018-08-02 10:29:44 +09:00
Britni Alexander
7157067eb2 don't establish connection test_database since it gets established in load_schema 2018-08-01 19:41:07 -05:00
Alberto Almagro
67265a3ab0 [ci skip] Change references from Rake task to Rails command
This commit follows the path we started at commit #ea4f0e2
and continued at PR #33229.
2018-08-01 22:44:53 +02:00
Jack Christensen
dd435da5b3
Fix file upload location recommendation
Going one level downwards from Rails' /public directory would still be inside the public directory and therefore servable by the web server. Files should stored upwards of the public directory.
2018-08-01 12:26:47 -05:00
George Claghorn
bd01f9831c Remove unused require 2018-08-01 09:59:04 -04:00
Eileen M. Uchitelle
78992d6f6d
Merge pull request #33479 from twitnithegirl/make_parallel_testing_db_faster
Make parallel testing db faster
2018-08-01 08:12:49 -04:00
Britni Alexander
e6173c98e8 use load_schema instead of migrate for parallel testing 2018-07-31 21:24:29 -04:00
George Claghorn
fee7fba893 Retry ActiveStorage::PurgeJobs on DB deadlock 2018-07-31 19:29:23 -04:00
Ryuta Kamizono
57a91c4d42
Merge pull request #33492 from kamipo/revert_breaking_default_order_contract
Revert the breaking existing default sort order contract
2018-08-01 06:24:14 +09:00
Ryuta Kamizono
25760a4921 Revert "Merge pull request #24131 from brchristian/limit_and_primary_key"
This reverts commit d162188dd662a7d9f62ba8431474f50bc35e3e93, reversing
changes made to 3576782888c307e3e192c44e332b957cd1174128.

Reason: #24131 conflicts the #5153's default order contract, it means
that existing apps would be broken by that change.

We don't want to break existing apps without a deprecation cycle.
2018-08-01 05:32:43 +09:00
Ryuta Kamizono
673cf4f13b Add test case for the #5153's default order contract 2018-08-01 05:30:02 +09:00
Rafael França
b66bf91316
Merge pull request #28937 from maclover7/jm-fix-28927
Default content type for `head` is `text/html`
2018-07-31 15:54:23 -04:00
Xavier Noria
40ac706393
Merge pull request #33490 from rails/revert-31883-remove-label-in-porgress-for-M-V-guides
Revert "Remove label 'work in progress' for AM and AV guides"
2018-07-31 21:44:10 +02:00
Xavier Noria
fb12c03d68
Revert "Remove label 'work in progress' for AM and AV guides" 2018-07-31 21:43:51 +02:00
Richard Schneeman
f37982e41a
Merge pull request #31883 from bogdanvlviv/remove-label-in-porgress-for-M-V-guides
Remove label 'work in progress' for AM and AV guides
2018-07-31 15:33:34 -04:00
Rafael França
1c811cd2fe
Merge pull request #33488 from znz/avoid-to-post-twice
Throw if ujs loaded twice
2018-07-31 15:26:26 -04:00
George Claghorn
e2aaf5c237
Merge pull request #33489 from Atul9/remote-ip
Log the remote IP addr of clients behind a proxy
2018-07-31 14:06:47 -04:00
Atul Bhosale
7e40e9585a Log the remote IP addr of clients behind a proxy
[Atul Bhosale, Victor Nawothnig]
2018-07-31 20:45:37 +05:30
Kazuhiro NISHIYAMA
9df747c9f0 Throw if ujs loaded twice
I saw two posts of problem about ajax requesting twice on qiita.
So I think detecting double loaded earlier make easy to find the problem.

https://qiita.com/hot_study_man/items/56dc87ad734cfda68bb6
https://qiita.com/hisas/items/8399aec3a5377bf75017
2018-07-31 22:16:02 +09:00
Ryuta Kamizono
0f5497499c ✂️ .
[ci skip]
2018-07-31 20:21:15 +09:00
Richard Schneeman
5deab3d26c
Merge pull request #33446 from ptoomey3/nested-respond-to
Raises exception when respond_to called multiple times in incompatible way
2018-07-31 07:08:59 -04:00
Ryuta Kamizono
69f6c4d2af
Merge pull request #33486 from f-mer/patch-1
Fix example in thread_mattr_accessor documentation

[ci skip]
2018-07-31 19:03:22 +09:00
Fabian Mersch
b1589f6712
Fix example in thread_mattr_accessor documentation 2018-07-31 11:44:56 +02:00
Kasper Timm Hansen
0f6a4891fe
Merge pull request #33484 from aditya-kapoor/fix-find-each-description
[ci skip] Fix the outdated description for `find_each`.
2018-07-31 09:57:37 +02:00
Aditya Kapoor
b1b585fe08 [ci skip] Fix the outdated description for find_each. 2018-07-31 13:26:02 +05:30
Kasper Timm Hansen
b377e4d6b1
Merge pull request #33481 from da-edra/readme-over-https
[Docs] All links from README.md now served over https
2018-07-31 09:53:09 +02:00
Andrea Gómez
46fa2e3b08
All links from README.md now served over https 2018-07-31 00:31:43 -05:00
George Claghorn
cd2fe237f7 Guard against missing blobs caused by concurrent purges 2018-07-30 21:42:20 -04:00
Ryuta Kamizono
2a8917d304 Remove unused require
"active_support/core_ext/module/aliasing" is no longer used since
#19434.
2018-07-31 09:50:16 +09:00
Ryuta Kamizono
c83e30da27 Avoid extra scoping when using Relation#update
Since 9ac7dd4, class level `update`, `destroy`, and `delete` were placed
in the `Persistence` module as class methods.

But `Relation#update` without passing ids which was introduced at #11898
is not a class method, and it was caused the extra scoping regression
#33470.

I moved the relation method back into the `Relation` to fix the
regression.

Fixes #33470.
2018-07-31 08:31:46 +09:00
Ryuta Kamizono
e8dd2bf857
Merge pull request #33325 from Edouard-chin/ec-deprecate-class-method
A regression in `deprecate_methods` was introduced in a982a42:
2018-07-31 07:55:39 +09:00
Patrick Toomey
84e8b350a3
Raises exception when respond_to called multiple times in incompatible way
Nesting respond_to calls can lead to unexpected behavior, so it should be
avoided. Currently, the first respond_to format match sets the content-type
for the resulting response. But, if a nested respond_to occurs, it is possible
to match on a different format. For example:

    respond_to do |outer_type|
      outer_type.js do
        respond_to do |inner_type|
          inner_type.html { render body: "HTML" }
        end
      end
    end

Browsers will often include */* in their Accept headers. In the above example,
such a request would result in the outer_type.js match setting the content-
type of the response to text/javascript, while the inner_type.html match will
cause the actual response to return "HTML".

This change tries to minimize potential breakage by only raising an exception
if the nested respond_to calls are in conflict with each other. So, something
like the following example would not raise an exception:

    respond_to do |outer_type|
      outer_type.js do
        respond_to do |inner_type|
          inner_type.js { render body: "JS" }
        end
      end
    end

While the above is nested, it doesn't affect the content-type of the response.
2018-07-30 16:33:34 -06:00
Edouard CHIN
015477ae91 A regression in deprecate_methods was introduced in a982a42:
- Refactoring alias_chain to Module#prepend broke the possibility to deprecate class methods since the module
  generated was prepended to the target's instance.

  A suggestion to fix this was  to use `AS#redefine_method` which would solve the
  problem but with the cost of redefining directly the method.
  Decided to go with the same alias_chain implementation as before instead.

- Fixes #33253
2018-07-30 18:12:56 -04:00
Kasper Timm Hansen
6db5b6dc43
Merge pull request #33467 from bdewater/chomp-unconditionally
Chomp will work without checking for end of the string
2018-07-30 20:39:54 +02:00
George Claghorn
362042c0d7 Ignore concurrently-deleted files when deleting by prefix from GCS 2018-07-30 13:13:00 -04:00
Ryuta Kamizono
159e58fc60
Merge pull request #33471 from yahonda/follows_up_33449
cpu_time and allocations are 0 when JRuby is used
2018-07-31 00:56:45 +09:00
Yasuo Honda
d35b06e2f0 cpu_time and allocations are 0 when JRuby is used
According to #33449 and #33468, cpu_time and allocations are 0 when
JRuby is used.

```ruby
$ ruby -v
jruby 9.2.1.0-SNAPSHOT (2.5.0) 2018-07-27 13b2df5 Java HotSpot(TM) 64-Bit Server VM 25.181-b13 on 1.8.0_181-b13 [linux-x86_64]
$ bundle exec ruby -w -Itest test/log_subscriber_test.rb -n test_event_attributes
Run options: -n test_event_attributes --seed 6231

F

Failure:
SyncLogSubscriberTest#test_event_attributes [test/log_subscriber_test.rb:84]:
Expected 0 to be > 0.

rails test test/log_subscriber_test.rb:78

Finished in 0.018983s, 52.6791 runs/s, 105.3582 assertions/s.
1 runs, 2 assertions, 1 failures, 0 errors, 0 skips
```
2018-07-30 15:10:30 +00:00
George Claghorn
59c3ed1b3f MySQL: Raise ActiveRecord::InvalidForeignKey for foreign-key constraint violations on delete 2018-07-30 09:12:55 -04:00
Rafael França
cfee9feee4
Merge pull request #33468 from bdewater/xplatform-cpu-time
Only use CLOCK_PROCESS_CPUTIME_ID if it's defined
2018-07-30 02:48:24 -04:00
Bart de Water
0ab64b162f Only use CLOCK_PROCESS_CPUTIME_ID if it's defined
It's not defined on JRuby and unlike monotonic time, concurrent-ruby doesn't have an cross-platform abstraction for this.
2018-07-29 14:58:03 -04:00
Bart de Water
4c9c18e93a Chomp will work without checking for end of the string 2018-07-29 14:42:35 -04:00
Bart
eb4f7cad20 ActiveModel::Naming delegate match? in the same manner as =~ and != (#33466)
The purpose of the module seems to quack like a string.
2018-07-29 19:58:35 +02:00
Ryuta Kamizono
66da5ea128 Extract Relation#bind_attribute for internal use
To make it easier to construct boundable predicate.
2018-07-30 00:57:44 +09:00
George Claghorn
6a0b0154e3 Update ActiveStorage::Previewer docs
PDFPreviewer became MuPDFPreviewer in 0b717c2. Previewers are simple enough that we can just provide a single example.
2018-07-29 11:48:11 -04:00
Ryuta Kamizono
975fa15b47 Extract Relation#update_counters for internal use
The target object for counter cache is not always determined by the
primary key value on the model. I'd like to extract `update_couters`
onto the `Relation` for the internal use.
2018-07-30 00:03:16 +09:00
Ryuta Kamizono
14931e537f Remove unused require "active_support/core_ext/regexp"
Ruby 2.4 has native `Regexp#match?`.

https://ruby-doc.org/core-2.4.0/Regexp.html#method-i-match-3F

Related #32034.
2018-07-29 14:51:00 +09:00