Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to migrate from SQLite3 to PostgreSQL

I have a Rails application, created initially using SQLite3. Now I have a need to move it to PostgreSQL with all the data.

I tried to do it as suggested in "How to migrate from SQLite to PostgreSQL (Rails)" using:

sqlite3 development.db .dump | psql dbname username

Which, in my case, is:

sqlite3 development.sqlite3 .dump | psql dev_db deployer

And I got this:

ERROR:  syntax error at or near "PRAGMA"
LINE 1: PRAGMA foreign_keys=OFF;
    ^
BEGIN
ERROR:  syntax error at or near "AUTOINCREMENT"
LINE 1: CREATE TABLE "people" ("id" INTEGER PRIMARY KEY AUTOINCREMEN...

Are those just SQL implementation differences? How can I solve this?

like image 224
Mikhail Chuprynski Avatar asked Sep 13 '25 17:09

Mikhail Chuprynski


1 Answers

Thanks to @theTinMan

gem install sequel

sequel -C sqlite://db/development.sqlite3 postgres://user:password@localhost/dbname
like image 92
Mikhail Chuprynski Avatar answered Sep 16 '25 06:09

Mikhail Chuprynski