Skip to main content

SQLite to PostgreSQL Migration

Migrate your Gauzy database from SQLite to PostgreSQL for production.

Why Migrate?​

FeatureSQLitePostgreSQL
ConcurrencySingle writeMulti-user
PerformanceSmall datasetsLarge datasets
ScalabilityLimitedHighly scalable
FeaturesBasicFull SQL support
BackupFile copypg_dump, PITR
Recommended forDevelopmentProduction

Migration Steps​

1. Set Up PostgreSQL​

# Install PostgreSQL
sudo apt install postgresql

# Create database and user
sudo -u postgres createuser gauzy
sudo -u postgres createdb gauzy -O gauzy
sudo -u postgres psql -c "ALTER USER gauzy PASSWORD 'your-password';"

2. Export SQLite Data​

# Use the Gauzy export tool
curl -H "Authorization: Bearer $TOKEN" \
http://localhost:3000/api/export/all \
-o gauzy-data-export.json

3. Update Configuration​

Change .env:

- DB_TYPE=sqlite
- DB_NAME=gauzy.sqlite3
+ DB_TYPE=postgres
+ DB_HOST=localhost
+ DB_PORT=5432
+ DB_NAME=gauzy
+ DB_USER=gauzy
+ DB_PASS=your-password

4. Start API (Creates Schema)​

yarn start:api

TypeORM will create all tables automatically on first start.

5. Import Data​

curl -X POST -H "Authorization: Bearer $TOKEN" \
-F "file=@gauzy-data-export.json" \
http://localhost:3000/api/import/all

6. Verify​

  • Check all tables have data
  • Test login and basic operations
  • Verify time logs and invoices