New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be more explicit about the default of db:drop and db:create #13629

Merged
merged 1 commit into from Jan 8, 2014

Conversation

Projects
None yet
3 participants
@dmathieu
Contributor

dmathieu commented Jan 8, 2014

Closes #13625

@prathamesh-sonpatki

This comment has been minimized.

Show comment
Hide comment
@prathamesh-sonpatki

prathamesh-sonpatki Jan 8, 2014

Member

@dmathieu Can also add this to create task right? rake db:create also creates development and test databases by default right?

Member

prathamesh-sonpatki commented Jan 8, 2014

@dmathieu Can also add this to create task right? rake db:create also creates development and test databases by default right?

@dmathieu

This comment has been minimized.

Show comment
Hide comment
@dmathieu

dmathieu Jan 8, 2014

Contributor

You're right. Thank you. 🌞

Contributor

dmathieu commented Jan 8, 2014

You're right. Thank you. 🌞

@prathamesh-sonpatki

View changes

Show outdated Hide outdated activerecord/lib/active_record/railties/databases.rake
@prathamesh-sonpatki

This comment has been minimized.

Show comment
Hide comment
@prathamesh-sonpatki

prathamesh-sonpatki Jan 8, 2014

Member

@dmathieu Will it work with [ci skip] ?

Member

prathamesh-sonpatki commented Jan 8, 2014

@dmathieu Will it work with [ci skip] ?

@senny

This comment has been minimized.

Show comment
Hide comment
@senny

senny Jan 8, 2014

Member

From the description it's not obvious to me, when the default applies and how I can change it to only create the database of the current Rails.env.

Member

senny commented Jan 8, 2014

From the description it's not obvious to me, when the default applies and how I can change it to only create the database of the current Rails.env.

@senny

This comment has been minimized.

Show comment
Hide comment
@senny

senny Jan 8, 2014

Member

Looking closer I think we should also change the functionality. Currently:

  • bin/rake db:create => creates dev and test
  • RAILS_ENV=development bin/rake db:create => creates dev and test
  • RAILS_ENV=test bin/rake db:create => creates test

I think if the RAILS_ENV is specified it should only create the database for that env. This would also allow us to reword the description to:

Create the database from DATABASE_URL or config/database.yml 
for the current RAILS_ENV (use db:create:all to create all databases in the config). 
Without RAILS_ENV it defaults to creating the development and test databases.

This explains when the default is active and how it can be changed.

Member

senny commented Jan 8, 2014

Looking closer I think we should also change the functionality. Currently:

  • bin/rake db:create => creates dev and test
  • RAILS_ENV=development bin/rake db:create => creates dev and test
  • RAILS_ENV=test bin/rake db:create => creates test

I think if the RAILS_ENV is specified it should only create the database for that env. This would also allow us to reword the description to:

Create the database from DATABASE_URL or config/database.yml 
for the current RAILS_ENV (use db:create:all to create all databases in the config). 
Without RAILS_ENV it defaults to creating the development and test databases.

This explains when the default is active and how it can be changed.

@senny

This comment has been minimized.

Show comment
Hide comment
@senny

senny Jan 8, 2014

Member

This is even worse when using db:drop. For example:

RAILS_ENV=development bin/rake db:drop will also drop your test database.

Member

senny commented Jan 8, 2014

This is even worse when using db:drop. For example:

RAILS_ENV=development bin/rake db:drop will also drop your test database.

@dmathieu

This comment has been minimized.

Show comment
Hide comment
@dmathieu

dmathieu Jan 8, 2014

Contributor

@senny: your idea definitely makes sense. ⭐️
I just pushed it.

Contributor

dmathieu commented Jan 8, 2014

@senny: your idea definitely makes sense. ⭐️
I just pushed it.

@senny

View changes

Show outdated Hide outdated activerecord/lib/active_record/tasks/database_tasks.rb
@senny

View changes

Show outdated Hide outdated activerecord/test/cases/tasks/database_tasks_test.rb
@senny

View changes

Show outdated Hide outdated activerecord/test/cases/tasks/database_tasks_test.rb
@senny

View changes

Show outdated Hide outdated activerecord/lib/active_record/tasks/database_tasks.rb
@senny

View changes

Show outdated Hide outdated activerecord/test/cases/tasks/database_tasks_test.rb
@senny

View changes

Show outdated Hide outdated activerecord/test/cases/tasks/database_tasks_test.rb
@senny

View changes

Show outdated Hide outdated activerecord/test/cases/tasks/database_tasks_test.rb
@senny

View changes

Show outdated Hide outdated activerecord/CHANGELOG.md
@senny

View changes

Show outdated Hide outdated activerecord/CHANGELOG.md

senny added a commit that referenced this pull request Jan 8, 2014

Merge pull request #13629 from dmathieu/drop_test
Be more explicit about the default of db:drop and db:create

@senny senny merged commit b502e3d into rails:master Jan 8, 2014

@senny

This comment has been minimized.

Show comment
Hide comment
@senny

senny Jan 8, 2014

Member

@dmathieu thanks 💛

Member

senny commented Jan 8, 2014

@dmathieu thanks 💛

@dmathieu dmathieu deleted the dmathieu:drop_test branch Jan 8, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment