# Database Overview {#database-overview}


Ever Gauzy supports multiple databases and ORMs, providing flexibility for different deployment scenarios.


## Supported Databases {#supported-databases}


| Database            |   Production   | Development | Default |
| ------------------- | :------------: | :---------: | :-----: |
| **PostgreSQL**      | ✅ Recommended |     ✅      |   ❌    |
| **MySQL / MariaDB** |       ✅       |     ✅      |   ❌    |
| **SQLite**          |  ⚠️ Demo only  |     ✅      |   ✅    |
| **better-sqlite3**  |  ⚠️ Demo only  |     ✅      |   ❌    |


## Supported ORMs {#supported-orms}


| ORM          | Role            | Configuration      |
| ------------ | --------------- | ------------------ |
| **TypeORM**  | Primary ORM     | `DB_ORM=typeorm`   |
| **MikroORM** | Alternative ORM | `DB_ORM=mikro-orm` |
| **Knex**     | Query builder   | Always available   |


## Database Configuration {#database-configuration}



### Core Environment Variables {#core-environment-variables}


```bash
# Database type
DB_TYPE=postgres          # postgres | mysql | sqlite | better-sqlite3

# ORM selection
DB_ORM=typeorm            # typeorm | mikro-orm

# Connection settings
DB_HOST=localhost
DB_PORT=5432
DB_NAME=gauzy
DB_USER=postgres
DB_PASS=your-password
DB_SSL_MODE=false

# Connection pool
DB_POOL_SIZE=40
DB_CONNECTION_TIMEOUT=5000
DB_IDLE_TIMEOUT=10000

# Logging
DB_LOGGING=false          # true | false | query | error | schema
```


### SQLite Configuration {#sqlite-configuration}


For development with SQLite:

```bash
DB_TYPE=sqlite
DB_NAME=gauzy.sqlite3
```

SQLite requires no host, port, user, or password settings.


### PostgreSQL Configuration {#postgresql-configuration}


```bash
DB_TYPE=postgres
DB_HOST=localhost
DB_PORT=5432
DB_NAME=gauzy
DB_USER=postgres
DB_PASS=root
DB_SSL_MODE=false
```


### MySQL Configuration {#mysql-configuration}


```bash
DB_TYPE=mysql
DB_HOST=localhost
DB_PORT=3306
DB_NAME=gauzy
DB_USER=root
DB_PASS=root
```


## Database Schema {#database-schema}


The platform has approximately **200+ database tables** organized into domains:


### Core Tables {#core-tables}


| Table             | Entity         | Description                  |
| ----------------- | -------------- | ---------------------------- |
| `tenant`          | Tenant         | Multi-tenant root            |
| `user`            | User           | User accounts                |
| `role`            | Role           | Role definitions             |
| `role_permission` | RolePermission | Role-permission mappings     |
| `organization`    | Organization   | Organizations within tenants |


### HRM Tables {#hrm-tables}


| Table              | Entity         | Description               |
| ------------------ | -------------- | ------------------------- |
| `employee`         | Employee       | Employee profiles         |
| `time_log`         | TimeLog        | Time tracking entries     |
| `timesheet`        | Timesheet      | Weekly/monthly timesheets |
| `time_slot`        | TimeSlot       | 10-minute activity slots  |
| `screenshot`       | Screenshot     | Activity screenshots      |
| `activity`         | Activity       | App/URL activity tracking |
| `time_off_request` | TimeOffRequest | Leave requests            |
| `time_off_policy`  | TimeOffPolicy  | Leave policies            |


### PM Tables {#pm-tables}


| Table                         | Entity              | Description          |
| ----------------------------- | ------------------- | -------------------- |
| `organization_project`        | OrganizationProject | Projects             |
| `task`                        | Task                | Task management      |
| `task_status`                 | TaskStatus          | Custom task statuses |
| `task_priority`               | TaskPriority        | Custom priorities    |
| `organization_sprint`         | OrganizationSprint  | Sprint management    |
| `organization_project_module` | ProjectModule       | Project modules      |


### ERP Tables {#erp-tables}


| Table          | Entity      | Description            |
| -------------- | ----------- | ---------------------- |
| `invoice`      | Invoice     | Invoices and estimates |
| `invoice_item` | InvoiceItem | Invoice line items     |
| `expense`      | Expense     | Expense records        |
| `payment`      | Payment     | Payment records        |
| `income`       | Income      | Income records         |


### CRM / ATS Tables {#crm--ats-tables}


| Table                  | Entity              | Description        |
| ---------------------- | ------------------- | ------------------ |
| `organization_contact` | OrganizationContact | Contacts/leads     |
| `pipeline`             | Pipeline            | Sales pipelines    |
| `pipeline_stage`       | PipelineStage       | Pipeline stages    |
| `candidate`            | Candidate           | Job candidates     |
| `candidate_interview`  | CandidateInterview  | Interview schedule |


### Integration Tables {#integration-tables}


| Table                        | Entity                   | Description                 |
| ---------------------------- | ------------------------ | --------------------------- |
| `integration`                | Integration              | Active integrations         |
| `integration_type`           | IntegrationType          | Available integration types |
| `integration_setting`        | IntegrationSetting       | Integration configs         |
| `integration_entity_setting` | IntegrationEntitySetting | Entity sync settings        |


## Entity Relationships {#entity-relationships}


```
Tenant ──┬── Organization ──┬── Employee ──── TimeLog
         │                  ├── Project ──── Task
         │                  ├── Contact
         │                  ├── Invoice
         │                  └── Expense
         │
         ├── User ──── Role ──── RolePermission
         │
         └── Integration
```


## Database Initialization {#database-initialization}



### Auto-Migration {#auto-migration}


TypeORM can automatically synchronize the schema:

```bash
DB_SYNCHRONIZE=true     # ⚠️ Development only - drops/recreates tables
```



> [!WARNING]
> Never enable `DB_SYNCHRONIZE=true` in production. Use migrations instead.




### Seeding {#seeding}


The platform includes seed data for demo/development:

```bash
yarn seed:all           # Seed all demo data
yarn seed:module:all    # Seed module-specific data
```

See [Database Seeding](https://sourcey-gauzy.pages.dev/database/seeding/index.md) for details.


## Related Pages {#related-pages}


- [TypeORM Setup](https://sourcey-gauzy.pages.dev/database/typeorm/index.md) — TypeORM configuration
- [MikroORM Setup](https://sourcey-gauzy.pages.dev/database/mikroorm/index.md) — MikroORM configuration
- [Knex Setup](https://sourcey-gauzy.pages.dev/database/knex/index.md) — Knex query builder
- [Migrations](https://sourcey-gauzy.pages.dev/database/migrations/index.md) — schema migration management
- [Seeding](https://sourcey-gauzy.pages.dev/database/seeding/index.md) — demo and test data
- [Multi-ORM Entities](https://sourcey-gauzy.pages.dev/database/multi-orm-entities/index.md) — entity definition patterns
- [Tenant Filtering](https://sourcey-gauzy.pages.dev/database/tenant-filtering/index.md) — tenant-scoped data access
