*Issue:* https://github.com/rails/rails/pull/21237
*Pull-request:* https://github.com/rails/rails/pull/22967

Hi!

This past January, Richard Schneeman came up with a idea for preventing 
undesired destructive actions on the production database. 

Good! 

It was implemented via the introduction of a key/value table to store 
internal Active Record values (namely "ar_internal_metadata"). This table 
stores the "environment" that was used when migrating the database. Before 
executing any tests, it will read this value, compare it agains the list of 
"protected_environments", and abort the operation if it's unsafe. 

However, people expressed some concerns 
<https://github.com/rails/rails/pull/21237#issuecomment-169203294> related 
to the database pollution this creates.

I would like to share a proposal:

Before doing any destructive action, Rails should check if the 
configuration of the connection that is being used is the same as the one 
in the list of "protected_environments" and prompt for confirmation: "it 
seems you are trying to execute db:drop task using the same configuration 
as the production database, do you want to continue? [Y/n]". 

This option should work in cases in which the production credentials are 
introduced in development for diagnosing an issue 
<https://github.com/rails/rails/pull/22967#commitcomment-15331938> or using 
ENV["DATABASE_URL"] for all the environments 
<https://github.com/rails/rails/issues/21441>. 

In addition, if we decide to go down this road, "protected_environments" 
could be marked in the "config/database.yml" configuration file.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to