Files
talktime/backend/drizzle/meta/0002_snapshot.json
T
patrickandClaude Sonnet 5 edc05d4d1e fix(PROJ-11): clear the remaining QA backlog (BUG-5/6/9/10/13/14/15/16/17/21/22)
Every previously-reported bug from the three QA rounds is now addressed
(BUG-11 and BUG-15 mitigated rather than fully solved — see spec for
why). Verified end-to-end on talkhub/matrix after each change.

Security:
- BUG-21: @fastify/helmet registered, CORS origin allowlist (APP_BASE_URL
  + localhost:5173) replaces `origin: true`. Verified: own origin gets
  CORS + HSTS/nosniff/X-Frame-Options headers, foreign origins get none.
- BUG-13: GET /api/teams only returns matrixRoomId for teams the
  requester actually belongs to (was leaking every team's room id to
  any org member). Verified with/without team membership.
- BUG-14: leftJoin now filters scope='team'; new partial unique index
  chat_rooms_team_id_team_scope_unique enforces one room per team at
  the DB level, not just in the query (migration 0002).

Reliability:
- BUG-5: use-team-chat.ts's setup poll now backs off exponentially
  (5s->60s) instead of a fixed 15s; SyncState.Error stops the client
  and reconnects with backoff instead of letting matrix-js-sdk retry
  against Synapse forever.
- BUG-6: one-off backfill script (src/scripts/backfill-history-visibility.ts)
  sets history_visibility=shared on rooms created before that fix;
  run against talkhub/matrix.
- BUG-9: route rate limit on GET /api/chat/room, unified 404 for
  nonexistent-team vs not-a-member (was a cross-org existence oracle),
  LRU-correct eviction order in matrix-token-cache.ts, scroll position
  preserved on "load older messages", and eslint.config.js added (lint
  never ran on this feature before — flat config was simply missing).
- BUG-15 (mitigated): a small module-level credential cache in
  lib/matrix.ts lets useTeamChat and useTeamUnreadCounts share one
  fetched token instead of each hitting POST /api/chat/token
  independently. Reduces but doesn't eliminate rate-limit risk under
  rapid team switching (no in-flight dedup between the two hooks).
- BUG-16: refreshCounts() checks `cancelled` before setCounts.
- BUG-17: use-team-chat.ts uses getRoomUnreadNotificationCount()
  instead of the deprecated getUnreadNotificationCount(); left
  unchanged in use-team-unread-counts.ts on purpose, since importing
  NotificationCountType there would undo BUG-11's bundle-splitting fix.

Cleanup:
- BUG-10: new POST /api/chat/logout invalidates the cached token and
  calls Synapse's logout_all admin endpoint; frontend calls it
  best-effort on logout and clears its own credential cache.
- BUG-22: trim() on displayName construction (trailing space with an
  empty last name); the reported trailing-dot localpart is moot after
  BUG-20 since localparts are random now, not name-derived.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0143yYvjesjHndBACoweyK67
2026-09-11 23:10:37 +02:00

1494 lines
38 KiB
JSON

{
"id": "735c3afb-31cc-42ea-ab27-8a26f33cc915",
"prevId": "7623ad60-f099-46c4-8027-42012f2d062f",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.audit_logs": {
"name": "audit_logs",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"organization_id": {
"name": "organization_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"actor_user_id": {
"name": "actor_user_id",
"type": "uuid",
"primaryKey": false,
"notNull": false
},
"action": {
"name": "action",
"type": "text",
"primaryKey": false,
"notNull": true
},
"target_type": {
"name": "target_type",
"type": "text",
"primaryKey": false,
"notNull": true
},
"target_id": {
"name": "target_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"metadata": {
"name": "metadata",
"type": "text",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"audit_logs_organization_id_idx": {
"name": "audit_logs_organization_id_idx",
"columns": [
{
"expression": "organization_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"audit_logs_created_at_idx": {
"name": "audit_logs_created_at_idx",
"columns": [
{
"expression": "created_at",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"audit_logs_organization_id_organizations_id_fk": {
"name": "audit_logs_organization_id_organizations_id_fk",
"tableFrom": "audit_logs",
"tableTo": "organizations",
"columnsFrom": [
"organization_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"audit_logs_actor_user_id_users_id_fk": {
"name": "audit_logs_actor_user_id_users_id_fk",
"tableFrom": "audit_logs",
"tableTo": "users",
"columnsFrom": [
"actor_user_id"
],
"columnsTo": [
"id"
],
"onDelete": "set null",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.chat_rooms": {
"name": "chat_rooms",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"organization_id": {
"name": "organization_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"matrix_room_id": {
"name": "matrix_room_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"scope": {
"name": "scope",
"type": "chat_room_scope",
"typeSchema": "public",
"primaryKey": false,
"notNull": true
},
"department_id": {
"name": "department_id",
"type": "uuid",
"primaryKey": false,
"notNull": false
},
"team_id": {
"name": "team_id",
"type": "uuid",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"chat_rooms_organization_id_idx": {
"name": "chat_rooms_organization_id_idx",
"columns": [
{
"expression": "organization_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"chat_rooms_team_id_team_scope_unique": {
"name": "chat_rooms_team_id_team_scope_unique",
"columns": [
{
"expression": "team_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": true,
"where": "\"chat_rooms\".\"scope\" = 'team'",
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"chat_rooms_organization_id_organizations_id_fk": {
"name": "chat_rooms_organization_id_organizations_id_fk",
"tableFrom": "chat_rooms",
"tableTo": "organizations",
"columnsFrom": [
"organization_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"chat_rooms_department_id_departments_id_fk": {
"name": "chat_rooms_department_id_departments_id_fk",
"tableFrom": "chat_rooms",
"tableTo": "departments",
"columnsFrom": [
"department_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"chat_rooms_team_id_teams_id_fk": {
"name": "chat_rooms_team_id_teams_id_fk",
"tableFrom": "chat_rooms",
"tableTo": "teams",
"columnsFrom": [
"team_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"chat_rooms_matrix_room_id_unique": {
"name": "chat_rooms_matrix_room_id_unique",
"nullsNotDistinct": false,
"columns": [
"matrix_room_id"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.departments": {
"name": "departments",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"organization_id": {
"name": "organization_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"departments_organization_id_idx": {
"name": "departments_organization_id_idx",
"columns": [
{
"expression": "organization_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"departments_organization_id_organizations_id_fk": {
"name": "departments_organization_id_organizations_id_fk",
"tableFrom": "departments",
"tableTo": "organizations",
"columnsFrom": [
"organization_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.invitations": {
"name": "invitations",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"organization_id": {
"name": "organization_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true
},
"token": {
"name": "token",
"type": "text",
"primaryKey": false,
"notNull": true
},
"role": {
"name": "role",
"type": "org_role",
"typeSchema": "public",
"primaryKey": false,
"notNull": true,
"default": "'MEMBER'"
},
"team_id": {
"name": "team_id",
"type": "uuid",
"primaryKey": false,
"notNull": false
},
"status": {
"name": "status",
"type": "invitation_status",
"typeSchema": "public",
"primaryKey": false,
"notNull": true,
"default": "'pending'"
},
"expires_at": {
"name": "expires_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"invitations_organization_id_idx": {
"name": "invitations_organization_id_idx",
"columns": [
{
"expression": "organization_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"invitations_organization_id_organizations_id_fk": {
"name": "invitations_organization_id_organizations_id_fk",
"tableFrom": "invitations",
"tableTo": "organizations",
"columnsFrom": [
"organization_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"invitations_team_id_teams_id_fk": {
"name": "invitations_team_id_teams_id_fk",
"tableFrom": "invitations",
"tableTo": "teams",
"columnsFrom": [
"team_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"invitations_token_unique": {
"name": "invitations_token_unique",
"nullsNotDistinct": false,
"columns": [
"token"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.members": {
"name": "members",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"organization_id": {
"name": "organization_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"user_id": {
"name": "user_id",
"type": "uuid",
"primaryKey": false,
"notNull": false
},
"first_name": {
"name": "first_name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"last_name": {
"name": "last_name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true
},
"phone": {
"name": "phone",
"type": "text",
"primaryKey": false,
"notNull": false
},
"birth_date": {
"name": "birth_date",
"type": "date",
"primaryKey": false,
"notNull": false
},
"status": {
"name": "status",
"type": "member_status",
"typeSchema": "public",
"primaryKey": false,
"notNull": true,
"default": "'active'"
},
"matrix_user_id": {
"name": "matrix_user_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"members_organization_id_idx": {
"name": "members_organization_id_idx",
"columns": [
{
"expression": "organization_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"members_organization_id_organizations_id_fk": {
"name": "members_organization_id_organizations_id_fk",
"tableFrom": "members",
"tableTo": "organizations",
"columnsFrom": [
"organization_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"members_user_id_users_id_fk": {
"name": "members_user_id_users_id_fk",
"tableFrom": "members",
"tableTo": "users",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "set null",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"members_organization_id_email_unique": {
"name": "members_organization_id_email_unique",
"nullsNotDistinct": false,
"columns": [
"organization_id",
"email"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.org_roles": {
"name": "org_roles",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"organization_id": {
"name": "organization_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"member_id": {
"name": "member_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"department_id": {
"name": "department_id",
"type": "uuid",
"primaryKey": false,
"notNull": false
},
"role": {
"name": "role",
"type": "org_role",
"typeSchema": "public",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"org_roles_organization_id_idx": {
"name": "org_roles_organization_id_idx",
"columns": [
{
"expression": "organization_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"org_roles_member_id_idx": {
"name": "org_roles_member_id_idx",
"columns": [
{
"expression": "member_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"org_roles_organization_id_organizations_id_fk": {
"name": "org_roles_organization_id_organizations_id_fk",
"tableFrom": "org_roles",
"tableTo": "organizations",
"columnsFrom": [
"organization_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"org_roles_member_id_members_id_fk": {
"name": "org_roles_member_id_members_id_fk",
"tableFrom": "org_roles",
"tableTo": "members",
"columnsFrom": [
"member_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"org_roles_department_id_departments_id_fk": {
"name": "org_roles_department_id_departments_id_fk",
"tableFrom": "org_roles",
"tableTo": "departments",
"columnsFrom": [
"department_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"org_roles_scope_unique": {
"name": "org_roles_scope_unique",
"nullsNotDistinct": false,
"columns": [
"organization_id",
"member_id",
"department_id",
"role"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.organizations": {
"name": "organizations",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"slug": {
"name": "slug",
"type": "text",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"organizations_slug_unique": {
"name": "organizations_slug_unique",
"nullsNotDistinct": false,
"columns": [
"slug"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.parent_links": {
"name": "parent_links",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"child_member_id": {
"name": "child_member_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"parent_member_id": {
"name": "parent_member_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"parent_links_child_member_id_members_id_fk": {
"name": "parent_links_child_member_id_members_id_fk",
"tableFrom": "parent_links",
"tableTo": "members",
"columnsFrom": [
"child_member_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"parent_links_parent_member_id_members_id_fk": {
"name": "parent_links_parent_member_id_members_id_fk",
"tableFrom": "parent_links",
"tableTo": "members",
"columnsFrom": [
"parent_member_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"parent_links_child_parent_unique": {
"name": "parent_links_child_parent_unique",
"nullsNotDistinct": false,
"columns": [
"child_member_id",
"parent_member_id"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.password_reset_tokens": {
"name": "password_reset_tokens",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"user_id": {
"name": "user_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"token": {
"name": "token",
"type": "text",
"primaryKey": false,
"notNull": true
},
"expires_at": {
"name": "expires_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true
},
"used_at": {
"name": "used_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"password_reset_tokens_user_id_idx": {
"name": "password_reset_tokens_user_id_idx",
"columns": [
{
"expression": "user_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"password_reset_tokens_user_id_users_id_fk": {
"name": "password_reset_tokens_user_id_users_id_fk",
"tableFrom": "password_reset_tokens",
"tableTo": "users",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"password_reset_tokens_token_unique": {
"name": "password_reset_tokens_token_unique",
"nullsNotDistinct": false,
"columns": [
"token"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.seasons": {
"name": "seasons",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"organization_id": {
"name": "organization_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"start_date": {
"name": "start_date",
"type": "date",
"primaryKey": false,
"notNull": true
},
"end_date": {
"name": "end_date",
"type": "date",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"seasons_organization_id_idx": {
"name": "seasons_organization_id_idx",
"columns": [
{
"expression": "organization_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"seasons_organization_id_organizations_id_fk": {
"name": "seasons_organization_id_organizations_id_fk",
"tableFrom": "seasons",
"tableTo": "organizations",
"columnsFrom": [
"organization_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.sync_jobs": {
"name": "sync_jobs",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"organization_id": {
"name": "organization_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"type": {
"name": "type",
"type": "text",
"primaryKey": false,
"notNull": true
},
"payload": {
"name": "payload",
"type": "text",
"primaryKey": false,
"notNull": true
},
"status": {
"name": "status",
"type": "sync_job_status",
"typeSchema": "public",
"primaryKey": false,
"notNull": true,
"default": "'pending'"
},
"attempts": {
"name": "attempts",
"type": "integer",
"primaryKey": false,
"notNull": true,
"default": 0
},
"last_error": {
"name": "last_error",
"type": "text",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"sync_jobs_organization_id_idx": {
"name": "sync_jobs_organization_id_idx",
"columns": [
{
"expression": "organization_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"sync_jobs_status_idx": {
"name": "sync_jobs_status_idx",
"columns": [
{
"expression": "status",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"sync_jobs_organization_id_organizations_id_fk": {
"name": "sync_jobs_organization_id_organizations_id_fk",
"tableFrom": "sync_jobs",
"tableTo": "organizations",
"columnsFrom": [
"organization_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.team_members": {
"name": "team_members",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"team_id": {
"name": "team_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"member_id": {
"name": "member_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"role": {
"name": "role",
"type": "org_role",
"typeSchema": "public",
"primaryKey": false,
"notNull": true,
"default": "'MEMBER'"
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"team_members_team_id_idx": {
"name": "team_members_team_id_idx",
"columns": [
{
"expression": "team_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"team_members_member_id_idx": {
"name": "team_members_member_id_idx",
"columns": [
{
"expression": "member_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"team_members_team_id_teams_id_fk": {
"name": "team_members_team_id_teams_id_fk",
"tableFrom": "team_members",
"tableTo": "teams",
"columnsFrom": [
"team_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"team_members_member_id_members_id_fk": {
"name": "team_members_member_id_members_id_fk",
"tableFrom": "team_members",
"tableTo": "members",
"columnsFrom": [
"member_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"team_members_team_id_member_id_role_unique": {
"name": "team_members_team_id_member_id_role_unique",
"nullsNotDistinct": false,
"columns": [
"team_id",
"member_id",
"role"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.teams": {
"name": "teams",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"organization_id": {
"name": "organization_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"department_id": {
"name": "department_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"season_id": {
"name": "season_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"teams_organization_id_idx": {
"name": "teams_organization_id_idx",
"columns": [
{
"expression": "organization_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"teams_department_id_idx": {
"name": "teams_department_id_idx",
"columns": [
{
"expression": "department_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"teams_organization_id_organizations_id_fk": {
"name": "teams_organization_id_organizations_id_fk",
"tableFrom": "teams",
"tableTo": "organizations",
"columnsFrom": [
"organization_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"teams_department_id_departments_id_fk": {
"name": "teams_department_id_departments_id_fk",
"tableFrom": "teams",
"tableTo": "departments",
"columnsFrom": [
"department_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"teams_season_id_seasons_id_fk": {
"name": "teams_season_id_seasons_id_fk",
"tableFrom": "teams",
"tableTo": "seasons",
"columnsFrom": [
"season_id"
],
"columnsTo": [
"id"
],
"onDelete": "restrict",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.users": {
"name": "users",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true
},
"password_hash": {
"name": "password_hash",
"type": "text",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"users_email_unique": {
"name": "users_email_unique",
"nullsNotDistinct": false,
"columns": [
"email"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
}
},
"enums": {
"public.chat_room_scope": {
"name": "chat_room_scope",
"schema": "public",
"values": [
"organization",
"department",
"team"
]
},
"public.invitation_status": {
"name": "invitation_status",
"schema": "public",
"values": [
"pending",
"accepted",
"revoked",
"expired"
]
},
"public.member_status": {
"name": "member_status",
"schema": "public",
"values": [
"active",
"suspended",
"left"
]
},
"public.org_role": {
"name": "org_role",
"schema": "public",
"values": [
"ORG_ADMIN",
"ORG_MANAGER",
"DEPARTMENT_ADMIN",
"TEAM_MANAGER",
"TEAM_LEAD",
"ASSISTANT_LEAD",
"SUPERVISOR",
"MEMBER",
"GUARDIAN"
]
},
"public.sync_job_status": {
"name": "sync_job_status",
"schema": "public",
"values": [
"pending",
"processing",
"done",
"failed"
]
}
},
"schemas": {},
"sequences": {},
"roles": {},
"policies": {},
"views": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}