audit_log
Key
id  
uuid
NN
table_name  
character varying(255)
NN
entity_id  
uuid
NN
entity_action  
entity_action
NN
entity_timestamp  
timestamp without time zone
NN
Key
user_id  
uuid
NN
values_original  
jsonb
values_new  
jsonb
calendar
Key
id  
uuid
NN
Key
company_id  
uuid
NN
created_at  
timestamp without time zone
NN
calendar_event_categories
Key
id  
uuid
NN
Key
title  
character varying(255)
NN
Key
calendar_id  
uuid
NN
calendar_event_participants
Key
event_id  
uuid
NN
Key
user_id  
uuid
NN
calendar_events
Key
id  
uuid
NN
title  
character varying(255)
NN
Key
calendar_id  
uuid
NN
Key
category_id  
uuid
NN
created_at  
timestamp without time zone
NN
color_hex_6  
character(7)
description  
text
NN
event_start  
timestamp without time zone
NN
event_end  
timestamp without time zone
NN
companies
Key
id  
uuid
NN
Key
company_name  
character varying(255)
NN
company_size  
company_size
NN
total_revenue  
double precision
NN
industry  
character varying(100)
NN
business_type  
business_type
NN
Key
country_id  
uuid
NN
website  
character varying(255)
created_at  
timestamp without time zone
NN
companies_notes
Key
id  
uuid
NN
note_text  
text
NN
Key
company_id  
uuid
NN
created_at  
timestamp without time zone
NN
Key
created_by_user_id  
uuid
NN
contacts
Key
id  
uuid
NN
first_name  
character varying(255)
NN
last_name  
character varying(255)
NN
email  
character varying(255)
NN
telephone  
character varying(255)
NN
Key
company_id  
uuid
NN
job_title  
character varying(255)
NN
stage  
contact_stage
NN
Key
timezone_id  
uuid
created_at  
timestamp without time zone
NN
contacts_notes
Key
id  
uuid
NN
note_text  
text
NN
Key
contact_id  
uuid
NN
created_at  
timestamp without time zone
NN
Key
created_by_user_id  
uuid
NN
countries
Key
id  
uuid
NN
Key
num_code  
integer
NN
Key
alpha_2_code  
character varying
NN
Key
alpha_3_code  
character varying
NN
Key
short_name  
character varying(100)
NN
nationality  
character varying(100)
NN
kanban
Key
id  
uuid
NN
Key
company_id  
uuid
NN
created_at  
timestamp without time zone
NN
kanban_stages
Key
id  
uuid
NN
title  
character varying(255)
NN
Key
kanban_table_id  
uuid
NN
created_at  
timestamp without time zone
NN
kanban_task_checklist
Key
id  
uuid
NN
title  
character varying(255)
NN
completed  
boolean
NN
created_at  
timestamp without time zone
NN
Key
task_id  
uuid
NN
kanban_task_comments
Key
id  
uuid
NN
Key
task_id  
uuid
NN
created_at  
timestamp without time zone
NN
updated_at  
timestamp without time zone
Key
created_by_user_id  
uuid
comment_text  
text
kanban_tasks
Key
id  
uuid
NN
serial  
character varying(6)
NN
title  
character varying(255)
NN
completed  
boolean
Key
stage  
uuid
NN
description_text  
text
due_date  
timestamp without time zone
Key
assigned_user_id  
uuid
created_at  
timestamp without time zone
NN
kanban_tasks_order
Key
id  
uuid
NN
task_order[]  
text
NN
Key
column_id  
uuid
NN
Key
kanban_id  
uuid
NN
created_at  
timestamp without time zone
NN
updated_at  
timestamp without time zone
pipeline
Key
id  
uuid
NN
Key
company_id  
uuid
NN
created_at  
timestamp without time zone
NN
pipeline_deals
Key
id  
uuid
NN
serial  
character varying(6)
NN
title  
character varying(255)
NN
Key
company_name  
uuid
NN
Key
pipeline_stage  
uuid
NN
total_revenue  
numeric(14,2)
NN
Key
deal_owner  
uuid
NN
Key
deal_contact  
uuid
NN
created_at  
timestamp without time zone
NN
pipeline_deals_order
Key
id  
uuid
NN
deal_order[]  
text
NN
Key
column_id  
uuid
NN
Key
pipeline_id  
uuid
NN
created_at  
timestamp without time zone
NN
updated_at  
timestamp without time zone
pipeline_stages
Key
id  
uuid
NN
title  
character varying(255)
NN
created_at  
timestamp without time zone
NN
Key
pipeline_table_id  
uuid
NN
quotes
Key
id  
uuid
NN
Key
title  
character varying(255)
NN
Key
company_id  
uuid
NN
total  
numeric(14,2)
NN
sales_tax  
numeric(4,2)
NN
quote_stage  
quote_stage
NN
Key
prepared_for_contact_id  
uuid
NN
Key
prepared_by_user_id  
uuid
NN
issued_at  
timestamp without time zone
due_at  
timestamp without time zone
created_at  
timestamp without time zone
NN
quotes_notes
Key
id  
uuid
NN
note_text  
text
NN
Key
quote_id  
uuid
NN
created_at  
timestamp without time zone
NN
Key
created_by_user_id  
uuid
NN
quotes_services
Key
id  
uuid
NN
title  
character varying(255)
NN
price  
numeric(14,2)
NN
quantity  
integer
NN
discount  
numeric(4,2)
NN
total  
numeric(14,2)
NN
Key
quote_id  
uuid
NN
created_at  
timestamp without time zone
NN
time_zones_utc
Key
id  
uuid
NN
alpha_2_code  
character(2)
NN
gmt_offset  
character(6)
NN
Key
country_id  
uuid
NN
user
Key
id  
uuid
NN
Key
email  
character varying(255)
NN
user_role  
user_role
NN
password  
character varying(255)
NN
password_changed_at  
timestamp without time zone
NN
password_reset_token  
character varying(64)
password_reset_expires  
timestamp without time zone
account_created_at  
timestamp without time zone
NN
account_updated_at  
timestamp without time zone
NN
account_frozen_at  
timestamp without time zone
account_frozen  
boolean
NN
account_active  
boolean
NN
Key
email_index
user_profile
Key
id  
uuid
NN
Key
user_id  
uuid
NN
first_name  
character varying(255)
NN
last_name  
character varying(255)
NN
email  
character varying(255)
NN
mobile  
character varying(255)
telephone  
character varying(255)
Key
timezone_id  
uuid
Key
country_id  
uuid
NN
Key
company_id  
uuid
NN
company_role  
company_role
NN
profile_image  
character(32)
updated_at  
timestamp without time zone
NN
user_tokens
Key
jti  
uuid
NN
iat  
integer
NN
exp  
integer
NN
acc  
integer
NN
activated  
boolean
NN
Key
user_id  
uuid
NN
Function
audit_trigger
Trigger
audit_calendar_category
Trigger
audit_calendar_event
Trigger
audit_companies
Trigger
audit_companies_notes
Trigger
audit_contacts
Trigger
audit_contacts_notes
Trigger
audit_pipeline_stages
Trigger
audit_pipeline_deals
Trigger
audit_kanban_tasks
Trigger
audit_kanban_task_checklist
Trigger
audit_kanban_task_comments
Trigger
audit_quotes
Trigger
audit_quotes_notes
Trigger
audit_quotes_services
Enum
business_type
Enum
company_role
Enum
company_size
Enum
contact_stage
Enum
entity_action
Enum
quote_stage
Enum
user_role

Documentation for project CRM-Server
CRM-Server
Project
Name
CRM-Server
Diagram
Name
Main Diagram
Report
Generated
27/09/2025 | 12:07:43
tables
Name
audit_log
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
table_name
character varying
255
Yes
entity_id
uuid
Yes
entity_action
Yes
entity_timestamp
timestamp without time zone
Yes
Default value
now()
user_id
uuid
Yes
values_original
jsonb
values_new
jsonb
Keys
audit_log_pkey
Column in audit_log_pkey
id
Relationships
Name
calendar
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
company_id
uuid
Yes
created_at
timestamp without time zone
Yes
Default value
now()
Keys
calendar_pkey
Column in calendar_pkey
id
calendar_company_id_unique
Column in calendar_company_id_unique
company_id
Name
calendar_event_categories
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
title
character varying
255
Yes
calendar_id
uuid
Yes
Keys
calendar_event_categories_pkey
Column in calendar_event_categories_pkey
id
calendar_event_categories_title_calendar_id_unique
Column in calendar_event_categories_title_calendar_id_unique
title
Column in calendar_event_categories_title_calendar_id_unique
calendar_id
Name
calendar_event_participants
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
event_id
uuid
Yes
user_id
uuid
Yes
Keys
calendar_event_participants_pkey
Name
calendar_events
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
title
character varying
255
Yes
calendar_id
uuid
Yes
category_id
uuid
Yes
created_at
timestamp without time zone
Yes
Default value
now()
color_hex_6
character
7
description
text
Yes
event_start
timestamp without time zone
Yes
event_end
timestamp without time zone
Yes
Keys
calendar_events_pkey
Column in calendar_events_pkey
id
Name
companies
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
company_name
character varying
255
Yes
company_size
Yes
total_revenue
double precision
Yes
industry
character varying
100
Yes
business_type
Yes
country_id
uuid
Yes
website
character varying
255
created_at
timestamp without time zone
Yes
Default value
now()
Keys
companies_pkey
Column in companies_pkey
id
companies_company_name_unique
Column in companies_company_name_unique
company_name
Name
companies_notes
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
note_text
text
Yes
company_id
uuid
Yes
created_at
timestamp without time zone
Yes
Default value
now()
created_by_user_id
uuid
Yes
Keys
companies_notes_pkey
Column in companies_notes_pkey
id
Name
contacts
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
first_name
character varying
255
Yes
last_name
character varying
255
Yes
email
character varying
255
Yes
telephone
character varying
255
Yes
company_id
uuid
Yes
job_title
character varying
255
Yes
stage
Yes
timezone_id
uuid
created_at
timestamp without time zone
Yes
Default value
now()
Keys
contacts_pkey
Column in contacts_pkey
id
Name
contacts_notes
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
note_text
text
Yes
contact_id
uuid
Yes
created_at
timestamp without time zone
Yes
Default value
now()
created_by_user_id
uuid
Yes
Keys
contacts_notes_pkey
Column in contacts_notes_pkey
id
Name
countries
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
num_code
integer
Yes
alpha_2_code
character varying
Yes
alpha_3_code
character varying
Yes
short_name
character varying
100
Yes
nationality
character varying
100
Yes
Keys
countries_pkey
Column in countries_pkey
id
countries_alpha_2_code_unique
Column in countries_alpha_2_code_unique
alpha_2_code
countries_alpha_3_code_unique
Column in countries_alpha_3_code_unique
alpha_3_code
countries_num_code_unique
Column in countries_num_code_unique
num_code
countries_short_name_unique
Column in countries_short_name_unique
short_name
Name
kanban
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
company_id
uuid
Yes
created_at
timestamp without time zone
Yes
Default value
now()
Keys
kanban_pkey
Column in kanban_pkey
id
Name
kanban_stages
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
title
character varying
255
Yes
kanban_table_id
uuid
Yes
created_at
timestamp without time zone
Yes
Default value
now()
Keys
kanban_stages_pkey
Column in kanban_stages_pkey
id
Name
kanban_task_checklist
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
title
character varying
255
Yes
completed
boolean
Yes
Default value
false
created_at
timestamp without time zone
Yes
Default value
now()
task_id
uuid
Yes
Keys
kanban_task_checklist_pkey
Column in kanban_task_checklist_pkey
id
Name
kanban_task_comments
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
task_id
uuid
Yes
created_at
timestamp without time zone
Yes
Default value
now()
updated_at
timestamp without time zone
created_by_user_id
uuid
comment_text
text
Keys
kanban_task_comments_pkey
Column in kanban_task_comments_pkey
id
Name
kanban_tasks
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
serial
character varying
6
Yes
title
character varying
255
Yes
completed
boolean
Default value
false
stage
uuid
Yes
description_text
text
due_date
timestamp without time zone
assigned_user_id
uuid
created_at
timestamp without time zone
Yes
Default value
now()
Keys
kanban_tasks_pkey
Column in kanban_tasks_pkey
id
Name
kanban_tasks_order
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
task_order
text
Yes
Array
Yes
Default value
ARRAY[]::text[]
column_id
uuid
Yes
kanban_id
uuid
Yes
created_at
timestamp without time zone
Yes
Default value
now()
updated_at
timestamp without time zone
Keys
kanban_tasks_order_pkey
Column in kanban_tasks_order_pkey
id
Name
pipeline
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
company_id
uuid
Yes
created_at
timestamp without time zone
Yes
Default value
now()
Keys
pipeline_pkey
Column in pipeline_pkey
id
Name
pipeline_deals
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
serial
character varying
6
Yes
title
character varying
255
Yes
company_name
uuid
Yes
pipeline_stage
uuid
Yes
total_revenue
numeric
14,2
Yes
Default value
0.00
deal_owner
uuid
Yes
deal_contact
uuid
Yes
created_at
timestamp without time zone
Yes
Default value
now()
Keys
pipeline_deals_pkey
Column in pipeline_deals_pkey
id
Name
pipeline_deals_order
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
deal_order
text
Yes
Array
Yes
Default value
ARRAY[]::text[]
column_id
uuid
Yes
pipeline_id
uuid
Yes
created_at
timestamp without time zone
Yes
Default value
now()
updated_at
timestamp without time zone
Keys
pipeline_deals_order_pkey
Column in pipeline_deals_order_pkey
id
Name
pipeline_stages
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
title
character varying
255
Yes
created_at
timestamp without time zone
Yes
Default value
now()
pipeline_table_id
uuid
Yes
Keys
pipeline_stages_pkey
Column in pipeline_stages_pkey
id
Name
quotes
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
title
character varying
255
Yes
company_id
uuid
Yes
total
numeric
14,2
Yes
Default value
0.00
sales_tax
numeric
4,2
Yes
Default value
20.00
quote_stage
Yes
prepared_for_contact_id
uuid
Yes
prepared_by_user_id
uuid
Yes
issued_at
timestamp without time zone
due_at
timestamp without time zone
created_at
timestamp without time zone
Yes
Default value
now()
Keys
quotes_pkey
Column in quotes_pkey
id
quotes_title_unique
Column in quotes_title_unique
title
Name
quotes_notes
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
note_text
text
Yes
quote_id
uuid
Yes
created_at
timestamp without time zone
Yes
Default value
now()
created_by_user_id
uuid
Yes
Keys
quotes_notes_pkey
Column in quotes_notes_pkey
id
Name
quotes_services
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
title
character varying
255
Yes
price
numeric
14,2
Yes
Default value
0.00
quantity
integer
Yes
Default value
0
discount
numeric
4,2
Yes
Default value
0.00
total
numeric
14,2
Yes
Default value
0.00
quote_id
uuid
Yes
created_at
timestamp without time zone
Yes
Default value
now()
Keys
quotes_services_pkey
Column in quotes_services_pkey
id
Name
time_zones_utc
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
alpha_2_code
character
2
Yes
gmt_offset
character
6
Yes
country_id
uuid
Yes
Keys
time_zones_utc_pkey
Column in time_zones_utc_pkey
id
Name
user
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
id
uuid
Yes
Yes
Default value
gen_random_uuid()
email
character varying
255
Yes
user_role
Yes
Default value
'USER'::user_role
password
character varying
255
Yes
Default value
''::character varying
password_changed_at
timestamp without time zone
Yes
Default value
now()
password_reset_token
character varying
64
password_reset_expires
timestamp without time zone
account_created_at
timestamp without time zone
Yes
Default value
now()
account_updated_at
timestamp without time zone
Yes
Default value
now()
account_frozen_at
timestamp without time zone
Default value
now()
account_frozen
boolean
Yes
Default value
true
account_active
boolean
Yes
Default value
false
Indexes
email_index
Column name
email
Nulls last
Yes
Unique
Yes
Using
btree
Keys
user_pkey
Column in user_pkey
id
user_email_unique
Column in user_email_unique
email
Name
user_tokens
Properties
Schema
public
Columns
Name
Data type
Param
Key
Not Null
jti
uuid
Yes
Yes
iat
integer
Yes
exp
integer
Yes
acc
integer
Yes
Default value
0
activated
boolean
Yes
Default value
false
user_id
uuid
Yes
Keys
user_tokens_pkey
Column in user_tokens_pkey
jti
Relationships
relationships
Name
audit_log_user_id_user_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in user
Column in audit_log
user_pkey
id
user_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
calendar_company_id_companies_id_fk
Name
Source
Target
Cardinality type:
One to
one
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in companies
Column in calendar
companies_pkey
id
company_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
calendar_event_categories_calendar_id_calendar_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in calendar
Column in calendar_event_categories
calendar_pkey
id
calendar_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
calendar_event_participants_event_id_calendar_events_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in calendar_events
Column in calendar_event_participants
calendar_events_pkey
id
event_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
calendar_event_participants_user_id_user_profile_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in user_profile
Column in calendar_event_participants
user_profile_pkey
id
user_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
calendar_events_calendar_id_calendar_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in calendar
Column in calendar_events
calendar_pkey
id
calendar_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
calendar_events_category_id_calendar_event_categories_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in calendar_event_categories
Column in calendar_events
calendar_event_categories_pkey
id
category_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
companies_country_id_countries_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in countries
Column in companies
countries_pkey
id
country_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
companies_notes_company_id_companies_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in companies
Column in companies_notes
companies_pkey
id
company_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
companies_notes_created_by_user_id_user_profile_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in user_profile
Column in companies_notes
user_profile_pkey
id
created_by_user_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
contacts_company_id_companies_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in companies
Column in contacts
companies_pkey
id
company_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
contacts_timezone_id_time_zones_utc_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Optional
Key and columns
Key name
Column in time_zones_utc
Column in contacts
time_zones_utc_pkey
id
timezone_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
contacts_notes_contact_id_contacts_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in contacts
Column in contacts_notes
contacts_pkey
id
contact_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
contacts_notes_created_by_user_id_user_profile_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in user_profile
Column in contacts_notes
user_profile_pkey
id
created_by_user_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
kanban_company_id_companies_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in companies
Column in kanban
companies_pkey
id
company_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
kanban_stages_kanban_table_id_kanban_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in kanban
Column in kanban_stages
kanban_pkey
id
kanban_table_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
kanban_task_checklist_task_id_kanban_tasks_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in kanban_tasks
Column in kanban_task_checklist
kanban_tasks_pkey
id
task_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
kanban_task_comments_created_by_user_id_user_profile_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Optional
Key and columns
Key name
Column in user_profile
Column in kanban_task_comments
user_profile_pkey
id
created_by_user_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
kanban_task_comments_task_id_kanban_tasks_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in kanban_tasks
Column in kanban_task_comments
kanban_tasks_pkey
id
task_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
kanban_tasks_assigned_user_id_user_profile_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Optional
Key and columns
Key name
Column in user_profile
Column in kanban_tasks
user_profile_pkey
id
assigned_user_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
kanban_tasks_stage_kanban_stages_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in kanban_stages
Column in kanban_tasks
kanban_stages_pkey
id
stage
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
kanban_tasks_order_column_id_kanban_stages_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in kanban_stages
Column in kanban_tasks_order
kanban_stages_pkey
id
column_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
kanban_tasks_order_kanban_id_kanban_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in kanban
Column in kanban_tasks_order
kanban_pkey
id
kanban_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
pipeline_company_id_companies_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in companies
Column in pipeline
companies_pkey
id
company_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
pipeline_deals_company_name_companies_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in companies
Column in pipeline_deals
companies_pkey
id
company_name
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
pipeline_deals_deal_contact_contacts_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in contacts
Column in pipeline_deals
contacts_pkey
id
deal_contact
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
pipeline_deals_deal_owner_user_profile_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in user_profile
Column in pipeline_deals
user_profile_pkey
id
deal_owner
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
pipeline_deals_pipeline_stage_pipeline_stages_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in pipeline_stages
Column in pipeline_deals
pipeline_stages_pkey
id
pipeline_stage
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
pipeline_deals_order_column_id_pipeline_stages_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in pipeline_stages
Column in pipeline_deals_order
pipeline_stages_pkey
id
column_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
pipeline_deals_order_pipeline_id_pipeline_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in pipeline
Column in pipeline_deals_order
pipeline_pkey
id
pipeline_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
pipeline_stages_pipeline_table_id_pipeline_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in pipeline
Column in pipeline_stages
pipeline_pkey
id
pipeline_table_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
quotes_company_id_companies_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in companies
Column in quotes
companies_pkey
id
company_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
quotes_prepared_by_user_id_user_profile_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in user_profile
Column in quotes
user_profile_pkey
id
prepared_by_user_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
quotes_prepared_for_contact_id_contacts_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in contacts
Column in quotes
contacts_pkey
id
prepared_for_contact_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
quotes_notes_created_by_user_id_user_profile_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in user_profile
Column in quotes_notes
user_profile_pkey
id
created_by_user_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
quotes_notes_quote_id_quotes_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in quotes
Column in quotes_notes
quotes_pkey
id
quote_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
quotes_services_quote_id_quotes_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in quotes
Column in quotes_services
quotes_pkey
id
quote_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
time_zones_utc_country_id_countries_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in countries
Column in time_zones_utc
countries_pkey
id
country_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
user_profile_company_id_companies_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in companies
Column in user_profile
companies_pkey
id
company_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
user_profile_country_id_countries_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in countries
Column in user_profile
countries_pkey
id
country_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
user_profile_timezone_id_time_zones_utc_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Optional
Key and columns
Key name
Column in time_zones_utc
Column in user_profile
time_zones_utc_pkey
id
timezone_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
user_profile_user_id_user_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in user
Column in user_profile
user_pkey
id
user_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Name
user_tokens_user_id_user_id_fk
Name
Source
Target
Cardinality type:
One to
many
Ordinality:
Mandatory
Mandatory
Key and columns
Key name
Column in user
Column in user_tokens
user_pkey
id
user_id
Properties
Rerefential integrity - parent delete
No action
Referential integrity - parent update
No action
Other objects
Name
audit_trigger
Type
Function
Schema
public
Code
CREATE OR REPLACE FUNCTION public.audit_trigger()
 RETURNS trigger
 LANGUAGE plpgsql
AS $function$
DECLARE
  new_data jsonb;
  old_data jsonb;
  key text;
  new_values jsonb;
  old_values jsonb;
  client_id uuid;
BEGIN
  client_id := current_setting('app.client_id', true);
  new_values := '{}';
  old_values := '{}';

  IF TG_OP = 'UPDATE' THEN
    new_data := to_jsonb(NEW);
    old_data := to_jsonb(OLD);

    FOR key IN SELECT jsonb_object_keys(new_data) INTERSECT SELECT jsonb_object_keys(old_data)
    LOOP
      IF new_data ->> key != old_data ->> key THEN
          new_values := new_values || jsonb_build_object(key, new_data ->> key);
          old_values := old_values || jsonb_build_object(key, old_data ->> key);
      END IF;
    END LOOP;

  ELSIF TG_OP = 'DELETE' THEN
    old_data := to_jsonb(OLD);
    old_values := old_data;

    FOR key IN SELECT jsonb_object_keys(old_data)
    LOOP
      old_values := old_values || jsonb_build_object(key, old_data ->> key);
    END LOOP;

  END IF;

  IF (TG_OP = 'DELETE') THEN
    INSERT INTO audit_log (table_name, entity_id, entity_action, user_id, values_original, values_new)
    VALUES (TG_TABLE_NAME, OLD.id, TG_OP::entity_action, client_id, old_values, new_values);
  ELSIF (TG_OP = 'UPDATE') THEN
    INSERT INTO audit_log (table_name, entity_id, entity_action, user_id, values_original, values_new)
    VALUES (TG_TABLE_NAME, NEW.id, TG_OP::entity_action, client_id, old_values, new_values);
  END IF;
  RETURN NULL;
END;
$function$
;
Name
audit_calendar_category
Type
Trigger
Schema
public
Code
CREATE TRIGGER audit_calendar_category AFTER DELETE OR UPDATE ON public.calendar_event_categories FOR EACH ROW EXECUTE FUNCTION audit_trigger();
Name
audit_calendar_event
Type
Trigger
Schema
public
Code
CREATE TRIGGER audit_calendar_event AFTER DELETE OR UPDATE ON public.calendar_events FOR EACH ROW EXECUTE FUNCTION audit_trigger();
Name
audit_companies
Type
Trigger
Schema
public
Code
CREATE TRIGGER audit_companies AFTER DELETE OR UPDATE ON public.companies FOR EACH ROW EXECUTE FUNCTION audit_trigger();
Name
audit_companies_notes
Type
Trigger
Schema
public
Code
CREATE TRIGGER audit_companies_notes AFTER DELETE OR UPDATE ON public.companies_notes FOR EACH ROW EXECUTE FUNCTION audit_trigger();
Name
audit_contacts
Type
Trigger
Schema
public
Code
CREATE TRIGGER audit_contacts AFTER DELETE OR UPDATE ON public.contacts FOR EACH ROW EXECUTE FUNCTION audit_trigger();
Name
audit_contacts_notes
Type
Trigger
Schema
public
Code
CREATE TRIGGER audit_contacts_notes AFTER DELETE OR UPDATE ON public.contacts_notes FOR EACH ROW EXECUTE FUNCTION audit_trigger();
Name
audit_pipeline_stages
Type
Trigger
Schema
public
Code
CREATE TRIGGER audit_pipeline_stages AFTER DELETE OR UPDATE ON public.pipeline_stages FOR EACH ROW EXECUTE FUNCTION audit_trigger();
Name
audit_pipeline_deals
Type
Trigger
Schema
public
Code
CREATE TRIGGER audit_pipeline_deals AFTER DELETE OR UPDATE ON public.pipeline_deals FOR EACH ROW EXECUTE FUNCTION audit_trigger();
Name
audit_kanban_tasks
Type
Trigger
Schema
public
Code
CREATE TRIGGER audit_kanban_tasks AFTER DELETE OR UPDATE ON public.kanban_tasks FOR EACH ROW EXECUTE FUNCTION audit_trigger();
Name
audit_kanban_task_checklist
Type
Trigger
Schema
public
Code
CREATE TRIGGER audit_kanban_task_checklist AFTER DELETE OR UPDATE ON public.kanban_task_checklist FOR EACH ROW EXECUTE FUNCTION audit_trigger();
Name
audit_kanban_task_comments
Type
Trigger
Schema
public
Code
CREATE TRIGGER audit_kanban_task_comments AFTER DELETE OR UPDATE ON public.kanban_task_comments FOR EACH ROW EXECUTE FUNCTION audit_trigger();
Name
audit_quotes
Type
Trigger
Schema
public
Code
CREATE TRIGGER audit_quotes AFTER DELETE OR UPDATE ON public.quotes FOR EACH ROW EXECUTE FUNCTION audit_trigger();
Name
audit_quotes_notes
Type
Trigger
Schema
public
Code
CREATE TRIGGER audit_quotes_notes AFTER DELETE OR UPDATE ON public.quotes_notes FOR EACH ROW EXECUTE FUNCTION audit_trigger();
Name
audit_quotes_services
Type
Trigger
Schema
public
Code
CREATE TRIGGER audit_quotes_services AFTER DELETE OR UPDATE ON public.quotes_services FOR EACH ROW EXECUTE FUNCTION audit_trigger();
Name
business_type
Type
Enum
Schema
public
Enum values
'B2B',
'B2C'
Name
company_role
Type
Enum
Schema
public
Enum values
'ADMIN',
'SALES_MANAGER',
'SALES_PERSON',
'SALES_INTERN'
Name
company_size
Type
Enum
Schema
public
Enum values
'MICRO',
'SMALL',
'MEDIUM',
'LARGE'
Name
contact_stage
Type
Enum
Schema
public
Enum values
'NEW',
'CONTACTED',
'INTERESTED',
'UNQUALIFIED',
'QUALIFIED',
'NEGOTIATION',
'LOST',
'WON',
'CHURNED'
Name
entity_action
Type
Enum
Schema
public
Enum values
'INSERT',
'UPDATE',
'DELETE'
Name
quote_stage
Type
Enum
Schema
public
Enum values
'DRAFT',
'SENT',
'ACCEPTED'
Name
user_role
Type
Enum
Schema
public
Enum values
'ROOT',
'ADMIN',
'MODERATOR',
'USER'