Contracts are stored in the public.contracts table in your Supabase database.
CREATE TABLE public.contracts (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
user_id UUID NOT NULL REFERENCES public.users(id) ON DELETE CASCADE,
property_id UUID REFERENCES public.properties(id) ON DELETE SET NULL,
contract_type TEXT NOT NULL CHECK (contract_type IN ('property_management', 'maintenance', 'leasing')),
status TEXT NOT NULL DEFAULT 'draft' CHECK (status IN ('draft', 'pending', 'signed', 'active', 'terminated')),
start_date DATE,
end_date DATE,
monthly_fee DECIMAL(10, 2),
fee_type TEXT CHECK (fee_type IN ('fixed', 'percentage')) DEFAULT 'fixed',
terms JSONB,
signed_at TIMESTAMPTZ,
signature_data JSONB,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);The contract HTML (the rendered contract document) is stored in the terms JSONB column under the key contract_html:
{
"owner": {
"full_name": "John Doe",
"email": "owner@example.com"
},
"property": {
"address_1": "123 Main St",
"city": "Oslo",
"state": "NO",
"zip_code": "0001"
},
"contract_html": "<html>...full contract HTML...</html>",
"service_id": "uuid-of-service"
}Signature information is stored in the signature_data JSONB column:
{
"owner": {
"token": "unique-token-for-signing",
"signed": true/false,
"signature": "data:image/png;base64,..." or "text signature",
"signed_at": "2026-01-25T10:30:00Z"
},
"company": {
"signed": true,
"signature": "Cozy Lift AS",
"signed_at": "2026-01-25T10:00:00Z",
"signed_by": "user-uuid"
}
}-
Via Supabase Dashboard:
- Go to Supabase Dashboard → Table Editor →
contractstable - View all contract records
- Click on a row to see the full JSONB data
- Go to Supabase Dashboard → Table Editor →
-
Via SQL Query:
-- View all contracts SELECT * FROM public.contracts; -- View contract HTML for a specific contract SELECT id, contract_type, status, terms->>'contract_html' as contract_html FROM public.contracts WHERE id = 'contract-uuid'; -- View signature data SELECT id, signature_data->'owner' as owner_signature, signature_data->'company' as company_signature FROM public.contracts WHERE id = 'contract-uuid';
-
Via Application:
- Admins can view contracts in
/dashboard/contracts/[id] - Contract HTML is displayed in the
ContractViewcomponent - The HTML is rendered using
dangerouslySetInnerHTML
- Admins can view contracts in
id: Unique contract identifier (UUID)user_id: ID of the admin user who created the contractproperty_id: Optional link to a property (can be null if manual address)contract_type: Type of contract ('property_management', 'maintenance', 'leasing')status: Current status ('draft', 'pending', 'signed', 'active', 'terminated')terms: JSONB object containing:owner: Owner details (name, email)property: Property details (address, city, zip_code)contract_html: The full rendered contract HTMLservice_id: ID of the service usedcompany: Company details (name, email)
signature_data: JSONB object containing signature information for both owner and companymonthly_fee: The fee amount (decimal)fee_type: 'fixed' or 'percentage'start_date/end_date: Contract period datessigned_at: Timestamp when contract was fully signedcreated_at/updated_at: Timestamps for record tracking
- The contract HTML is generated when the contract is created or updated
- The HTML is stored as a string within the JSONB
termscolumn - PDF versions are generated on-the-fly when sending emails (not stored in DB)
- Contracts are linked to properties via
property_id(nullable) - All contracts belong to an admin user via
user_id