# SQLite to PostgreSQL Migration {#sqlite-to-postgresql-migration}


Migrate your Gauzy database from SQLite to PostgreSQL for production.


## Why Migrate? {#why-migrate}


| Feature         | SQLite         | PostgreSQL       |
| --------------- | -------------- | ---------------- |
| Concurrency     | Single write   | Multi-user       |
| Performance     | Small datasets | Large datasets   |
| Scalability     | Limited        | Highly scalable  |
| Features        | Basic          | Full SQL support |
| Backup          | File copy      | pg_dump, PITR    |
| Recommended for | Development    | Production       |


## Migration Steps {#migration-steps}



### 1. Set Up PostgreSQL {#1-set-up-postgresql}


```bash
# 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 {#2-export-sqlite-data}


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


### 3. Update Configuration {#3-update-configuration}


Change `.env`:

```diff
- 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) {#4-start-api-creates-schema}


```bash
yarn start:api
```

TypeORM will create all tables automatically on first start.


### 5. Import Data {#5-import-data}


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


### 6. Verify {#6-verify}


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


## Related Pages {#related-pages}


- [Database Connection Issues](https://sourcey-gauzy.pages.dev/troubleshooting/database-issues/index.md) — troubleshooting
- [Environment Variables](https://sourcey-gauzy.pages.dev/devops/environment-variables/index.md) — DB config
