1
migrate from sqlite to postgresql
Armando Lüscher edited this page 2020-10-11 23:51:24 +02:00

Migrate from SQLite to PostgreSQL

Shutdown Lutim to avoid URL creation while migrating.

Install some dependencies:

apt-get install sqlite3 libsqlite3-mod-impexp
sqlite3 /var/www/lutim/lutim.db

In SQLite prompt, do this to export data:

.load libsqlite3_mod_impexp
SELECT export_sql('/tmp/lutim.sql','1');
.exit

Modify the exported file (the export format is close to PostgreSQL's SQL but not quite):

sed -e "s@^INSERT OR REPLACE @INSERT @" -e 's@INSERT INTO "mojo_migrations".*@@' -i /tmp/lutim.sql

Create PostgreSQL database:

su - postgres
createuser lutim_user -P
createdb -O lutim_user lutim_db

Configure Lutim to use PostgreSQL and start it to create the database structure.

Then import the data:

su postgres
psql lutim_db < /tmp/lutim.sql

Go back to wiki's homepage.