ruby on rails - Build db:rake task from existing Database -


i have project has had alot of editing postgresql database.

i tring find out there way build new db:rake file can rebuild database on new server easily. without manually editing db:rake files.

thanks

ruby 1.9.3 centos 6.4 ruby on rails 3 postgresql 9.3 

for clarity, assuming referring migration files when mention db:rake files.

in rails, don't want rebuild database using migration files. can become outdated, referring things no longer exist, etc. instead, best practice recreate database using schema.rb file instead. touched on an answer wrote while back. in short, schema.rb file represents database table structure; snapshot, if will. note it not contain data, table structure.

in scenario, in order create, or ensure schema.rb date, need dump schema, so:

rake db:schema:dump 

this regenerates schema.rb file. then, rebuild database file in environment, reload schema, so:

rake db:schema:load 

as stated above, schema.rb not contain data tables, merely represents structure. if want preload database initial / default values, want use seed.rb file. write .create statements, , run so:

rake db:seed 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -