Wednesday, 5 November 2014

Dump and restore a database in Rails using schemas

To dump db:

 pg_dump db_name --format=t --schema=schema --host=host --port=port --username=user --password  

and to restore it:

    rails console development  
    > FactoryGirl.create(:customer, shortname: "customer_name")  
    pg_restore db.tar --data-only --dbname=db_name --format=t --schema=customer_name --host=localhost --port=port --username=user --disable-triggers  

No comments: