> For the complete documentation index, see [llms.txt](https://gramhal.gitbook.io/bolbhav/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gramhal.gitbook.io/bolbhav/chapter-1-database/user-data/person_table.md).

# person\_table

This is the user table, where all information on the users are stored.

## Model

<table><thead><tr><th width="278">Field</th><th>Type</th><th data-type="checkbox">Nullable</th><th>Default value</th></tr></thead><tbody><tr><td>id</td><td>int4</td><td>false</td><td></td></tr><tr><td>name</td><td>varchar(250)</td><td>true</td><td></td></tr><tr><td>password</td><td>varchar</td><td>true</td><td></td></tr><tr><td>roles</td><td>varchar</td><td>true</td><td></td></tr><tr><td>phone_number</td><td>varchar</td><td>true</td><td></td></tr><tr><td>created_at</td><td>timestamp</td><td>true</td><td></td></tr><tr><td>updated_at</td><td>timestamp</td><td>true</td><td></td></tr><tr><td>referrer_data</td><td>json</td><td>true</td><td></td></tr><tr><td>is_worker_referral</td><td>bool</td><td>true</td><td>False</td></tr><tr><td>has_received_default_wa</td><td>bool</td><td>true</td><td>False</td></tr><tr><td>fcm_token</td><td></td><td>false</td><td></td></tr><tr><td>mobile_number</td><td></td><td>false</td><td></td></tr></tbody></table>

## Description of fields

### id

This is the primary key

### name

Name of the user. It is not a required field. While registering users through WhatsApp Chatbot, we use default name such as "kisaan", "किसान"

### password

if a user is using the admin portal, then this is the password for them to login.

### roles

This is a text field that can accommodate comma-separated values for roles. User can have one or more roles comma-separated. These roles are used by the Admin portal to allow access to specific models and actions within models.

{% hint style="info" %}
This roles field need to be put inside separate role & permission handling database tables. Once that is done, the roles field from person table will be deleted.
{% endhint %}

Currently, there are three roles supported in the admin portal:

1. superadmin: Those users who can access all features of the Admin portal.
2. cs\_user: employees who uploaded the receipts. All of them except to have left the job and are now continuing as regular users, but they are still marked as cs\_user.
3. user: these are users who can access admin portal for data validation only. Below image shows that these users can access mandi receipts table only, with the option to edit, approve or reject a receipt.

<figure><img src="https://3898150257-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrjNYs8KmxBlZvBKyEb2T%2Fuploads%2FE9fn9wj3kJzADPCOMPqQ%2FScreenshot%202024-02-17%20at%2011.36.07%20PM.png?alt=media&amp;token=04af2225-49ef-4321-b20a-35669cfcdf7e" alt=""><figcaption></figcaption></figure>

### phone\_number

It is only unique identifier with user credentials. It is stored with country code of 91.&#x20;

{% hint style="info" %}
The constraint for this table is that a unique phone\_number cannot repeat. This was put in place to avoid multiple entries of the same phone\_number if a user repeatdely clicks on an action button.
{% endhint %}

### mobile\_number

This is a user's phone number stored without the country code 91.

### created\_at

The timestamp when is user is first registered.

### updated\_at

The timestamp at which the data is last updated.

### is\_worker\_referral

Boolean field that captures whether the user was referred by a team member or not. A popup comes after a new user registration where they are asked to put in the worker user's phone number for referral.

{% hint style="danger" %}
This field is outdated as we have removed the functionality and needs to be deleted.
{% endhint %}

### has\_received\_default\_wa

Bolbhav chatbot was sunsetted on 7th Dec 2023. After that day, if a user would write to Bolbhav chatbot number then it would not respond. Hence, we created a onetime default message that would be sent to the user only the first time they write to the Bolbhav chatbot. Basically, all incoming message to the Bolbhav chatbot comes to backend, and it is checked if this field is empty, if yes then the default message is sent to user on WhatsApp and this field is marked as True. If it is already True then no message is sent to the user.

### referrer\_data

If a user has downloaded the app via a referral link, then this field tells us about the referee. It is an array that carries the data about the referrer\_id.

```json
{
    "~channel": "whatsApp", 
    "~referring_link": "https://0vx58.app.link/08xY5W1w1Eb", 
    "+is_first_session": false, 
    "+clicked_branch_link": true, 
    "$canonical_url": "https://app.bolbhav.com", 
    "custom": "data", 
    "~campaign": "Bolbhav referrals", 
    "$canonical_identifier": "208904", 
    "$desktop_url": "https://app.bolbhav.com", 
    "~id": "1257064518614704472", 
    "+click_timestamp": 1700945810, 
    "+match_guaranteed": false, 
    "~feature": "referral", 
    "$og_title": "Bolbhav", 
    "+rn_cached_initial_event": true, 
    "referrer_id": "208904"
}
```

### fcm\_data

Upon login each users is provided an fcm\_token (registeration token) that expires after 6 months. <mark style="color:red;">**More details to be added.**</mark>&#x20;
