Code2Des Table
Overview
Backend-owned lifecycle, Page Import source, Figma destination, result pointer, and first successful materialization record for one Code2Des generation.
Table Definition
| Logical Name | Physical Name | Column Name | Data Type | Primary Key | Relation | Unique | Nullable | Default Value | Remarks |
|---|---|---|---|---|---|---|---|---|---|
| Code2Des | code2des | id | string | โฏ | Backend UUIDv7 (varchar(255)); API code2desId and worker code2des_id |
||||
| organization_id | number | organization:id | Organization scope; cascade on update/delete | ||||||
| project_id | number | project:id | Project scope; cascade on update/delete | ||||||
| page_import_id | string | page_import:id | Source Page Import (varchar(255)); the index is non-unique so one capture can back multiple jobs |
||||||
| figma_file_key | string | Plugin discovery destination (varchar(255)) |
|||||||
| screen_id | string | User-visible generated screen identity (varchar(255)) |
|||||||
| placement_target | string | โฏ | Optional initial Figma placement context (varchar(255)) |
||||||
| status | enum | '0' |
code2des_status; see Type Codes |
||||||
| attempt | number | 1 |
Worker-attempt fence (integer); fixed at 1 until a retry path is introduced |
||||||
| nonce | string | Per-job callback/manifest correlation fence (varchar(255)); not exposed by the user API |
|||||||
| result_url | string | โฏ | Native-Figma result or failure artifact pointer (varchar(1000)) |
||||||
| warning_count | number | โฏ | Deterministic conversion warning count (integer) |
||||||
| error_message | string | โฏ | Safe terminal failure detail (text) |
||||||
| materialized_at | datetime | โฏ | First successful Figma root creation time | ||||||
| materialized_node_id | string | โฏ | First successfully created Figma root ID (varchar(255)) |
||||||
| created_at | datetime | CURRENT_TIMESTAMP |
Shared audit field | ||||||
| updated_at | datetime | CURRENT_TIMESTAMP |
Shared audit field | ||||||
| deleted_at | datetime | โฏ | Shared soft-delete field | ||||||
| created_by | string | Cognito subject or backend actor (varchar(50)) |
|||||||
| updated_by | string | Cognito subject or backend actor (varchar(50)) |
|||||||
| deleted_by | string | โฏ | Cognito subject or backend actor (varchar(50)) |
Relations
organization_idโorganization.idwith update/delete cascadeproject_idโproject.idwith update/delete cascadepage_import_idโpage_import.idwith update/delete cascade; the foreign-key index is non-unique
Indexes
- PRIMARY KEY (
id) - INDEX
code2des_page_import_idx(page_import_id) - INDEX
code2des_project_status_idx(project_id,status) - INDEX
code2des_org_project_file_status_idx(organization_id,project_id,figma_file_key,status)
Type Codes
Database enum: code2des_status.
| Value | Meaning |
|---|---|
'0' |
processing |
'1' |
completed and eligible for result retrieval/materialization |
'2' |
failed |
Notes
- Each trigger creates a new Code2Des row from an existing completed Page Import. Repeated generation therefore retains previous jobs and Figma nodes.
- The webhook must match the persisted job
id,attempt, andnonce; the database update also requires the row to remain processing and non-deleted. materialized_atandmaterialized_node_idare written only on the first successful placement for a job. Repeated placement calls are idempotent and do not replace that root.- The lifecycle GET returns this row as control-plane metadata. The separate result GET validates the S3 artifact and hydrates image bytes without exposing S3 credentials.