---
tags: [companyuser, database]
module: CompanyUser
---

# DatabaseTables

## Connections
[[_CompanyUser]] · [[[Model]User]] · [[[Model]RecurringEntity]] · [[[Model]RoleAndPermission]] · [[[Cross]CrossModuleDependencies]]

## Source
`Modules/CompanyUser/Database/Migrations/tenancy/`

---

## `users`
| Column | Type | Notes |
|---|---|---|
| id | bigIncrements | PK |
| uname | string | Display name |
| email | string (unique) | Login email |
| mobile | string (nullable) | Phone |
| password | string | Hashed |
| is_active | boolean | Active/inactive |
| added_by | unsignedBigInteger (nullable) | FK → users.id (self-ref) |
| country_code | string (nullable) | Phone country code |
| img | string (nullable) | Profile image path |
| email_verified_at | timestamp (nullable) | Email verification |
| password_created_at | timestamp (nullable) | Password change tracking |
| last_visit_date | timestamp (nullable) | Last login |
| current_visit_date | timestamp (nullable) | Current login |
| last_activity_date | timestamp (nullable) | Last action timestamp |
| session_time | integer (nullable) | Session duration |
| deleted_at | timestamp (nullable) | Soft delete |
| created_at / updated_at | timestamps | — |

## `users_configs`
| Column | Type | Notes |
|---|---|---|
| id | bigIncrements | PK |
| user_id | unsignedBigInteger | FK → users.id (cascade delete) |
| key | string | Config key (e.g. `preferred_language`) |
| value | string | Config value |

## `referrals`
| Column | Type | Notes |
|---|---|---|
| id | bigIncrements | PK |
| name | string | Referral candidate name |
| country_code | string | Phone country code |
| mobile | string | Phone |
| email | string (nullable) | Email |
| notes | text (nullable) | Notes |
| is_joined | boolean | Has the referral joined? |
| user_id | unsignedBigInteger | FK → users.id |
| joined_date | datetime (nullable) | When they joined |
| website_id | unsignedBigInteger (nullable) | FK → websites |

## `recurring_entities`
| Column | Type | Notes |
|---|---|---|
| id | bigIncrements | PK |
| entity_type | string | `Invoice`, `JournalEntry` |
| entity_id | unsignedBigInteger | Polymorphic FK |
| start_date | date | Recurrence start |
| end_date | date (nullable) | Recurrence end |
| recurring_status | string | active / paused / finished |
| interval | string | daily / weekly / monthly / quarterly / yearly |
| next_generate_date | date | Next scheduled generation |
| created_by | unsignedBigInteger | FK → users.id |
| emails | JSON | Recipient emails |
| allow_send_emails | boolean | Email toggle |
| deleted_at | timestamp (nullable) | Soft delete |

## `recurring_entity_logs`
| Column | Type | Notes |
|---|---|---|
| id | bigIncrements | PK |
| recurring_entity_id | unsignedBigInteger | FK → recurring_entities.id |
| entity_type | string | Type of generated entity |
| entity_id | string | ID of generated entity (polymorphic) |
| status | string | success / failed |
| errors | JSON (nullable) | Error details |
| created_entity_id | unsignedBigInteger (nullable) | ID of the newly created entity |
| deleted_at | timestamp (nullable) | Soft delete |

## `roles` / `permissions` (Spatie)
Managed by `spatie/laravel-permission` migrations — standard roles, permissions, model_has_roles, model_has_permissions, role_has_permissions tables
