简体   繁体   中英

Starting My Ruby on Rails application - How to fill database?

i'm tying to install my ruby on rails application on a new Server.

In the folder db theres is my schema.rb file.

But my problem ist how to run the schema.rb file to run the sql statements?

The schema file doesn't populate the data, rather it shows the structure of the database. You'll have to run:

rake:db:create rake:db:migrate

on the new server and then create a dump of the data you wish to import to the new database. Then import the data. Both of these processes can differ widely depending on what kind of database you're using.

For MySQL: Export and Import all MySQL databases at one time

For PostgreSQL: import sql dump into postgresql database

You can do this:

  • rake db:create to create your DB (you do this only once)
  • rake db:migrate to migrate your BD (do this the first time and every time you want to apply changes, like removing a column)

And

  • rake db:seed to populate your DB, if you have something in you seeds.rb file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM