0

I've a simple Sinatra application which I've developed using SQLite. The database is a simple two-column table: an ID and a string entry.

I would like to deploy this app to Heroku. What's the least painful way to convert an SQLite database to PostgreSQL, understanding that PostgreSQL is required to deploy to Heroku.

nyzm
  • 2,787
  • 3
  • 24
  • 30
acdanger
  • 17
  • 1
  • 4
  • this seems to be almost duplicate of http://stackoverflow.com/questions/4581727/convert-sqlite-sql-dump-file-to-postgresql – mvp Jul 16 '13 at 02:59

3 Answers3

1

For simple use cases heroku db:push will push your local sqlite database into your Heroku Postgres database.

It's worth considering then switching to using Postgres locally and then use heroku db:pull to bring the database back from Heroku to your new local postgres instance.

I'll caveat to say that whilst heroku db:pull works for SIMPLE databases once you start using more complex Postgres datatypes then you need to use something like heroku pg:transger which is Postgres > Postgres only.

John Beynon
  • 37,398
  • 8
  • 88
  • 97
0

Use the taps gem, as shown in this Railscast.

Ryan Bigg
  • 106,965
  • 23
  • 235
  • 261
0

First you'll want to install Postgres on your local machine so you can make changes and easily deploy to heroku. Second you'll want to migrate from SQLite to Postgres. I just did the migration for my own Rails app following Heroku's instructions and it took less 5 minutes. Seems simple enough.

The instructions to migrate are here (even has instructions on installing Postgres locally). Then you can follow the Heroku getting started guide for the rest.

Chris Kenst
  • 279
  • 1
  • 7