---
# System prepended metadata

title: Platter Database Schema Documentation

---

# Platter Database Schema Documentation

## Overview

1. `pla_organization`: This table stores information about various organizations that are using the platform. It includes fields for the organization's unique identifier (`id`), name (`name`), and status (`status`). The status can be 'new', 'approved', or 'disapproved'. Timestamp fields track when each record was created and last updated, and if it was deleted.

2. `pla_division`: Each organization can have multiple divisions, and information about these is stored in the `pla_division` table. It includes fields for the division's unique identifier (`id`), name (`name`), and description (`description`). It also has fields referencing the organization (`organizationId`) and parent division (`parentId`) the division belongs to. Similar to `pla_organization`, timestamp fields are included.

3. `pla_users`: This table stores information about the users of the platform. It includes fields for the user's unique identifier (`id`), name (`name`), username (`username`), password (`password`), email (`email`), phone (`phone`), and status (`status`). The user's role (`roles`) in the system is stored as well, which can be 'user', 'super-admin', 'admin', or 'trial'. Each user is associated with an organization (`organizationId`) and a division (`divisionId`).

4. `pla_integrations`: This table stores information about various platform integrations, such as Google Drive, OneDrive, Notion, and Confluence. It includes fields for the integration's unique identifier (`id`), account name (`account_name`), pivot method (`pivot_method`), and pivot (`pivot`). The type of integration (`type_integrations`), link status (`link_status`), and index status (`index_status`) are also stored.

5. `pla_documents`: This table stores data related to documents on the platform. Each document has a unique identifier (`id`), name (`document_name`), document id (`document_id`), MIME type (`document_mime`), and URI (`document_uri`). The document's modification time (`document_modified_time`) and status (`document_status`) are also tracked.

6. `pla_pivot_integration_documents`: This table establishes a many-to-many relationship between the `pla_integrations` and `pla_documents` tables. Each record includes the unique identifier of an integration (`id_integration`) and a document (`id_document`).

7. `pla_document_permissions`: This table stores information about the permissions associated with each document. It includes the unique identifier for a permission (`id_permission`), the associated document id (`id_document`), the type of permission (`tipe`), the pivot (`pivot`), and the user's role in relation to the document (`user_role_document`).

8. `pla_pivot_user_integrations` and `pla_pivot_org_integrations`: These tables establish many-to-many relationships between users and integrations, and organizations and integrations respectively. 

9. `pla_conversations` and `pla_messages`: These tables store data related to conversations between users. `pla_conversations` includes a record for each conversation, while `pla_messages` includes a record for each message within a conversation.

10. `pla_graph_messages`: This table stores data related to graphical messages. Each record includes the unique identifier of a message (`id_message`), the type of graph (`graph_type`), and the graph data (`graph_json`).

## Tables

1. `pla_organization`

   Stores data related to organizations.

   | Column | Type | Description |
   |---|---|---|
   | `id` | UUID | The unique identifier for an organization. |
   | `name` | character varying(255) | The name of the organization. |
   | `status` | character varying(255) | The status of the organization. Can be 'new', 'approved', or 'disapproved'. |
   | `createdAt` | timestamp with time zone | The time at which the organization was created. |
   | `updatedAt` | timestamp with time zone | The time at which the organization was last updated. |
   | `deletedAt` | timestamp with time zone | The time at which the organization was deleted. |
   | `owned_by` | UUID | The ID of the user who owns the organization. References `pla_users(id)`. |

2. `pla_division`

   Stores data related to divisions within organizations.

   | Column | Type | Description |
   |---|---|---|
   | `id` | UUID | The unique identifier for a division. |
   | `name` | character varying(255) | The name of the division. |
   | `description` | character varying(255) | The description of the division. |
   | `organizationId` | UUID | The ID of the organization that the division belongs to. References `pla_organization(id)`. |
   | `childId` | UUID | The ID of the child division. References `pla_division(id)`. |
   | `parentId` | UUID | The ID of the parent division. References `pla_division(id)`. |
   | `createdAt` | timestamp with time zone | The time at which the division was created. |
   | `updatedAt` | timestamp with time zone | The time at which the division was last updated. |
   | `deletedAt` | timestamp with time zone | The time at which the division was deleted. |
   | `owned_by` | UUID | The ID of the user who owns the division. References `pla_users(id)`. |

3. `pla_users`

   Stores data related to users.

   | Column | Type | Description |
   |---|---|---|
   | `id` | UUID | The unique identifier for a user. |
   | `name` | character varying(255) | The name of the user. |
   | `username` | character varying(255) | The username of the user. |
   | `password` | character varying(255) | The password of the user. |
   | `email` | character varying(255) | The email of the user. |
   | `phone` | character varying(255) | The phone number of the user. |
   | `status` | character varying(255) | The status of the user. Default is 'new'. |
   | `avatar_url` | character varying(255) | The URL of the user's avatar. |
   | `roles` | character varying(255) | The role of the user. Can be 'user', 'super-admin', 'admin', or 'trial'. |
   | `organizationId` | UUID | The ID of the organization that the user belongs to. References `pla_organization(id)`. |
   | `divisionId` | UUID | The ID of the division that the user belongs to. References `pla_division(id)`. |
   | `createdAt` | timestamp with time zone | The time at which the user was created. |
   | `updatedAt` | timestamp with time zone | The time at which the user was last updated. |
   | `deletedAt` | timestamp with time zone | The time at which the user was deleted. |


4. `pla_integrations`

   Stores data related to various integrations.

   | Column | Type | Description |
   |---|---|---|
   | `id` | UUID | The unique identifier for an integration. |
   | `account_name` | character varying(255) | The name of the account associated with the integration. |
   | `pivot_method` | character varying(255) | The pivot method for the integration. |
   | `pivot` | character varying(255) | The pivot for the integration. |
   | `type_integrations` | character varying(255) | The type of integration. Can be 'google-drive', 'one-drive', 'notion', or 'confluence'. |
   | `link_status` | character varying(255) | The status of the link. Can be 'new', 'processing', 'connected', 'failed', or 'revoked'. |
   | `index_status` | character varying(255) | The status of the index. Can be 'new', 'processing', 'indexed', or 'failed'. |
   | `credential_platform` | jsonb | The credentials for the platform. |
   | `createdAt` | timestamp with time zone | The time at which the integration was created. |
   | `updatedAt` | timestamp with time zone | The time at which the integration was last updated. |
   | `deletedAt` | timestamp with time zone | The time at which the integration was deleted. |

5. `pla_documents`

   Stores data related to documents.

   | Column | Type | Description |
   |---|---|---|
   | `id` | UUID | The unique identifier for a document. |
   | `document_name` | character varying(255) | The name of the document. |
   | `document_id` | character varying(255) | The ID of the document. |
   | `document_mime` | character varying(255) | The MIME type of the document. |
   | `document_uri` | character varying(255) | The URI of the document. |
   | `document_modified_time` | character varying(255) | The time at which the document was last modified. |
   | `document_status` | character varying(255) | The status of the document. Can be 'new', 'processing', 'indexed', 'failed', or 'unsupported'. |
   | `createdAt` | timestamp with time zone | The time at which the document was created. |
   | `updatedAt` | timestamp with time zone | The time at which the document was last updated. |
   | `deletedAt` | timestamp with time zone | The time at which the document was deleted. |

... and so on for the rest of the tables. The pattern is similar: each table has an `id` as primary key, and various other fields storing different types of information related to the entity the table represents. Most tables also have `createdAt`, `updatedAt`, and `deletedAt` fields to track when each record was created, last updated, and deleted.

## Indexes

Indexes are created for various fields to speed up searches on those fields. The pattern for creating an index is: `CREATE INDEX index_name ON table_name (column_name);`. Indexes have been created for fields that are likely to be used in queries, such as names, statuses,