# Calendario · Diccionario de datos

Relevamiento: 20/11/2026 · Modelo reconstruido desde código y migraciones.

La correspondencia con una base desplegada requiere contraste con su catálogo. Las relaciones entre servicios se distinguen de las claves foráneas locales.

## calendar_member

Miembro local identificado por el UUID canónico de Core.

Estructura verificada en código y migraciones. Esquema configurable del módulo.

PK: core_user_id. Unicidad total: sin declaración identificada.

| Campo | Tipo | NULL | Clave | Referencia física | Fuente técnica |
|---|---|---|---|---|---|
| core_user_id | uuid | NO | PK |  | Migración 1788739200000 · línea 77 |
| email | varchar(320) | NO |  |  | Migración 1788739200000 · línea 77 |
| display_name | varchar(200) | NO |  |  | Migración 1788739200000 · línea 77 |
| module_access_status | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| core_profile_version | bigint | SÍ |  |  | Migración 1788739200000 · línea 77 |
| core_access_version | bigint | SÍ |  |  | Migración 1788739200000 · línea 77 |
| last_synced_at | timestamptz | SÍ |  |  | Migración 1788739200000 · línea 77 |
| created_at | timestamptz | NO |  |  | Migración 1788739200000 · línea 77 |
| updated_at | timestamptz | NO |  |  | Migración 1788739200000 · línea 77 |

Claves foráneas:


Restricciones CHECK:

- `email varchar(320) NOT NULL CHECK (email <> '' AND email = lower(btrim(email)))` · Migración 1788739200000 · línea 77
- `display_name varchar(200) NOT NULL CHECK (btrim(display_name) <> '')` · Migración 1788739200000 · línea 77
- `module_access_status varchar(120) NOT NULL CHECK (module_access_status IN ('pending','active','suspended','revoked'))` · Migración 1788739200000 · línea 77
- `core_profile_version bigint CHECK (core_profile_version >= 0)` · Migración 1788739200000 · línea 77
- `core_access_version bigint CHECK (core_access_version >= 0)` · Migración 1788739200000 · línea 77

Índices declarados:

- `CREATE UNIQUE INDEX calendar_member_email_uq ON esquema.calendar_member (lower(email))` · Migración 1788739200000 · línea 77
- `CREATE INDEX calendar_member_status_idx ON esquema.calendar_member (module_access_status, core_user_id)` · Migración 1788739200000 · línea 77
- `CREATE INDEX calendar_member_name_idx ON esquema.calendar_member (lower(display_name), core_user_id)` · Migración 1788739200000 · línea 77

## permission

Permiso granular del dominio.

Estructura verificada en código y migraciones. Esquema configurable del módulo.

PK: id. Unicidad total: (code).

| Campo | Tipo | NULL | Clave | Referencia física | Fuente técnica |
|---|---|---|---|---|---|
| id | uuid | NO | PK |  | Migración 1788739200000 · línea 77 |
| code | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| name | varchar(160) | NO |  |  | Migración 1788739200000 · línea 77 |
| description | varchar(4000) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| category | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| is_system | boolean | NO |  |  | Migración 1788739200000 · línea 77 |
| is_active | boolean | NO |  |  | Migración 1788739200000 · línea 77 |
| created_at | timestamptz | NO |  |  | Migración 1788739200000 · línea 77 |
| updated_at | timestamptz | NO |  |  | Migración 1788739200000 · línea 77 |

Claves foráneas:


Restricciones CHECK:

- `code varchar(120) NOT NULL UNIQUE CHECK (btrim(code) <> '')` · Migración 1788739200000 · línea 77
- `name varchar(160) NOT NULL CHECK (btrim(name) <> '')` · Migración 1788739200000 · línea 77

Índices declarados:

Sin declaración adicional identificada.

## role

Rol de autorización del dominio.

Estructura verificada en código y migraciones. Esquema configurable del módulo.

PK: id. Unicidad total: (code).

| Campo | Tipo | NULL | Clave | Referencia física | Fuente técnica |
|---|---|---|---|---|---|
| id | uuid | NO | PK |  | Migración 1788739200000 · línea 77 |
| code | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| name | varchar(160) | NO |  |  | Migración 1788739200000 · línea 77 |
| description | varchar(4000) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| is_system | boolean | NO |  |  | Migración 1788739200000 · línea 77 |
| is_protected | boolean | NO |  |  | Migración 1788739200000 · línea 77 |
| is_active | boolean | NO |  |  | Migración 1788739200000 · línea 77 |
| version | integer | NO |  |  | Migración 1788739200000 · línea 77 |
| created_by_core_user_id | uuid | SÍ | FK | calendar_member(core_user_id) | Migración 1788739200000 · línea 77 |
| updated_by_core_user_id | uuid | SÍ | FK | calendar_member(core_user_id) | Migración 1788739200000 · línea 77 |
| created_at | timestamptz | NO |  |  | Migración 1788739200000 · línea 77 |
| updated_at | timestamptz | NO |  |  | Migración 1788739200000 · línea 77 |

Claves foráneas:

- (created_by_core_user_id) → calendar_member(core_user_id). Cada hija: 0..1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.
- (updated_by_core_user_id) → calendar_member(core_user_id). Cada hija: 0..1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.

Restricciones CHECK:

- `code varchar(120) NOT NULL UNIQUE CHECK (btrim(code) <> '')` · Migración 1788739200000 · línea 77
- `name varchar(160) NOT NULL CHECK (btrim(name) <> '')` · Migración 1788739200000 · línea 77
- `is_protected boolean NOT NULL DEFAULT false CHECK (NOT is_protected OR is_system)` · Migración 1788739200000 · línea 77
- `version integer NOT NULL DEFAULT 1 CHECK (version >= 1)` · Migración 1788739200000 · línea 77

Índices declarados:

Sin declaración adicional identificada.

## role_permission

Tabla puente entre roles y permisos.

Estructura verificada en código y migraciones. Esquema configurable del módulo.

PK: role_id, permission_id. Unicidad total: sin declaración identificada.

| Campo | Tipo | NULL | Clave | Referencia física | Fuente técnica |
|---|---|---|---|---|---|
| role_id | uuid | NO | PK, FK | role(id) | Migración 1788739200000 · línea 77 |
| permission_id | uuid | NO | PK, FK | permission(id) | Migración 1788739200000 · línea 77 |
| granted_by_core_user_id | uuid | SÍ | FK | calendar_member(core_user_id) | Migración 1788739200000 · línea 77 |
| granted_at | timestamptz | NO |  |  | Migración 1788739200000 · línea 77 |

Claves foráneas:

- (role_id) → role(id). Cada hija: 1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.
- (permission_id) → permission(id). Cada hija: 1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.
- (granted_by_core_user_id) → calendar_member(core_user_id). Cada hija: 0..1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.

Restricciones CHECK:

Sin declaración adicional identificada.

Índices declarados:

- `CREATE INDEX role_permission_reverse_idx ON esquema.role_permission(permission_id, role_id)` · Migración 1788739200000 · línea 77

## permission_dependency

Dependencias entre permisos.

Estructura verificada en código y migraciones. Esquema configurable del módulo.

PK: permission_id, required_permission_id. Unicidad total: sin declaración identificada.

| Campo | Tipo | NULL | Clave | Referencia física | Fuente técnica |
|---|---|---|---|---|---|
| permission_id | uuid | NO | PK, FK | permission(id) | Migración 1788739200000 · línea 77 |
| required_permission_id | uuid | NO | PK, FK | permission(id) | Migración 1788739200000 · línea 77 |
| created_at | timestamptz | NO |  |  | Migración 1788739200000 · línea 77 |

Claves foráneas:

- (permission_id) → permission(id). Cada hija: 1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.
- (required_permission_id) → permission(id). Cada hija: 1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.

Restricciones CHECK:

- `CHECK (permission_id <> required_permission_id)` · Migración 1788739200000 · línea 77

Índices declarados:

- `CREATE INDEX permission_dependency_reverse_idx ON esquema.permission_dependency(required_permission_id, permission_id)` · Migración 1788739200000 · línea 77

## user_role

Asignación de roles a usuarios.

Estructura verificada en código y migraciones. Esquema configurable del módulo.

PK: core_user_id, role_id. Unicidad total: sin declaración identificada.

| Campo | Tipo | NULL | Clave | Referencia física | Fuente técnica |
|---|---|---|---|---|---|
| core_user_id | uuid | NO | PK, FK | calendar_member(core_user_id) | Migración 1788739200000 · línea 77 |
| role_id | uuid | NO | PK, FK | role(id) | Migración 1788739200000 · línea 77 |
| is_active | boolean | NO |  |  | Migración 1788739200000 · línea 77 |
| assigned_by_core_user_id | uuid | SÍ | FK | calendar_member(core_user_id) | Migración 1788739200000 · línea 77 |
| assigned_at | timestamptz | NO |  |  | Migración 1788739200000 · línea 77 |
| revoked_by_core_user_id | uuid | SÍ | FK | calendar_member(core_user_id) | Migración 1788739200000 · línea 77 |
| revoked_at | timestamptz | SÍ |  |  | Migración 1788739200000 · línea 77 |
| revocation_reason | varchar(1000) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| version | integer | NO |  |  | Migración 1788739200000 · línea 77 |

Claves foráneas:

- (core_user_id) → calendar_member(core_user_id). Cada hija: 1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.
- (role_id) → role(id). Cada hija: 1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.
- (assigned_by_core_user_id) → calendar_member(core_user_id). Cada hija: 0..1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.
- (revoked_by_core_user_id) → calendar_member(core_user_id). Cada hija: 0..1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.

Restricciones CHECK:

- `CHECK ((is_active AND revoked_at IS NULL AND revoked_by_core_user_id IS NULL AND revocation_reason IS NULL) OR (NOT is_active AND revoked_at IS NOT NULL AND revocation_reason IS NOT NULL AND btrim(revocation_reason) <> ''))` · Migración 1788739200000 · línea 77
- `version integer NOT NULL DEFAULT 1 CHECK (version >= 1)` · Migración 1788739200000 · línea 77

Índices declarados:

- `CREATE INDEX user_role_reverse_idx ON esquema.user_role(role_id, core_user_id)` · Migración 1788739200000 · línea 77
- `CREATE INDEX user_role_active_idx ON esquema.user_role(core_user_id, role_id) WHERE is_active` · Migración 1788739200000 · línea 77

## core_inbox_event

Mensaje externo persistido antes de procesarse.

Estructura verificada en código y migraciones. Esquema configurable del módulo.

PK: source_event_id. Unicidad total: sin declaración identificada.

| Campo | Tipo | NULL | Clave | Referencia física | Fuente técnica |
|---|---|---|---|---|---|
| source_event_id | uuid | NO | PK |  | Migración 1788739200000 · línea 77 |
| event_type | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| schema_version | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| aggregate_type | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| aggregate_id | uuid | NO |  |  | Migración 1788739200000 · línea 77 |
| aggregate_version | integer | NO |  |  | Migración 1788739200000 · línea 77 |
| source_cursor | varchar(2000) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| payload_hash | varchar(64) | NO |  |  | Migración 1788739200000 · línea 77 |
| payload | jsonb | NO |  |  | Migración 1788739200000 · línea 77 |
| processing_status | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| processing_attempts | integer | NO |  |  | Migración 1788739200000 · línea 77 |
| received_at | timestamptz | NO |  |  | Migración 1788739200000 · línea 77 |
| processed_at | timestamptz | SÍ |  |  | Migración 1788739200000 · línea 77 |
| last_error | varchar(2000) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| next_attempt_at | timestamptz | SÍ |  |  | Migración 1789603200000 · línea 16 |
| lease_expires_at | timestamptz | SÍ |  |  | Migración 1789603200000 · línea 16 |

Claves foráneas:


Restricciones CHECK:

- `CHECK ((processing_status = 'processed') = (processed_at IS NOT NULL))` · Migración 1788739200000 · línea 77
- `aggregate_version integer NOT NULL CHECK (aggregate_version >= 1)` · Migración 1788739200000 · línea 77
- `payload_hash varchar(64) NOT NULL CHECK (payload_hash ~ '^[0-9a-f]{64}$')` · Migración 1788739200000 · línea 77
- `processing_status varchar(120) NOT NULL DEFAULT 'pending' CHECK (processing_status IN ('pending','processing','processed','failed'))` · Migración 1788739200000 · línea 77
- `processing_attempts integer NOT NULL DEFAULT 0 CHECK (processing_attempts >= 0)` · Migración 1788739200000 · línea 77

Índices declarados:

- `CREATE INDEX core_inbox_pending_idx ON esquema.core_inbox_event(received_at, source_event_id) WHERE processing_status = 'pending'` · Migración 1788739200000 · línea 77
- `CREATE INDEX core_inbox_claim_idx ON esquema.core_inbox_event(next_attempt_at, received_at, source_event_id) WHERE processing_status IN ('pending','failed')` · Migración 1789603200000 · línea 16
- `CREATE INDEX core_inbox_lease_recovery_idx ON esquema.core_inbox_event(lease_expires_at, received_at, source_event_id) WHERE processing_status = 'processing'` · Migración 1789603200000 · línea 16

## core_sync_checkpoint

Avance de sincronización externa.

Estructura verificada en código y migraciones. Esquema configurable del módulo.

PK: stream_code. Unicidad total: sin declaración identificada.

| Campo | Tipo | NULL | Clave | Referencia física | Fuente técnica |
|---|---|---|---|---|---|
| stream_code | varchar(120) | NO | PK |  | Migración 1788739200000 · línea 77 |
| last_cursor | varchar(2000) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| snapshot_version | varchar(2000) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| sync_status | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| last_attempt_at | timestamptz | SÍ |  |  | Migración 1788739200000 · línea 77 |
| last_success_at | timestamptz | SÍ |  |  | Migración 1788739200000 · línea 77 |
| last_error | varchar(2000) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| version | integer | NO |  |  | Migración 1788739200000 · línea 77 |

Claves foráneas:


Restricciones CHECK:

- `CHECK (sync_status <> 'healthy' OR last_success_at IS NOT NULL)` · Migración 1788739200000 · línea 77
- `stream_code varchar(120) PRIMARY KEY CHECK (btrim(stream_code) <> '')` · Migración 1788739200000 · línea 77
- `sync_status varchar(120) NOT NULL CHECK (sync_status IN ('uninitialized','syncing','healthy','degraded','failed'))` · Migración 1788739200000 · línea 77
- `version integer NOT NULL DEFAULT 1 CHECK (version >= 1)` · Migración 1788739200000 · línea 77

Índices declarados:

Sin declaración adicional identificada.

## core_space_projection

Proyección local de espacios canónicos.

Estructura verificada en código y migraciones. Esquema configurable del módulo.

PK: core_space_id. Unicidad total: (code).

| Campo | Tipo | NULL | Clave | Referencia física | Fuente técnica |
|---|---|---|---|---|---|
| core_space_id | uuid | NO | PK |  | Migración 1788739200000 · línea 77 |
| code | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| name | varchar(200) | NO |  |  | Migración 1788739200000 · línea 77 |
| parent_core_space_id | uuid | SÍ | FK | core_space_projection(core_space_id) | Migración 1788739200000 · línea 77 |
| sort_order | integer | NO |  |  | Migración 1788739200000 · línea 77 |
| type_code | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| source_status | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| effective_status | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| module_selection_state | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| module_setting_is_explicit | boolean | NO |  |  | Migración 1788739200000 · línea 77 |
| module_setting_version | integer | NO |  |  | Migración 1788739200000 · línea 77 |
| selectable | boolean | NO |  |  | Migración 1788739200000 · línea 77 |
| context_only | boolean | NO |  |  | Migración 1788739200000 · línea 77 |
| color_hex | varchar(7) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| effective_color_hex | varchar(7) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| path_text | varchar(4000) | NO |  |  | Migración 1788739200000 · línea 77 |
| path_ids | jsonb | NO |  |  | Migración 1788739200000 · línea 77 |
| core_version | integer | NO |  |  | Migración 1788739200000 · línea 77 |
| catalog_sequence | bigint | NO |  |  | Migración 1788739200000 · línea 77 |
| is_tombstone | boolean | NO |  |  | Migración 1788739200000 · línea 77 |
| last_source_event_id | uuid | SÍ | FK | core_inbox_event(source_event_id) | Migración 1788739200000 · línea 77 |
| synced_at | timestamptz | NO |  |  | Migración 1788739200000 · línea 77 |

Claves foráneas:

- (parent_core_space_id) → core_space_projection(core_space_id). Cada hija: 0..1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.
- (last_source_event_id) → core_inbox_event(source_event_id). Cada hija: 0..1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.

Restricciones CHECK:

- `CHECK ((module_setting_is_explicit AND module_setting_version >= 1) OR (NOT module_setting_is_explicit AND module_setting_version = 0))` · Migración 1788739200000 · línea 77
- `CHECK (NOT ((context_only OR is_tombstone) AND selectable))` · Migración 1788739200000 · línea 77
- `code varchar(120) NOT NULL UNIQUE CHECK (btrim(code) <> '')` · Migración 1788739200000 · línea 77
- `name varchar(200) NOT NULL CHECK (btrim(name) <> '')` · Migración 1788739200000 · línea 77
- `sort_order integer NOT NULL CHECK (sort_order >= 0)` · Migración 1788739200000 · línea 77
- `source_status varchar(120) NOT NULL CHECK (source_status IN ('draft','active','inactive','retired'))` · Migración 1788739200000 · línea 77
- `effective_status varchar(120) NOT NULL CHECK (effective_status IN ('draft','active','inactive','retired'))` · Migración 1788739200000 · línea 77
- `module_selection_state varchar(120) NOT NULL CHECK (module_selection_state IN ('enabled','disabled'))` · Migración 1788739200000 · línea 77
- `module_setting_version integer NOT NULL CHECK (module_setting_version >= 0)` · Migración 1788739200000 · línea 77
- `color_hex varchar(7) CHECK (color_hex ~ '^#[0-9A-Fa-f]{6}$')` · Migración 1788739200000 · línea 77
- `effective_color_hex varchar(7) CHECK (effective_color_hex ~ '^#[0-9A-Fa-f]{6}$')` · Migración 1788739200000 · línea 77
- `path_ids jsonb NOT NULL CHECK (jsonb_typeof(path_ids) = 'array')` · Migración 1788739200000 · línea 77
- `core_version integer NOT NULL CHECK (core_version >= 1)` · Migración 1788739200000 · línea 77
- `catalog_sequence bigint NOT NULL CHECK (catalog_sequence >= 0)` · Migración 1788739200000 · línea 77

Índices declarados:

- `CREATE INDEX core_space_parent_idx ON esquema.core_space_projection(parent_core_space_id, sort_order, core_space_id)` · Migración 1788739200000 · línea 77
- `CREATE INDEX core_space_selectable_idx ON esquema.core_space_projection(selectable, core_space_id)` · Migración 1788739200000 · línea 77
- `CREATE INDEX core_space_status_idx ON esquema.core_space_projection(effective_status, core_space_id)` · Migración 1788739200000 · línea 77
- `CREATE INDEX core_space_sequence_idx ON esquema.core_space_projection(catalog_sequence, core_space_id)` · Migración 1788739200000 · línea 77
- `CREATE INDEX core_space_path_idx ON esquema.core_space_projection(md5(path_text))` · Migración 1788739200000 · línea 77

## core_space_relation_projection

Proyección de relaciones espaciales.

Estructura verificada en código y migraciones. Esquema configurable del módulo.

PK: ancestor_core_space_id, descendant_core_space_id. Unicidad total: sin declaración identificada.

| Campo | Tipo | NULL | Clave | Referencia física | Fuente técnica |
|---|---|---|---|---|---|
| ancestor_core_space_id | uuid | NO | PK, FK | core_space_projection(core_space_id) | Migración 1788739200000 · línea 77 |
| descendant_core_space_id | uuid | NO | PK, FK | core_space_projection(core_space_id) | Migración 1788739200000 · línea 77 |
| depth | integer | NO |  |  | Migración 1788739200000 · línea 77 |
| catalog_sequence | bigint | NO |  |  | Migración 1788739200000 · línea 77 |
| last_source_event_id | uuid | SÍ | FK | core_inbox_event(source_event_id) | Migración 1788739200000 · línea 77 |
| synced_at | timestamptz | NO |  |  | Migración 1788739200000 · línea 77 |

Claves foráneas:

- (ancestor_core_space_id) → core_space_projection(core_space_id). Cada hija: 1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.
- (descendant_core_space_id) → core_space_projection(core_space_id). Cada hija: 1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.
- (last_source_event_id) → core_inbox_event(source_event_id). Cada hija: 0..1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.

Restricciones CHECK:

- `CHECK ((ancestor_core_space_id = descendant_core_space_id) = (depth = 0))` · Migración 1788739200000 · línea 77
- `depth integer NOT NULL CHECK (depth >= 0)` · Migración 1788739200000 · línea 77
- `catalog_sequence bigint NOT NULL CHECK (catalog_sequence >= 0)` · Migración 1788739200000 · línea 77

Índices declarados:

- `CREATE INDEX core_space_relation_reverse_idx ON esquema.core_space_relation_projection(descendant_core_space_id, ancestor_core_space_id)` · Migración 1788739200000 · línea 77

## core_space_lineage_projection

Proyección de jerarquía espacial.

Estructura verificada en código y migraciones. Esquema configurable del módulo.

PK: core_lineage_id. Unicidad total: (source_core_space_id, target_core_space_id, relation_type).

| Campo | Tipo | NULL | Clave | Referencia física | Fuente técnica |
|---|---|---|---|---|---|
| core_lineage_id | uuid | NO | PK |  | Migración 1788739200000 · línea 77 |
| source_core_space_id | uuid | NO | FK | core_space_projection(core_space_id) | Migración 1788739200000 · línea 77 |
| target_core_space_id | uuid | NO | FK | core_space_projection(core_space_id) | Migración 1788739200000 · línea 77 |
| relation_type | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| effective_at | timestamptz | NO |  |  | Migración 1788739200000 · línea 77 |
| catalog_sequence | bigint | NO |  |  | Migración 1788739200000 · línea 77 |
| last_source_event_id | uuid | SÍ | FK | core_inbox_event(source_event_id) | Migración 1788739200000 · línea 77 |
| synced_at | timestamptz | NO |  |  | Migración 1788739200000 · línea 77 |

Claves foráneas:

- (source_core_space_id) → core_space_projection(core_space_id). Cada hija: 1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.
- (target_core_space_id) → core_space_projection(core_space_id). Cada hija: 1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.
- (last_source_event_id) → core_inbox_event(source_event_id). Cada hija: 0..1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.

Restricciones CHECK:

- `CHECK (source_core_space_id <> target_core_space_id)` · Migración 1788739200000 · línea 77
- `relation_type varchar(120) NOT NULL CHECK (relation_type IN ('split_into','merged_into','replaced_by'))` · Migración 1788739200000 · línea 77
- `catalog_sequence bigint NOT NULL CHECK (catalog_sequence >= 0)` · Migración 1788739200000 · línea 77

Índices declarados:

- `CREATE INDEX core_space_lineage_target_idx ON esquema.core_space_lineage_projection(target_core_space_id, source_core_space_id)` · Migración 1788739200000 · línea 77

## calendar_event

Evento administrado por Calendario con estado y versión.

Estructura verificada en código y migraciones. Esquema configurable del módulo.

PK: id. Unicidad total: (code).

| Campo | Tipo | NULL | Clave | Referencia física | Fuente técnica |
|---|---|---|---|---|---|
| id | uuid | NO | PK |  | Migración 1788739200000 · línea 77 |
| code | varchar(64) | NO |  |  | Migración 1788739200000 · línea 77 |
| name | varchar(200) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| description | varchar(4000) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| event_type | varchar(120) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| status | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| occupancy_start_at | timestamptz | SÍ |  |  | Migración 1788739200000 · línea 77 |
| public_start_at | timestamptz | SÍ |  |  | Migración 1788739200000 · línea 77 |
| public_end_at | timestamptz | SÍ |  |  | Migración 1788739200000 · línea 77 |
| occupancy_end_at | timestamptz | SÍ |  |  | Migración 1788739200000 · línea 77 |
| business_timezone | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| confirmed_at | timestamptz | SÍ |  |  | Migración 1788739200000 · línea 77 |
| confirmed_by_core_user_id | uuid | SÍ | FK | calendar_member(core_user_id) | Migración 1788739200000 · línea 77 |
| created_by_core_user_id | uuid | NO | FK | calendar_member(core_user_id) | Migración 1788739200000 · línea 77 |
| created_by_email_snapshot | varchar(320) | NO |  |  | Migración 1788739200000 · línea 77 |
| created_by_name_snapshot | varchar(200) | NO |  |  | Migración 1788739200000 · línea 77 |
| updated_by_core_user_id | uuid | SÍ | FK | calendar_member(core_user_id) | Migración 1788739200000 · línea 77 |
| updated_by_email_snapshot | varchar(320) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| updated_by_name_snapshot | varchar(200) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| archived_by_core_user_id | uuid | SÍ | FK | calendar_member(core_user_id) | Migración 1788739200000 · línea 77 |
| archived_at | timestamptz | SÍ |  |  | Migración 1788739200000 · línea 77 |
| cancelled_by_core_user_id | uuid | SÍ | FK | calendar_member(core_user_id) | Migración 1788739200000 · línea 77 |
| cancelled_at | timestamptz | SÍ |  |  | Migración 1788739200000 · línea 77 |
| cancellation_reason | varchar(1000) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| version | integer | NO |  |  | Migración 1788739200000 · línea 77 |
| created_at | timestamptz | NO |  |  | Migración 1788739200000 · línea 77 |
| updated_at | timestamptz | NO |  |  | Migración 1788739200000 · línea 77 |

Claves foráneas:

- (confirmed_by_core_user_id) → calendar_member(core_user_id). Cada hija: 0..1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.
- (created_by_core_user_id) → calendar_member(core_user_id). Cada hija: 1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.
- (updated_by_core_user_id) → calendar_member(core_user_id). Cada hija: 0..1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.
- (archived_by_core_user_id) → calendar_member(core_user_id). Cada hija: 0..1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.
- (cancelled_by_core_user_id) → calendar_member(core_user_id). Cada hija: 0..1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.

Restricciones CHECK:

- `CHECK (status = 'draft' OR (name IS NOT NULL AND btrim(name) <> '' AND description IS NOT NULL AND btrim(description) <> '' AND event_type IS NOT NULL AND occupancy_start_at IS NOT NULL AND public_start_at IS NOT NULL AND public_end_at IS NOT NULL AND occupancy_end_at IS NOT NULL))` · Migración 1788739200000 · línea 77
- `CHECK (occupancy_start_at < public_start_at)` · Migración 1788739200000 · línea 77
- `CHECK (occupancy_start_at < public_end_at)` · Migración 1788739200000 · línea 77
- `CHECK (occupancy_start_at < occupancy_end_at)` · Migración 1788739200000 · línea 77
- `CHECK (public_start_at < public_end_at)` · Migración 1788739200000 · línea 77
- `CHECK (public_start_at < occupancy_end_at)` · Migración 1788739200000 · línea 77
- `CHECK (public_end_at < occupancy_end_at)` · Migración 1788739200000 · línea 77
- `CHECK ((archived_at IS NULL AND archived_by_core_user_id IS NULL) OR (status = 'draft' AND archived_at IS NOT NULL AND archived_by_core_user_id IS NOT NULL))` · Migración 1788739200000 · línea 77
- `CHECK ((confirmed_at IS NULL) = (confirmed_by_core_user_id IS NULL))` · Migración 1788739200000 · línea 77
- `CHECK (status <> 'confirmed' OR confirmed_at IS NOT NULL)` · Migración 1788739200000 · línea 77
- `CHECK (status <> 'draft' OR confirmed_at IS NULL)` · Migración 1788739200000 · línea 77
- `CHECK ((status = 'cancelled' AND cancelled_at IS NOT NULL AND cancelled_by_core_user_id IS NOT NULL AND cancellation_reason IS NOT NULL AND btrim(cancellation_reason) <> '') OR (status <> 'cancelled' AND cancelled_at IS NULL AND cancelled_by_core_user_id IS NULL AND cancellation_reason IS NULL))` · Migración 1788739200000 · línea 77
- `CONSTRAINT calendar_event_business_timezone_ck CHECK (business_timezone = 'America/Argentina/Buenos_Aires')` · Migración 1788825600000 · línea 57
- `code varchar(64) NOT NULL UNIQUE CHECK (btrim(code) <> '')` · Migración 1788739200000 · línea 77
- `event_type varchar(120) CHECK (event_type IN ('own','third_party'))` · Migración 1788739200000 · línea 77
- `status varchar(120) NOT NULL DEFAULT 'draft' CHECK (status IN ('draft','confirmed','cancelled'))` · Migración 1788739200000 · línea 77
- `version integer NOT NULL DEFAULT 1 CHECK (version >= 1)` · Migración 1788739200000 · línea 77

Índices declarados:

- `CREATE INDEX calendar_event_status_idx ON esquema.calendar_event(status, id)` · Migración 1788739200000 · línea 77
- `CREATE INDEX calendar_event_type_idx ON esquema.calendar_event(event_type, id)` · Migración 1788739200000 · línea 77
- `CREATE INDEX calendar_event_public_start_idx ON esquema.calendar_event(public_start_at, id)` · Migración 1788739200000 · línea 77
- `CREATE INDEX calendar_event_occupancy_start_idx ON esquema.calendar_event(occupancy_start_at, id)` · Migración 1788739200000 · línea 77
- `CREATE INDEX calendar_event_occupancy_end_idx ON esquema.calendar_event(occupancy_end_at, id)` · Migración 1788739200000 · línea 77
- `CREATE INDEX calendar_event_name_idx ON esquema.calendar_event(lower(name), id)` · Migración 1788739200000 · línea 77
- `CREATE INDEX calendar_event_draft_idx ON esquema.calendar_event(updated_at, id) WHERE status = 'draft' AND archived_at IS NULL` · Migración 1788739200000 · línea 77
- `CREATE INDEX calendar_event_occupancy_gist_idx ON esquema.calendar_event USING gist(tstzrange(occupancy_start_at, occupancy_end_at, '[)')) WHERE status = 'confirmed'` · Migración 1788739200000 · línea 77

## event_space

Asociación de un evento con un espacio proyectado de Core.

Estructura verificada en código y migraciones. Esquema configurable del módulo.

PK: event_id, core_space_id. Unicidad total: sin declaración identificada.

| Campo | Tipo | NULL | Clave | Referencia física | Fuente técnica |
|---|---|---|---|---|---|
| event_id | uuid | NO | PK, FK | calendar_event(id) | Migración 1788739200000 · línea 77 |
| core_space_id | uuid | NO | PK, FK | core_space_projection(core_space_id) | Migración 1788739200000 · línea 77 |
| space_code_snapshot | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| space_name_snapshot | varchar(200) | NO |  |  | Migración 1788739200000 · línea 77 |
| space_path_snapshot | varchar(4000) | NO |  |  | Migración 1788739200000 · línea 77 |
| core_space_version_snapshot | integer | NO |  |  | Migración 1788739200000 · línea 77 |
| sort_order | integer | NO |  |  | Migración 1788739200000 · línea 77 |
| associated_by_core_user_id | uuid | NO | FK | calendar_member(core_user_id) | Migración 1788739200000 · línea 77 |
| associated_at | timestamptz | NO |  |  | Migración 1788739200000 · línea 77 |

Claves foráneas:

- (event_id) → calendar_event(id). Cada hija: 1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.
- (core_space_id) → core_space_projection(core_space_id). Cada hija: 1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.
- (associated_by_core_user_id) → calendar_member(core_user_id). Cada hija: 1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.

Restricciones CHECK:

- `core_space_version_snapshot integer NOT NULL CHECK (core_space_version_snapshot >= 1)` · Migración 1788739200000 · línea 77
- `sort_order integer NOT NULL CHECK (sort_order >= 0)` · Migración 1788739200000 · línea 77

Índices declarados:

- `CREATE INDEX event_space_reverse_idx ON esquema.event_space(core_space_id, event_id)` · Migración 1788739200000 · línea 77

## calendar_audit_log

Cabecera particionada de auditoría de Calendario.

Estructura verificada en código y migraciones. Esquema configurable del módulo.

PK: occurred_at, id. Unicidad total: sin declaración identificada.

| Campo | Tipo | NULL | Clave | Referencia física | Fuente técnica |
|---|---|---|---|---|---|
| id | uuid | NO | PK |  | Migración 1788739200000 · línea 77 |
| occurred_at | timestamptz | NO | PK |  | Migración 1788739200000 · línea 77 |
| calendar_event_id | uuid | SÍ | FK | calendar_event(id) | Migración 1788739200000 · línea 77 |
| domain | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| action | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| target_type | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| target_id | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| actor_type | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| actor_core_user_id | uuid | SÍ | FK | calendar_member(core_user_id) | Migración 1788739200000 · línea 77 |
| actor_service_id | varchar(120) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| actor_email_snapshot | varchar(320) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| actor_name_snapshot | varchar(200) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| actor_roles_snapshot | jsonb | NO |  |  | Migración 1788739200000 · línea 77 |
| outcome | varchar(120) | NO |  |  | Migración 1788739200000 · línea 77 |
| reason | varchar(1000) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| source_session_id | uuid | SÍ |  |  | Migración 1788739200000 · línea 77 |
| request_id | varchar(120) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| correlation_id | varchar(120) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| source_ip | inet | SÍ |  |  | Migración 1788739200000 · línea 77 |
| user_agent | varchar(2000) | SÍ |  |  | Migración 1788739200000 · línea 77 |
| required_protection_level | integer | NO |  |  | Migración 1788912000000 · línea 55 |

Claves foráneas:

- (calendar_event_id) → calendar_event(id). Cada hija: 0..1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.
- (actor_core_user_id) → calendar_member(core_user_id). Cada hija: 0..1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 77.

Restricciones CHECK:

- `CHECK ((actor_type = 'user' AND actor_core_user_id IS NOT NULL AND actor_service_id IS NULL) OR (actor_type = 'service' AND actor_core_user_id IS NULL AND actor_service_id IS NOT NULL AND btrim(actor_service_id) <> '') OR (actor_type = 'system' AND actor_core_user_id IS NULL AND actor_service_id IS NULL))` · Migración 1788739200000 · línea 77
- `CONSTRAINT calendar_audit_required_protection_level_ck CHECK (required_protection_level IN (0,50,100))` · Migración 1788912000000 · línea 93
- `actor_type varchar(120) NOT NULL CHECK (actor_type IN ('user','service','system'))` · Migración 1788739200000 · línea 77
- `actor_roles_snapshot jsonb NOT NULL DEFAULT '[]'::jsonb CHECK (jsonb_typeof(actor_roles_snapshot) = 'array')` · Migración 1788739200000 · línea 77
- `outcome varchar(120) NOT NULL CHECK (outcome IN ('succeeded','denied','failed'))` · Migración 1788739200000 · línea 77

Índices declarados:

- `CREATE INDEX calendar_audit_event_idx ON esquema.calendar_audit_log(calendar_event_id, occurred_at, id)` · Migración 1788739200000 · línea 281
- `CREATE INDEX calendar_audit_actor_idx ON esquema.calendar_audit_log(actor_core_user_id, occurred_at, id)` · Migración 1788739200000 · línea 281
- `CREATE INDEX calendar_audit_domain_idx ON esquema.calendar_audit_log(domain, occurred_at, id)` · Migración 1788739200000 · línea 281
- `CREATE INDEX calendar_audit_action_idx ON esquema.calendar_audit_log(action, occurred_at, id)` · Migración 1788739200000 · línea 281
- `CREATE INDEX calendar_audit_correlation_idx ON esquema.calendar_audit_log(correlation_id, occurred_at, id)` · Migración 1788739200000 · línea 281
- `CREATE INDEX calendar_audit_protection_idx ON esquema.calendar_audit_log(required_protection_level,occurred_at DESC,id DESC)` · Migración 1788912000000 · línea 93
- `CREATE INDEX calendar_audit_event_protection_idx ON esquema.calendar_audit_log(calendar_event_id,required_protection_level,occurred_at DESC,id DESC) WHERE calendar_event_id IS NOT NULL` · Migración 1788912000000 · línea 93

## calendar_audit_change

Cambio de campo asociado a una cabecera de auditoría.

Estructura verificada en código y migraciones. Esquema configurable del módulo.

PK: id. Unicidad total: sin declaración identificada.

| Campo | Tipo | NULL | Clave | Referencia física | Fuente técnica |
|---|---|---|---|---|---|
| id | uuid | NO | PK |  | Migración 1788739200000 · línea 281 |
| audit_log_id | uuid | NO | FK | calendar_audit_log(occurred_at, id) | Migración 1788739200000 · línea 281 |
| audit_occurred_at | timestamptz | NO | FK | calendar_audit_log(occurred_at, id) | Migración 1788739200000 · línea 281 |
| field_code | varchar(120) | NO |  |  | Migración 1788739200000 · línea 281 |
| field_label_snapshot | varchar(160) | NO |  |  | Migración 1788739200000 · línea 281 |
| old_value | jsonb | SÍ |  |  | Migración 1788739200000 · línea 281 |
| new_value | jsonb | SÍ |  |  | Migración 1788739200000 · línea 281 |
| sort_order | integer | NO |  |  | Migración 1788739200000 · línea 281 |

Claves foráneas:

- (audit_occurred_at, audit_log_id) → calendar_audit_log(occurred_at, id). Cada hija: 1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 281.

Restricciones CHECK:

- `sort_order integer NOT NULL CHECK (sort_order >= 0)` · Migración 1788739200000 · línea 281

Índices declarados:

- `CREATE INDEX calendar_audit_change_header_idx ON esquema.calendar_audit_change(audit_occurred_at, audit_log_id, sort_order)` · Migración 1788739200000 · línea 281

## calendar_outbox_event

Mensaje transaccional de un evento de Calendario pendiente de publicación.

Estructura verificada en código y migraciones. Esquema configurable del módulo.

PK: event_id. Unicidad total: (sequence); (calendar_event_id, aggregate_version).

| Campo | Tipo | NULL | Clave | Referencia física | Fuente técnica |
|---|---|---|---|---|---|
| event_id | uuid | NO | PK |  | Migración 1788739200000 · línea 281 |
| sequence | bigint | NO |  |  | Migración 1788739200000 · línea 281 |
| calendar_event_id | uuid | NO | FK | calendar_event(id) | Migración 1788739200000 · línea 281 |
| event_type | varchar(120) | NO |  |  | Migración 1788739200000 · línea 281 |
| schema_version | varchar(120) | NO |  |  | Migración 1788739200000 · línea 281 |
| aggregate_version | integer | NO |  |  | Migración 1788739200000 · línea 281 |
| correlation_id | varchar(120) | SÍ |  |  | Migración 1788739200000 · línea 281 |
| causation_id | varchar(120) | SÍ |  |  | Migración 1788739200000 · línea 281 |
| payload | jsonb | NO |  |  | Migración 1788739200000 · línea 281 |
| publication_status | varchar(120) | NO |  |  | Migración 1788739200000 · línea 281 |
| publication_attempts | integer | NO |  |  | Migración 1788739200000 · línea 281 |
| available_at | timestamptz | NO |  |  | Migración 1788739200000 · línea 281 |
| next_attempt_at | timestamptz | SÍ |  |  | Migración 1788739200000 · línea 281 |
| published_at | timestamptz | SÍ |  |  | Migración 1788739200000 · línea 281 |
| last_error | varchar(2000) | SÍ |  |  | Migración 1788739200000 · línea 281 |
| created_at | timestamptz | NO |  |  | Migración 1788739200000 · línea 281 |
| lease_expires_at | timestamptz | SÍ |  |  | Migración 1789603200000 · línea 16 |

Claves foráneas:

- (calendar_event_id) → calendar_event(id). Cada hija: 1 padre; cada padre: 0..N hijas. Migración 1788739200000 · línea 281.

Restricciones CHECK:

- `CHECK ((publication_status = 'published') = (published_at IS NOT NULL))` · Migración 1788739200000 · línea 281
- `aggregate_version integer NOT NULL CHECK (aggregate_version >= 1)` · Migración 1788739200000 · línea 281
- `publication_status varchar(120) NOT NULL DEFAULT 'pending' CHECK (publication_status IN ('pending','publishing','published','failed'))` · Migración 1788739200000 · línea 281
- `publication_attempts integer NOT NULL DEFAULT 0 CHECK (publication_attempts >= 0)` · Migración 1788739200000 · línea 281

Índices declarados:

- `CREATE INDEX calendar_outbox_eligible_idx ON esquema.calendar_outbox_event(publication_status, available_at, next_attempt_at, sequence)` · Migración 1788739200000 · línea 281
- `CREATE INDEX calendar_outbox_aggregate_idx ON esquema.calendar_outbox_event(calendar_event_id, aggregate_version, sequence)` · Migración 1788739200000 · línea 281
- `CREATE INDEX calendar_outbox_lease_recovery_idx ON esquema.calendar_outbox_event(lease_expires_at, sequence) WHERE publication_status = 'publishing'` · Migración 1789603200000 · línea 16

## idempotency_record

Control de repetición de solicitudes.

Estructura verificada en código y migraciones. Esquema configurable del módulo.

PK: id. Unicidad total: (principal_type, principal_id, operation, idempotency_key).

| Campo | Tipo | NULL | Clave | Referencia física | Fuente técnica |
|---|---|---|---|---|---|
| id | uuid | NO | PK |  | Migración 1788739200000 · línea 281 |
| principal_type | varchar(120) | NO |  |  | Migración 1788739200000 · línea 281 |
| principal_id | varchar(120) | NO |  |  | Migración 1788739200000 · línea 281 |
| operation | varchar(120) | NO |  |  | Migración 1788739200000 · línea 281 |
| idempotency_key | varchar(120) | NO |  |  | Migración 1788739200000 · línea 281 |
| request_hash | varchar(64) | NO |  |  | Migración 1788739200000 · línea 281 |
| processing_status | varchar(120) | NO |  |  | Migración 1788739200000 · línea 281 |
| response_status | integer | SÍ |  |  | Migración 1788739200000 · línea 281 |
| response_body | jsonb | SÍ |  |  | Migración 1788739200000 · línea 281 |
| resource_type | varchar(120) | SÍ |  |  | Migración 1788739200000 · línea 281 |
| resource_id | uuid | SÍ |  |  | Migración 1788739200000 · línea 281 |
| created_at | timestamptz | NO |  |  | Migración 1788739200000 · línea 281 |
| completed_at | timestamptz | SÍ |  |  | Migración 1788739200000 · línea 281 |
| expires_at | timestamptz | NO |  |  | Migración 1788739200000 · línea 281 |

Claves foráneas:


Restricciones CHECK:

- `CHECK (expires_at > created_at)` · Migración 1788739200000 · línea 281
- `CHECK ((processing_status = 'in_progress' AND completed_at IS NULL AND response_status IS NULL AND response_body IS NULL) OR (processing_status IN ('completed','failed') AND completed_at IS NOT NULL AND response_status IS NOT NULL))` · Migración 1788739200000 · línea 281
- `principal_type varchar(120) NOT NULL CHECK (principal_type IN ('user','service'))` · Migración 1788739200000 · línea 281
- `principal_id varchar(120) NOT NULL CHECK (btrim(principal_id) <> '')` · Migración 1788739200000 · línea 281
- `operation varchar(120) NOT NULL CHECK (btrim(operation) <> '')` · Migración 1788739200000 · línea 281
- `idempotency_key varchar(120) NOT NULL CHECK (btrim(idempotency_key) <> '')` · Migración 1788739200000 · línea 281
- `request_hash varchar(64) NOT NULL CHECK (request_hash ~ '^[0-9a-f]{64}$')` · Migración 1788739200000 · línea 281
- `processing_status varchar(120) NOT NULL DEFAULT 'in_progress' CHECK (processing_status IN ('in_progress','completed','failed'))` · Migración 1788739200000 · línea 281
- `response_status integer CHECK (response_status BETWEEN 100 AND 599)` · Migración 1788739200000 · línea 281

Índices declarados:

- `CREATE INDEX idempotency_expiry_idx ON esquema.idempotency_record(expires_at)` · Migración 1788739200000 · línea 281

