Skip to content

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

Merged
senny merged 1 commit into
rails:masterfrom
dmathieu:drop_test
Jan 8, 2014
Merged

senny merged 1 commit into
rails:masterfrom
dmathieu:drop_test

Conversation

@dmathieu

@dmathieu dmathieu commented Jan 8, 2014

Copy link
Copy Markdown
Contributor

Closes #13625

@prathamesh-sonpatki

Copy link
Copy Markdown
Member

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

@dmathieu

dmathieu commented Jan 8, 2014

Copy link
Copy Markdown
Contributor Author

You're right. Thank you. 🌞

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmathieu I think it can be better worded by
Defaults to creating the development and test databases in absence of Rails.env

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There never is an absence of Rails.env. It defaults to development.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Yes you are right :)

@prathamesh-sonpatki

Copy link
Copy Markdown
Member

@dmathieu Will it work with [ci skip] ?

@senny

senny commented Jan 8, 2014

Copy link
Copy Markdown
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.

@senny

senny commented Jan 8, 2014

Copy link
Copy Markdown
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.

@senny

senny commented Jan 8, 2014

Copy link
Copy Markdown
Member

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

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

@dmathieu

dmathieu commented Jan 8, 2014

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is quite hidden. Let's at least add a comment why that check is there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

senny added a commit that referenced this pull request Jan 8, 2014
Be more explicit about the default of db:drop and db:create
@senny
senny merged commit b502e3d into rails:master Jan 8, 2014
@senny

senny commented Jan 8, 2014

Copy link
Copy Markdown
Member

@dmathieu thanks 💛

@dmathieu
dmathieu deleted the drop_test branch January 8, 2014 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rake description for db:drop needs to be updated to mention that it drops both development and test database

3 participants