Rails Project automatically deleted after rake db:reset - ruby-on-rails

I was working on Nitrous.io on a Rails Project.
I have created a new branch and then after some coding , I reset the database with
rake db:reset.
After this action my Projects folders were automatically deleted.
Someone could help me understand what is wrong on my command?

db:reset will do exactly as described - it will "reset" the database. So db:reset is the same as executing the following commands: db:drop (which will drop/delete all entries in the database) + db:setup

I somehow doubt it that rake db:reset deletes your .rb files. Must be something else. Maybe you messed up with git?
rake db:reset
rake db:create
rake db:migrate
works just fine, normally.

Related

Is there a way to run rake db:setup on a single table?

I have a Ruby on rails app, and I modified db/seeds.rb file and I want to push my changes into my database.
is there an option in Rails where I can run rake db:setup and modify only that table without clearing all the other ones ?
Thanks
You use rake db:seed to run the seed file. rake db:setup is much more involved, it basically runs all of the following
db:create
db:schema:load
db:seed

I screw up the database and schema of my rails app, what should I do to rebuild database from my migration files?

My code is all OK, and it has all and only the migrations from which I want my database to be create, as I re-run them one bye one..
How should I do this.
my schema file is also screwed up.
thanks
If your schema file is wrong you can drop your database with rake db:drop, then recreate it with rake db:create and finally run simple rake db:migrate to run all migrations you have (assuming that you have only migrations you want to run, i.e. you deleted others).
Run rake db:reset inside your rails root directory.

Recreate database+tables (it dosn't want to work with rake commands) ROR 3

I'm newbie with ror and I just managed to ruin the databse... I tried to recreate with this 2 methodes bu none works:
first:
rake db:reset
rake db:migrate
second:
rake db:drop
rake db:create
rake db:migrate
But none work... I'm out of ideas what to do, please help...
My migrate folder is empty, if I migrate nothing happens, no table created notice.
Try using:
rake db:migrate:reset
examine your database.yml file, it might default to SQLITE which is basically a text file.
Make sure you are using the correct database with the correct name.

Rake db:migrate updates schema.rb, but not Mysql table. Any ideas why? [duplicate]

I have two instances of my app: one for development, one for production. My development database is called snip_development and my production database is called snip.
I've been doing migrations all along in my development environment and it's been going just fine. I recently created a production instance of my app but rake db:migrate doesn't seem to have any effect. After I run rake db:migrate and log into my database server, I can see that snip_development has all the tables I expect it to but snip doesn't have any tables at all.
I suspect the problem is that rake db:migrate is running on snip_development instead of snip and that's why I'm not seeing anything happen.
How do I get my migrations to work on my production database?
Sometimes I forget about Google. The answer is this:
rake db:migrate RAILS_ENV=production
For me the answer above not works. I have to add bundle exec to make it works.
bundle exec rails db:migrate RAILS_ENV=production

rake db:migrate doesn't seem to work in production

I have two instances of my app: one for development, one for production. My development database is called snip_development and my production database is called snip.
I've been doing migrations all along in my development environment and it's been going just fine. I recently created a production instance of my app but rake db:migrate doesn't seem to have any effect. After I run rake db:migrate and log into my database server, I can see that snip_development has all the tables I expect it to but snip doesn't have any tables at all.
I suspect the problem is that rake db:migrate is running on snip_development instead of snip and that's why I'm not seeing anything happen.
How do I get my migrations to work on my production database?
Sometimes I forget about Google. The answer is this:
rake db:migrate RAILS_ENV=production
For me the answer above not works. I have to add bundle exec to make it works.
bundle exec rails db:migrate RAILS_ENV=production

Resources