Kredal Docs
Reference

Database Schema

Tables, columns, RLS policies, and storage for Kredal. Generated from the migration SQL.

Generated file. Do not edit by hand — run npm run docs:gen. Source: kredal-app/supabase/migrations/*.sql.

Kredal runs on Supabase Postgres. Every table has Row-Level Security enabled and is scoped to workspace membership. See the security model for the rationale and the Verify RLS runbook for testing.

Entity relationships

Tables

profiles

Row-Level Security: enabled.

ColumnTypeNullKeyNotes
iduuidnoPK
full_nametextyes
roletextnocheck: role in ('founder','consultant','admin')
created_attimestamptzno
updated_attimestamptzno

RLS policies: profiles_select_own (select), profiles_insert_own (insert), profiles_update_own (update).

workspaces

Row-Level Security: enabled.

ColumnTypeNullKeyNotes
iduuidnoPK
nametextno
workspace_typetextnocheck: workspace_type in ('single_company','consultant')
owner_user_iduuidnoFK → profiles
created_attimestamptzno
updated_attimestamptzno

RLS policies: workspaces_select_member (select), workspaces_insert_self (insert), workspaces_update_admin (update), workspaces_delete_owner (delete).

workspace_members

Row-Level Security: enabled.

ColumnTypeNullKeyNotes
iduuidnoPK
workspace_iduuidnoFK → workspaces
user_iduuidnoFK → profiles
roletextnocheck: role in ('owner','admin','member','viewer')
created_attimestamptzno

RLS policies: workspace_members_select_member (select), workspace_members_insert (insert), workspace_members_update_admin (update), workspace_members_delete_admin (delete).

companies

Row-Level Security: enabled.

ColumnTypeNullKeyNotes
iduuidnoPK
workspace_iduuidnoFK → workspaces
legal_nametextno
trade_license_numbertextyes
emiratetextyes
jurisdiction_typetextnocheck: jurisdiction_type in ('mainland','free_zone','financial_free_zone','unknown')
authority_nametextyes
license_activity_codestext[]yes
incorporation_datedateyes
office_statustextyes
owner_nationalitytextyes
owner_uae_residency_statustextyes
expected_monthly_turnover_aednumericyes
target_banktextyes
target_account_typetextyes
statustextnocheck: status in ('draft','in_review','ready','high_risk','archived')
created_attimestamptzno
updated_attimestamptzno

RLS policies: companies_select_member (select), companies_insert_member (insert), companies_update_member (update), companies_delete_admin (delete).

company_owners

Row-Level Security: enabled.

ColumnTypeNullKeyNotes
iduuidnoPK
company_iduuidnoFK → companies
full_nametextno
nationalitytextyes
ownership_percentagenumericyes
is_ubobooleanno
uae_residency_statustextyes
emirates_id_last4textyes
passport_countrytextyes
created_attimestamptzno

RLS policies: company_owners_select_member (select), company_owners_write_member (all).

documents

Row-Level Security: enabled.

ColumnTypeNullKeyNotes
iduuidnoPK
company_iduuidnoFK → companies
uploaded_byuuidnoFK → profiles
document_typetextnocheck: document_type in ( 'trade_license','moa_aoa','shareholder_register','ubo_declaration', 'owner_passport','owner_emirates_id','owner_visa','proof_of_address', 'tenancy_or_office_agreement','invoice_or_contract','bank_statement', 'source_of_funds_evidence','business_plan','company_profile','other' )
storage_pathtextno
original_filenametextno
mime_typetextyes
file_size_bytesbigintyes
expiry_datedateyes
statustextnocheck: status in ('uploaded','parsed','needs_review','accepted','rejected')
extracted_texttextyes
parse_confidencenumericyes
created_attimestamptzno
updated_attimestamptzno

RLS policies: documents_select_member (select), documents_write_member (all).

questionnaire_responses

Row-Level Security: enabled.

ColumnTypeNullKeyNotes
iduuidnoPK
company_iduuidnoFK → companies
sectiontextno
question_keytextno
answer_jsonjsonbno
created_attimestamptzno
updated_attimestamptzno

RLS policies: questionnaire_select_member (select), questionnaire_write_member (all).

readiness_assessments

Row-Level Security: enabled.

ColumnTypeNullKeyNotes
iduuidnoPK
company_iduuidnoFK → companies
overall_scoreintegernocheck: overall_score >= 0 and overall_score <= 100
risk_leveltextnocheck: risk_level in ('low','medium','high')
category_scoresjsonbno
flagsjsonbno
recommendationsjsonbno
scoring_versiontextno
created_byuuidnoFK → profiles
created_attimestamptzno

RLS policies: assessments_select_member (select), assessments_insert_member (insert).

reports

Row-Level Security: enabled.

ColumnTypeNullKeyNotes
iduuidnoPK
company_iduuidnoFK → companies
assessment_iduuidnoFK → readiness_assessments
report_typetextnocheck: report_type in ( 'founder_readiness','consultant_checklist','bank_application_pack','rejection_recovery_pack' )
titletextno
content_markdowntextno
storage_pathtextyes
created_byuuidnoFK → profiles
created_attimestamptzno

RLS policies: reports_select_member (select), reports_insert_member (insert).

audit_events

Row-Level Security: enabled.

ColumnTypeNullKeyNotes
iduuidnoPK
workspace_iduuidyesFK → workspaces
company_iduuidyesFK → companies
user_iduuidnoFK → profiles
event_typetextno
event_datajsonbno
created_attimestamptzno

RLS policies: audit_events_insert_member (insert), audit_events_select_admin (select).

Storage

Private bucket company-documents (not public). Path convention: {workspace_id}/{company_id}/{document_id}/{filename}. Storage RLS policies check workspace membership on the first path segment; access is only via short-lived signed URLs generated server-side.


Generated from 10 tables.

On this page