Django: What are the best practices to migrate a project from sqlite to PostgreSQL

Viewed 28269

I need to migrate a complex project from sqlite to PostgreSQL. A lot of people seems to have problem with foreign keys, data truncature and so on...

  • Is there a full automated utility ?
  • Do I need to check some data or schema before the migration ?

Edit : I tried django-command-extensions DumpScript but it doesn't run on my 2GB RAM PC with my current DataSet.

7 Answers

What worked for me was to run sequel from ruby. Just run the command:

gem install sequel

You will need to have installed on your system the devel packages for postgres , sqlite and ruby Run the command:

gem install pg sqlite3

Create an empty database on postgresql, let's say testDB and assign a grant permission to a user From the command prompt run:

sequel -C sqlite:///path/to/sqlitedb.db postgres://user:password@host/testDB

This will run with no errors.

Change the settings in your django project to work with the postgres database Run

./manage migrate (not necessary)

Run the server

Related