Reputation: 3628
I have started a new Rails project with postgres as its database. I also have a .pgsql
file.
Looking at the file, I can see it contains instructions of how to build that database as well as its data. (It looks like a bunch of migrations and seed data all in one.)
I want to build my project's database from this file. My Google-foo is failing me on this one and I'm not sure where to start.
Is there a command I can run to import the structure and data into my project? Is it possible? What do I need to do to get up and running?
Upvotes: 0
Views: 47
Reputation: 1424
Open terminal and go to your project directory. Run below line of codes.
$rake db:drop db:create ## To drop and create fresh DB.
$pg_restore --verbose --clean --no-acl --no-owner -h localhost -U <user> -d <your db> <pgsql backup file path> ## Import data from DB backup file
Hope you find this helpful!
Upvotes: 1