0

So basically I am making a new sample application that will run using an external Postgres database and a model, both created by another programmer who has given me this project.

I am supposed to create a rails app that will implement the model and database in order to add some mapping functionality. The problem is that I truly do not know how to migrate an existing database using the "db_name.sqldump" file they provided me. I have installed psql, created a new rails app and added the "pg" gem, but I haven't been able to create a table with all the model information.

I am not sure if I am being clear but I truly am pretty much lost here with RoR. Any input would help.

Blessoul
  • 710
  • 1
  • 7
  • 17

2 Answers2

1

Assuming you've a pg_dump file, import it from the command line using either of psql or pg_restore.

http://www.postgresql.org/docs/current/interactive/app-pgrestore.html

Denis de Bernardy
  • 67,991
  • 12
  • 114
  • 140
-2

Follow this railscast by Ryan Bates - http://railscasts.com/episodes/342-migrating-to-postgresql

To convert your sqldump to a sqlite db, Follow these guides : -

script to convert mysql dump sql file into format that can be imported into sqlite3 db

http://code-n-fold.com/2011/11/28/convert-mysql-dump-to-sqlite-format/

Community
  • 1
  • 1
Zero Fiber
  • 4,089
  • 1
  • 20
  • 33
  • The railscast shows how to create a new database if I am not mistaken, I just want to know how to use an existing one based on an ".sqldump" file. I know its probably very similar, yet I don't know how to do it. – Blessoul Jun 16 '13 at 04:58
  • First convert you sqldump into a sqlite database and then use the taps gem as shown to import everything. – Zero Fiber Jun 16 '13 at 05:00
  • Pardon for asking, but how does turning a PostgreSQL dump into an SQLite dump help in importing the original dump into a PostgreSQL database? – Denis de Bernardy Jun 16 '13 at 12:45
  • Where does he state that he has a PostgreSQL dump and not a SQLite dump? – Zero Fiber Jun 16 '13 at 12:51
  • I beg to ask the same about SQLite. He mentions "an external Postgres database and a model, both created by another programmer" – Denis de Bernardy Jun 16 '13 at 12:55
  • But there's no reason to export to SQLite. If he has a PostgreSQL dump, he should restore the data using the same engine. – Alter Lagos Jun 16 '13 at 16:43
  • Yeah, I actually figured this out myself later, I had to run the script by using a psql command and it basically created itself. – Blessoul Jun 20 '13 at 02:08