{ "id": "da715a3d-633d-4401-81a3-6a4756555d9c", "prevId": "37b1520a-6ef3-413e-9e8b-4984e57260e9", "version": "7", "dialect": "postgresql", "tables": { "public.announcements": { "name": "announcements", "schema": "", "columns": { "id": { "name": "id", "type": "integer", "primaryKey": true, "notNull": true, "identity": { "type": "always", "name": "announcements_id_seq", "schema": "public", "increment": "1", "startWith": "1", "minValue": "1", "maxValue": "2147483647", "cache": "1", "cycle": false } }, "organization_id": { "name": "organization_id", "type": "text", "primaryKey": false, "notNull": true }, "title": { "name": "title", "type": "text", "primaryKey": false, "notNull": true }, "content": { "name": "content", "type": "text", "primaryKey": false, "notNull": true }, "attachment_file_name": { "name": "attachment_file_name", "type": "text", "primaryKey": false, "notNull": false }, "attachment_file_type": { "name": "attachment_file_type", "type": "text", "primaryKey": false, "notNull": false }, "attachment_file_size": { "name": "attachment_file_size", "type": "integer", "primaryKey": false, "notNull": false }, "attachment_storage_key": { "name": "attachment_storage_key", "type": "text", "primaryKey": false, "notNull": false }, "attachment_file_url": { "name": "attachment_file_url", "type": "text", "primaryKey": false, "notNull": false }, "start_date": { "name": "start_date", "type": "timestamp with time zone", "primaryKey": false, "notNull": true }, "end_date": { "name": "end_date", "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, "is_pin": { "name": "is_pin", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "status": { "name": "status", "type": "announcement_status", "typeSchema": "public", "primaryKey": false, "notNull": true, "default": "'draft'" }, "created_by": { "name": "created_by", "type": "text", "primaryKey": false, "notNull": true }, "updated_by": { "name": "updated_by", "type": "text", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": {}, "foreignKeys": { "announcements_organization_id_organizations_id_fk": { "name": "announcements_organization_id_organizations_id_fk", "tableFrom": "announcements", "tableTo": "organizations", "columnsFrom": [ "organization_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "announcements_created_by_users_id_fk": { "name": "announcements_created_by_users_id_fk", "tableFrom": "announcements", "tableTo": "users", "columnsFrom": [ "created_by" ], "columnsTo": [ "id" ], "onDelete": "restrict", "onUpdate": "no action" }, "announcements_updated_by_users_id_fk": { "name": "announcements_updated_by_users_id_fk", "tableFrom": "announcements", "tableTo": "users", "columnsFrom": [ "updated_by" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.audit_logs": { "name": "audit_logs", "schema": "", "columns": { "id": { "name": "id", "type": "integer", "primaryKey": true, "notNull": true, "identity": { "type": "always", "name": "audit_logs_id_seq", "schema": "public", "increment": "1", "startWith": "1", "minValue": "1", "maxValue": "2147483647", "cache": "1", "cycle": false } }, "organization_id": { "name": "organization_id", "type": "text", "primaryKey": false, "notNull": false }, "user_id": { "name": "user_id", "type": "text", "primaryKey": false, "notNull": false }, "module_name": { "name": "module_name", "type": "text", "primaryKey": false, "notNull": true }, "action": { "name": "action", "type": "text", "primaryKey": false, "notNull": true }, "entity_name": { "name": "entity_name", "type": "text", "primaryKey": false, "notNull": false }, "entity_id": { "name": "entity_id", "type": "text", "primaryKey": false, "notNull": false }, "old_value": { "name": "old_value", "type": "jsonb", "primaryKey": false, "notNull": false }, "new_value": { "name": "new_value", "type": "jsonb", "primaryKey": false, "notNull": false }, "ip_address": { "name": "ip_address", "type": "text", "primaryKey": false, "notNull": false }, "user_agent": { "name": "user_agent", "type": "text", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": {}, "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": "set null", "onUpdate": "no action" }, "audit_logs_user_id_users_id_fk": { "name": "audit_logs_user_id_users_id_fk", "tableFrom": "audit_logs", "tableTo": "users", "columnsFrom": [ "user_id" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.certificates": { "name": "certificates", "schema": "", "columns": { "id": { "name": "id", "type": "integer", "primaryKey": true, "notNull": true, "identity": { "type": "always", "name": "certificates_id_seq", "schema": "public", "increment": "1", "startWith": "1", "minValue": "1", "maxValue": "2147483647", "cache": "1", "cycle": false } }, "organization_id": { "name": "organization_id", "type": "text", "primaryKey": false, "notNull": true }, "training_record_id": { "name": "training_record_id", "type": "integer", "primaryKey": false, "notNull": true }, "file_name": { "name": "file_name", "type": "text", "primaryKey": false, "notNull": true }, "file_type": { "name": "file_type", "type": "text", "primaryKey": false, "notNull": true }, "file_size": { "name": "file_size", "type": "integer", "primaryKey": false, "notNull": true }, "storage_key": { "name": "storage_key", "type": "text", "primaryKey": false, "notNull": true }, "file_url": { "name": "file_url", "type": "text", "primaryKey": false, "notNull": false }, "uploaded_by": { "name": "uploaded_by", "type": "text", "primaryKey": false, "notNull": true }, "uploaded_at": { "name": "uploaded_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": {}, "foreignKeys": { "certificates_organization_id_organizations_id_fk": { "name": "certificates_organization_id_organizations_id_fk", "tableFrom": "certificates", "tableTo": "organizations", "columnsFrom": [ "organization_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "certificates_training_record_id_training_records_id_fk": { "name": "certificates_training_record_id_training_records_id_fk", "tableFrom": "certificates", "tableTo": "training_records", "columnsFrom": [ "training_record_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "certificates_uploaded_by_users_id_fk": { "name": "certificates_uploaded_by_users_id_fk", "tableFrom": "certificates", "tableTo": "users", "columnsFrom": [ "uploaded_by" ], "columnsTo": [ "id" ], "onDelete": "restrict", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.courses": { "name": "courses", "schema": "", "columns": { "id": { "name": "id", "type": "integer", "primaryKey": true, "notNull": true, "identity": { "type": "always", "name": "courses_id_seq", "schema": "public", "increment": "1", "startWith": "1", "minValue": "1", "maxValue": "2147483647", "cache": "1", "cycle": false } }, "organization_id": { "name": "organization_id", "type": "text", "primaryKey": false, "notNull": true }, "course_code": { "name": "course_code", "type": "text", "primaryKey": false, "notNull": false }, "name": { "name": "name", "type": "text", "primaryKey": false, "notNull": true }, "category": { "name": "category", "type": "text", "primaryKey": false, "notNull": true }, "organizer": { "name": "organizer", "type": "text", "primaryKey": false, "notNull": false }, "standard_hours": { "name": "standard_hours", "type": "double precision", "primaryKey": false, "notNull": true, "default": 0 }, "certificate_validity_months": { "name": "certificate_validity_months", "type": "integer", "primaryKey": false, "notNull": false }, "is_required": { "name": "is_required", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "certificate_required": { "name": "certificate_required", "type": "boolean", "primaryKey": false, "notNull": true, "default": true }, "training_cost": { "name": "training_cost", "type": "double precision", "primaryKey": false, "notNull": false }, "description": { "name": "description", "type": "text", "primaryKey": false, "notNull": false }, "is_active": { "name": "is_active", "type": "boolean", "primaryKey": false, "notNull": true, "default": true }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "courses_org_name_idx": { "name": "courses_org_name_idx", "columns": [ { "expression": "organization_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "name", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "courses_organization_id_organizations_id_fk": { "name": "courses_organization_id_organizations_id_fk", "tableFrom": "courses", "tableTo": "organizations", "columnsFrom": [ "organization_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.departments": { "name": "departments", "schema": "", "columns": { "id": { "name": "id", "type": "integer", "primaryKey": true, "notNull": true, "identity": { "type": "always", "name": "departments_id_seq", "schema": "public", "increment": "1", "startWith": "1", "minValue": "1", "maxValue": "2147483647", "cache": "1", "cycle": false } }, "organization_id": { "name": "organization_id", "type": "text", "primaryKey": false, "notNull": true }, "code": { "name": "code", "type": "text", "primaryKey": false, "notNull": false }, "name": { "name": "name", "type": "text", "primaryKey": false, "notNull": true }, "description": { "name": "description", "type": "text", "primaryKey": false, "notNull": false }, "is_active": { "name": "is_active", "type": "boolean", "primaryKey": false, "notNull": true, "default": true }, "pending_master_review": { "name": "pending_master_review", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "departments_org_code_idx": { "name": "departments_org_code_idx", "columns": [ { "expression": "organization_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "code", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} }, "departments_org_name_idx": { "name": "departments_org_name_idx", "columns": [ { "expression": "organization_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "name", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "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.employee_training_targets": { "name": "employee_training_targets", "schema": "", "columns": { "id": { "name": "id", "type": "integer", "primaryKey": true, "notNull": true, "identity": { "type": "always", "name": "employee_training_targets_id_seq", "schema": "public", "increment": "1", "startWith": "1", "minValue": "1", "maxValue": "2147483647", "cache": "1", "cycle": false } }, "organization_id": { "name": "organization_id", "type": "text", "primaryKey": false, "notNull": true }, "user_id": { "name": "user_id", "type": "text", "primaryKey": false, "notNull": true }, "employee_id": { "name": "employee_id", "type": "integer", "primaryKey": false, "notNull": false }, "year": { "name": "year", "type": "integer", "primaryKey": false, "notNull": true }, "total_hours": { "name": "total_hours", "type": "double precision", "primaryKey": false, "notNull": true }, "k_hours": { "name": "k_hours", "type": "double precision", "primaryKey": false, "notNull": true }, "s_hours": { "name": "s_hours", "type": "double precision", "primaryKey": false, "notNull": true }, "a_hours": { "name": "a_hours", "type": "double precision", "primaryKey": false, "notNull": true }, "created_by": { "name": "created_by", "type": "text", "primaryKey": false, "notNull": true }, "updated_by": { "name": "updated_by", "type": "text", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "employee_training_targets_org_user_year_idx": { "name": "employee_training_targets_org_user_year_idx", "columns": [ { "expression": "organization_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "user_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "year", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "employee_training_targets_organization_id_organizations_id_fk": { "name": "employee_training_targets_organization_id_organizations_id_fk", "tableFrom": "employee_training_targets", "tableTo": "organizations", "columnsFrom": [ "organization_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "employee_training_targets_user_id_users_id_fk": { "name": "employee_training_targets_user_id_users_id_fk", "tableFrom": "employee_training_targets", "tableTo": "users", "columnsFrom": [ "user_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "employee_training_targets_employee_id_employees_id_fk": { "name": "employee_training_targets_employee_id_employees_id_fk", "tableFrom": "employee_training_targets", "tableTo": "employees", "columnsFrom": [ "employee_id" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" }, "employee_training_targets_created_by_users_id_fk": { "name": "employee_training_targets_created_by_users_id_fk", "tableFrom": "employee_training_targets", "tableTo": "users", "columnsFrom": [ "created_by" ], "columnsTo": [ "id" ], "onDelete": "restrict", "onUpdate": "no action" }, "employee_training_targets_updated_by_users_id_fk": { "name": "employee_training_targets_updated_by_users_id_fk", "tableFrom": "employee_training_targets", "tableTo": "users", "columnsFrom": [ "updated_by" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.employees": { "name": "employees", "schema": "", "columns": { "id": { "name": "id", "type": "integer", "primaryKey": true, "notNull": true, "identity": { "type": "always", "name": "employees_id_seq", "schema": "public", "increment": "1", "startWith": "1", "minValue": "1", "maxValue": "2147483647", "cache": "1", "cycle": false } }, "organization_id": { "name": "organization_id", "type": "text", "primaryKey": false, "notNull": true }, "employee_code": { "name": "employee_code", "type": "text", "primaryKey": false, "notNull": true }, "prefix": { "name": "prefix", "type": "text", "primaryKey": false, "notNull": false }, "first_name_th": { "name": "first_name_th", "type": "text", "primaryKey": false, "notNull": false }, "last_name_th": { "name": "last_name_th", "type": "text", "primaryKey": false, "notNull": false }, "first_name_en": { "name": "first_name_en", "type": "text", "primaryKey": false, "notNull": false }, "last_name_en": { "name": "last_name_en", "type": "text", "primaryKey": false, "notNull": false }, "display_name": { "name": "display_name", "type": "text", "primaryKey": false, "notNull": false }, "full_name": { "name": "full_name", "type": "text", "primaryKey": false, "notNull": true }, "email": { "name": "email", "type": "text", "primaryKey": false, "notNull": false }, "phone": { "name": "phone", "type": "text", "primaryKey": false, "notNull": false }, "company_name": { "name": "company_name", "type": "text", "primaryKey": false, "notNull": false }, "company": { "name": "company", "type": "text", "primaryKey": false, "notNull": false }, "department_id": { "name": "department_id", "type": "integer", "primaryKey": false, "notNull": false }, "position_id": { "name": "position_id", "type": "integer", "primaryKey": false, "notNull": false }, "hired_at": { "name": "hired_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, "status": { "name": "status", "type": "text", "primaryKey": false, "notNull": true, "default": "'active'" }, "is_active": { "name": "is_active", "type": "boolean", "primaryKey": false, "notNull": true, "default": true }, "pending_master_review": { "name": "pending_master_review", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "employees_org_employee_code_idx": { "name": "employees_org_employee_code_idx", "columns": [ { "expression": "organization_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "employee_code", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "employees_organization_id_organizations_id_fk": { "name": "employees_organization_id_organizations_id_fk", "tableFrom": "employees", "tableTo": "organizations", "columnsFrom": [ "organization_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "employees_department_id_departments_id_fk": { "name": "employees_department_id_departments_id_fk", "tableFrom": "employees", "tableTo": "departments", "columnsFrom": [ "department_id" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" }, "employees_position_id_positions_id_fk": { "name": "employees_position_id_positions_id_fk", "tableFrom": "employees", "tableTo": "positions", "columnsFrom": [ "position_id" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.import_jobs": { "name": "import_jobs", "schema": "", "columns": { "id": { "name": "id", "type": "integer", "primaryKey": true, "notNull": true, "identity": { "type": "always", "name": "import_jobs_id_seq", "schema": "public", "increment": "1", "startWith": "1", "minValue": "1", "maxValue": "2147483647", "cache": "1", "cycle": false } }, "organization_id": { "name": "organization_id", "type": "text", "primaryKey": false, "notNull": true }, "import_type": { "name": "import_type", "type": "text", "primaryKey": false, "notNull": true }, "file_name": { "name": "file_name", "type": "text", "primaryKey": false, "notNull": true }, "total_rows": { "name": "total_rows", "type": "integer", "primaryKey": false, "notNull": true, "default": 0 }, "success_rows": { "name": "success_rows", "type": "integer", "primaryKey": false, "notNull": true, "default": 0 }, "failed_rows": { "name": "failed_rows", "type": "integer", "primaryKey": false, "notNull": true, "default": 0 }, "status": { "name": "status", "type": "import_status", "typeSchema": "public", "primaryKey": false, "notNull": true, "default": "'processing'" }, "error_message": { "name": "error_message", "type": "text", "primaryKey": false, "notNull": false }, "created_by": { "name": "created_by", "type": "text", "primaryKey": false, "notNull": true }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": {}, "foreignKeys": { "import_jobs_organization_id_organizations_id_fk": { "name": "import_jobs_organization_id_organizations_id_fk", "tableFrom": "import_jobs", "tableTo": "organizations", "columnsFrom": [ "organization_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "import_jobs_created_by_users_id_fk": { "name": "import_jobs_created_by_users_id_fk", "tableFrom": "import_jobs", "tableTo": "users", "columnsFrom": [ "created_by" ], "columnsTo": [ "id" ], "onDelete": "restrict", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.memberships": { "name": "memberships", "schema": "", "columns": { "id": { "name": "id", "type": "text", "primaryKey": true, "notNull": true }, "user_id": { "name": "user_id", "type": "text", "primaryKey": false, "notNull": true }, "organization_id": { "name": "organization_id", "type": "text", "primaryKey": false, "notNull": true }, "role": { "name": "role", "type": "membership_role", "typeSchema": "public", "primaryKey": false, "notNull": true, "default": "'owner'" }, "permissions": { "name": "permissions", "type": "text[]", "primaryKey": false, "notNull": true, "default": "'{}'" }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "memberships_user_org_idx": { "name": "memberships_user_org_idx", "columns": [ { "expression": "user_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "organization_id", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "memberships_user_id_users_id_fk": { "name": "memberships_user_id_users_id_fk", "tableFrom": "memberships", "tableTo": "users", "columnsFrom": [ "user_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "memberships_organization_id_organizations_id_fk": { "name": "memberships_organization_id_organizations_id_fk", "tableFrom": "memberships", "tableTo": "organizations", "columnsFrom": [ "organization_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.notifications": { "name": "notifications", "schema": "", "columns": { "id": { "name": "id", "type": "integer", "primaryKey": true, "notNull": true, "identity": { "type": "always", "name": "notifications_id_seq", "schema": "public", "increment": "1", "startWith": "1", "minValue": "1", "maxValue": "2147483647", "cache": "1", "cycle": false } }, "organization_id": { "name": "organization_id", "type": "text", "primaryKey": false, "notNull": true }, "user_id": { "name": "user_id", "type": "text", "primaryKey": false, "notNull": true }, "title": { "name": "title", "type": "text", "primaryKey": false, "notNull": true }, "message": { "name": "message", "type": "text", "primaryKey": false, "notNull": true }, "type": { "name": "type", "type": "notification_type", "typeSchema": "public", "primaryKey": false, "notNull": true }, "reference_type": { "name": "reference_type", "type": "text", "primaryKey": false, "notNull": false }, "reference_id": { "name": "reference_id", "type": "text", "primaryKey": false, "notNull": false }, "is_read": { "name": "is_read", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "read_at": { "name": "read_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": {}, "foreignKeys": { "notifications_organization_id_organizations_id_fk": { "name": "notifications_organization_id_organizations_id_fk", "tableFrom": "notifications", "tableTo": "organizations", "columnsFrom": [ "organization_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "notifications_user_id_users_id_fk": { "name": "notifications_user_id_users_id_fk", "tableFrom": "notifications", "tableTo": "users", "columnsFrom": [ "user_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.organizations": { "name": "organizations", "schema": "", "columns": { "id": { "name": "id", "type": "text", "primaryKey": true, "notNull": true }, "name": { "name": "name", "type": "text", "primaryKey": false, "notNull": true }, "slug": { "name": "slug", "type": "text", "primaryKey": false, "notNull": true }, "image_url": { "name": "image_url", "type": "text", "primaryKey": false, "notNull": false }, "plan": { "name": "plan", "type": "text", "primaryKey": false, "notNull": true, "default": "'free'" }, "pending_master_review": { "name": "pending_master_review", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "created_by": { "name": "created_by", "type": "text", "primaryKey": false, "notNull": true }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "organizations_slug_idx": { "name": "organizations_slug_idx", "columns": [ { "expression": "slug", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "organizations_created_by_users_id_fk": { "name": "organizations_created_by_users_id_fk", "tableFrom": "organizations", "tableTo": "users", "columnsFrom": [ "created_by" ], "columnsTo": [ "id" ], "onDelete": "restrict", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.positions": { "name": "positions", "schema": "", "columns": { "id": { "name": "id", "type": "integer", "primaryKey": true, "notNull": true, "identity": { "type": "always", "name": "positions_id_seq", "schema": "public", "increment": "1", "startWith": "1", "minValue": "1", "maxValue": "2147483647", "cache": "1", "cycle": false } }, "organization_id": { "name": "organization_id", "type": "text", "primaryKey": false, "notNull": true }, "code": { "name": "code", "type": "text", "primaryKey": false, "notNull": false }, "name": { "name": "name", "type": "text", "primaryKey": false, "notNull": true }, "description": { "name": "description", "type": "text", "primaryKey": false, "notNull": false }, "is_active": { "name": "is_active", "type": "boolean", "primaryKey": false, "notNull": true, "default": true }, "pending_master_review": { "name": "pending_master_review", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "positions_org_code_idx": { "name": "positions_org_code_idx", "columns": [ { "expression": "organization_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "code", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} }, "positions_org_name_idx": { "name": "positions_org_name_idx", "columns": [ { "expression": "organization_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "name", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "positions_organization_id_organizations_id_fk": { "name": "positions_organization_id_organizations_id_fk", "tableFrom": "positions", "tableTo": "organizations", "columnsFrom": [ "organization_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.products": { "name": "products", "schema": "", "columns": { "id": { "name": "id", "type": "integer", "primaryKey": true, "notNull": true, "identity": { "type": "always", "name": "products_id_seq", "schema": "public", "increment": "1", "startWith": "1", "minValue": "1", "maxValue": "2147483647", "cache": "1", "cycle": false } }, "organization_id": { "name": "organization_id", "type": "text", "primaryKey": false, "notNull": true }, "name": { "name": "name", "type": "text", "primaryKey": false, "notNull": true }, "category": { "name": "category", "type": "text", "primaryKey": false, "notNull": true }, "description": { "name": "description", "type": "text", "primaryKey": false, "notNull": true }, "photo_url": { "name": "photo_url", "type": "text", "primaryKey": false, "notNull": true }, "price": { "name": "price", "type": "double precision", "primaryKey": false, "notNull": true }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": {}, "foreignKeys": { "products_organization_id_organizations_id_fk": { "name": "products_organization_id_organizations_id_fk", "tableFrom": "products", "tableTo": "organizations", "columnsFrom": [ "organization_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.training_matrices": { "name": "training_matrices", "schema": "", "columns": { "id": { "name": "id", "type": "integer", "primaryKey": true, "notNull": true, "identity": { "type": "always", "name": "training_matrices_id_seq", "schema": "public", "increment": "1", "startWith": "1", "minValue": "1", "maxValue": "2147483647", "cache": "1", "cycle": false } }, "organization_id": { "name": "organization_id", "type": "text", "primaryKey": false, "notNull": true }, "department_id": { "name": "department_id", "type": "integer", "primaryKey": false, "notNull": false }, "position_id": { "name": "position_id", "type": "integer", "primaryKey": false, "notNull": false }, "course_id": { "name": "course_id", "type": "integer", "primaryKey": false, "notNull": true }, "is_required": { "name": "is_required", "type": "boolean", "primaryKey": false, "notNull": true, "default": true }, "renewal_period_months": { "name": "renewal_period_months", "type": "integer", "primaryKey": false, "notNull": false }, "note": { "name": "note", "type": "text", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": {}, "foreignKeys": { "training_matrices_organization_id_organizations_id_fk": { "name": "training_matrices_organization_id_organizations_id_fk", "tableFrom": "training_matrices", "tableTo": "organizations", "columnsFrom": [ "organization_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "training_matrices_department_id_departments_id_fk": { "name": "training_matrices_department_id_departments_id_fk", "tableFrom": "training_matrices", "tableTo": "departments", "columnsFrom": [ "department_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "training_matrices_position_id_positions_id_fk": { "name": "training_matrices_position_id_positions_id_fk", "tableFrom": "training_matrices", "tableTo": "positions", "columnsFrom": [ "position_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "training_matrices_course_id_courses_id_fk": { "name": "training_matrices_course_id_courses_id_fk", "tableFrom": "training_matrices", "tableTo": "courses", "columnsFrom": [ "course_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.training_policies": { "name": "training_policies", "schema": "", "columns": { "id": { "name": "id", "type": "integer", "primaryKey": true, "notNull": true, "identity": { "type": "always", "name": "training_policies_id_seq", "schema": "public", "increment": "1", "startWith": "1", "minValue": "1", "maxValue": "2147483647", "cache": "1", "cycle": false } }, "organization_id": { "name": "organization_id", "type": "text", "primaryKey": false, "notNull": true }, "year": { "name": "year", "type": "integer", "primaryKey": false, "notNull": true }, "total_hours": { "name": "total_hours", "type": "double precision", "primaryKey": false, "notNull": true, "default": 30 }, "k_hours": { "name": "k_hours", "type": "double precision", "primaryKey": false, "notNull": true, "default": 12 }, "s_hours": { "name": "s_hours", "type": "double precision", "primaryKey": false, "notNull": true, "default": 12 }, "a_hours": { "name": "a_hours", "type": "double precision", "primaryKey": false, "notNull": true, "default": 6 }, "is_active": { "name": "is_active", "type": "boolean", "primaryKey": false, "notNull": true, "default": true }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "training_policies_org_year_idx": { "name": "training_policies_org_year_idx", "columns": [ { "expression": "organization_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "year", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "training_policies_organization_id_organizations_id_fk": { "name": "training_policies_organization_id_organizations_id_fk", "tableFrom": "training_policies", "tableTo": "organizations", "columnsFrom": [ "organization_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.training_records": { "name": "training_records", "schema": "", "columns": { "id": { "name": "id", "type": "integer", "primaryKey": true, "notNull": true, "identity": { "type": "always", "name": "training_records_id_seq", "schema": "public", "increment": "1", "startWith": "1", "minValue": "1", "maxValue": "2147483647", "cache": "1", "cycle": false } }, "organization_id": { "name": "organization_id", "type": "text", "primaryKey": false, "notNull": true }, "user_id": { "name": "user_id", "type": "text", "primaryKey": false, "notNull": true }, "employee_id": { "name": "employee_id", "type": "integer", "primaryKey": false, "notNull": false }, "course_id": { "name": "course_id", "type": "integer", "primaryKey": false, "notNull": false }, "course_name": { "name": "course_name", "type": "text", "primaryKey": false, "notNull": true }, "training_date": { "name": "training_date", "type": "timestamp with time zone", "primaryKey": false, "notNull": true }, "training_type": { "name": "training_type", "type": "training_type", "typeSchema": "public", "primaryKey": false, "notNull": true }, "hours": { "name": "hours", "type": "double precision", "primaryKey": false, "notNull": true }, "approved_hours": { "name": "approved_hours", "type": "double precision", "primaryKey": false, "notNull": false }, "category": { "name": "category", "type": "training_category", "typeSchema": "public", "primaryKey": false, "notNull": false }, "organizer": { "name": "organizer", "type": "text", "primaryKey": false, "notNull": false }, "note": { "name": "note", "type": "text", "primaryKey": false, "notNull": false }, "approval_status": { "name": "approval_status", "type": "approval_status", "typeSchema": "public", "primaryKey": false, "notNull": true, "default": "'pending'" }, "reviewer_note": { "name": "reviewer_note", "type": "text", "primaryKey": false, "notNull": false }, "reject_reason": { "name": "reject_reason", "type": "text", "primaryKey": false, "notNull": false }, "reviewed_by": { "name": "reviewed_by", "type": "text", "primaryKey": false, "notNull": false }, "reviewed_at": { "name": "reviewed_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, "created_by": { "name": "created_by", "type": "text", "primaryKey": false, "notNull": true }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": {}, "foreignKeys": { "training_records_organization_id_organizations_id_fk": { "name": "training_records_organization_id_organizations_id_fk", "tableFrom": "training_records", "tableTo": "organizations", "columnsFrom": [ "organization_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "training_records_user_id_users_id_fk": { "name": "training_records_user_id_users_id_fk", "tableFrom": "training_records", "tableTo": "users", "columnsFrom": [ "user_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "training_records_employee_id_employees_id_fk": { "name": "training_records_employee_id_employees_id_fk", "tableFrom": "training_records", "tableTo": "employees", "columnsFrom": [ "employee_id" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" }, "training_records_course_id_courses_id_fk": { "name": "training_records_course_id_courses_id_fk", "tableFrom": "training_records", "tableTo": "courses", "columnsFrom": [ "course_id" ], "columnsTo": [ "id" ], "onDelete": "restrict", "onUpdate": "no action" }, "training_records_reviewed_by_users_id_fk": { "name": "training_records_reviewed_by_users_id_fk", "tableFrom": "training_records", "tableTo": "users", "columnsFrom": [ "reviewed_by" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" }, "training_records_created_by_users_id_fk": { "name": "training_records_created_by_users_id_fk", "tableFrom": "training_records", "tableTo": "users", "columnsFrom": [ "created_by" ], "columnsTo": [ "id" ], "onDelete": "restrict", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "public.users": { "name": "users", "schema": "", "columns": { "id": { "name": "id", "type": "text", "primaryKey": true, "notNull": true }, "name": { "name": "name", "type": "text", "primaryKey": false, "notNull": true }, "email": { "name": "email", "type": "text", "primaryKey": false, "notNull": true }, "username": { "name": "username", "type": "text", "primaryKey": false, "notNull": false }, "password_hash": { "name": "password_hash", "type": "text", "primaryKey": false, "notNull": false }, "provider": { "name": "provider", "type": "text", "primaryKey": false, "notNull": true, "default": "'credentials'" }, "provider_user_id": { "name": "provider_user_id", "type": "text", "primaryKey": false, "notNull": false }, "phone": { "name": "phone", "type": "text", "primaryKey": false, "notNull": false }, "image": { "name": "image", "type": "text", "primaryKey": false, "notNull": false }, "system_role": { "name": "system_role", "type": "system_role", "typeSchema": "public", "primaryKey": false, "notNull": true, "default": "'standard'" }, "is_active": { "name": "is_active", "type": "boolean", "primaryKey": false, "notNull": true, "default": true }, "employee_code": { "name": "employee_code", "type": "text", "primaryKey": false, "notNull": false }, "employee_id": { "name": "employee_id", "type": "integer", "primaryKey": false, "notNull": false }, "department_id": { "name": "department_id", "type": "integer", "primaryKey": false, "notNull": false }, "position_id": { "name": "position_id", "type": "integer", "primaryKey": false, "notNull": false }, "company_name": { "name": "company_name", "type": "text", "primaryKey": false, "notNull": false }, "hired_at": { "name": "hired_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, "active_organization_id": { "name": "active_organization_id", "type": "text", "primaryKey": false, "notNull": false }, "last_login_at": { "name": "last_login_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "users_email_idx": { "name": "users_email_idx", "columns": [ { "expression": "email", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} }, "users_username_idx": { "name": "users_username_idx", "columns": [ { "expression": "username", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} }, "users_provider_user_id_idx": { "name": "users_provider_user_id_idx", "columns": [ { "expression": "provider", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "provider_user_id", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "users_employee_id_employees_id_fk": { "name": "users_employee_id_employees_id_fk", "tableFrom": "users", "tableTo": "employees", "columnsFrom": [ "employee_id" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false } }, "enums": { "public.announcement_status": { "name": "announcement_status", "schema": "public", "values": [ "draft", "published", "archived" ] }, "public.approval_status": { "name": "approval_status", "schema": "public", "values": [ "pending", "approved", "rejected", "needs_revision" ] }, "public.import_status": { "name": "import_status", "schema": "public", "values": [ "processing", "completed", "failed" ] }, "public.membership_role": { "name": "membership_role", "schema": "public", "values": [ "owner", "admin", "member" ] }, "public.notification_type": { "name": "notification_type", "schema": "public", "values": [ "approved", "rejected", "announcement", "reminder" ] }, "public.system_role": { "name": "system_role", "schema": "public", "values": [ "standard", "super_admin" ] }, "public.training_category": { "name": "training_category", "schema": "public", "values": [ "K", "S", "A" ] }, "public.training_type": { "name": "training_type", "schema": "public", "values": [ "online", "onsite", "internal", "external" ] } }, "schemas": {}, "sequences": {}, "roles": {}, "policies": {}, "views": {}, "_meta": { "columns": {}, "schemas": {}, "tables": {} } }