Files
nextjs-elysia-allaos/drizzle/meta/0001_snapshot.json
phaichayon 043edff93a setup
2026-04-26 00:15:22 +07:00

3370 lines
87 KiB
JSON

{
"id": "cfa3dff3-6d9b-4ea2-9cf8-1f6e79da8e48",
"prevId": "f2f94f3e-4139-49dd-83ce-903b1759487b",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.tr_audit_logs": {
"name": "tr_audit_logs",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"branch_id": {
"name": "branch_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
"actor_id": {
"name": "actor_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
"entity_type": {
"name": "entity_type",
"type": "text",
"primaryKey": false,
"notNull": true
},
"entity_id": {
"name": "entity_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"action": {
"name": "action",
"type": "text",
"primaryKey": false,
"notNull": true
},
"action_type": {
"name": "action_type",
"type": "text",
"primaryKey": false,
"notNull": false
},
"before_data": {
"name": "before_data",
"type": "jsonb",
"primaryKey": false,
"notNull": false
},
"after_data": {
"name": "after_data",
"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
},
"request_id": {
"name": "request_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"deleted_at": {
"name": "deleted_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"tr_audit_logs_branch_id_idx": {
"name": "tr_audit_logs_branch_id_idx",
"columns": [
{
"expression": "branch_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"tr_audit_logs_user_id_idx": {
"name": "tr_audit_logs_user_id_idx",
"columns": [
{
"expression": "user_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"tr_audit_logs_entity_type_idx": {
"name": "tr_audit_logs_entity_type_idx",
"columns": [
{
"expression": "entity_type",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"tr_audit_logs_entity_id_idx": {
"name": "tr_audit_logs_entity_id_idx",
"columns": [
{
"expression": "entity_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"tr_audit_logs_action_idx": {
"name": "tr_audit_logs_action_idx",
"columns": [
{
"expression": "action",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"tr_audit_logs_created_at_idx": {
"name": "tr_audit_logs_created_at_idx",
"columns": [
{
"expression": "created_at",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"tr_audit_logs_branch_entity_idx": {
"name": "tr_audit_logs_branch_entity_idx",
"columns": [
{
"expression": "branch_id",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "entity_type",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"tr_audit_logs_user_entity_idx": {
"name": "tr_audit_logs_user_entity_idx",
"columns": [
{
"expression": "user_id",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "entity_type",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.ms_branches": {
"name": "ms_branches",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"code": {
"name": "code",
"type": "text",
"primaryKey": false,
"notNull": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"is_active": {
"name": "is_active",
"type": "boolean",
"primaryKey": false,
"notNull": false,
"default": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
}
},
"indexes": {
"idx_branches_code": {
"name": "idx_branches_code",
"columns": [
{
"expression": "code",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"idx_branches_is_active": {
"name": "idx_branches_is_active",
"columns": [
{
"expression": "is_active",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"ms_branches_code_unique": {
"name": "ms_branches_code_unique",
"nullsNotDistinct": false,
"columns": [
"code"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.ms_customer_contact_shares": {
"name": "ms_customer_contact_shares",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"contact_id": {
"name": "contact_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"shared_with_user_id": {
"name": "shared_with_user_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"shared_by": {
"name": "shared_by",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"shared_at": {
"name": "shared_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"notes": {
"name": "notes",
"type": "text",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"idx_contact_shares_contact": {
"name": "idx_contact_shares_contact",
"columns": [
{
"expression": "contact_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"idx_contact_shares_user": {
"name": "idx_contact_shares_user",
"columns": [
{
"expression": "shared_with_user_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"idx_contact_shares_shared_by": {
"name": "idx_contact_shares_shared_by",
"columns": [
{
"expression": "shared_by",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"ms_customer_contact_shares_contact_id_ms_customer_contacts_id_fk": {
"name": "ms_customer_contact_shares_contact_id_ms_customer_contacts_id_fk",
"tableFrom": "ms_customer_contact_shares",
"tableTo": "ms_customer_contacts",
"columnsFrom": [
"contact_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"ms_customer_contact_shares_shared_with_user_id_users_id_fk": {
"name": "ms_customer_contact_shares_shared_with_user_id_users_id_fk",
"tableFrom": "ms_customer_contact_shares",
"tableTo": "users",
"columnsFrom": [
"shared_with_user_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"ms_customer_contact_shares_shared_by_users_id_fk": {
"name": "ms_customer_contact_shares_shared_by_users_id_fk",
"tableFrom": "ms_customer_contact_shares",
"tableTo": "users",
"columnsFrom": [
"shared_by"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"uq_contact_share": {
"name": "uq_contact_share",
"nullsNotDistinct": false,
"columns": [
"contact_id",
"shared_with_user_id"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.ms_customer_contacts": {
"name": "ms_customer_contacts",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"branch_id": {
"name": "branch_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"customer_id": {
"name": "customer_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"position": {
"name": "position",
"type": "text",
"primaryKey": false,
"notNull": false
},
"department": {
"name": "department",
"type": "text",
"primaryKey": false,
"notNull": false
},
"phone": {
"name": "phone",
"type": "text",
"primaryKey": false,
"notNull": false
},
"mobile": {
"name": "mobile",
"type": "text",
"primaryKey": false,
"notNull": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": false
},
"is_primary": {
"name": "is_primary",
"type": "boolean",
"primaryKey": false,
"notNull": false,
"default": false
},
"notes": {
"name": "notes",
"type": "text",
"primaryKey": false,
"notNull": false
},
"created_by": {
"name": "created_by",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"is_public": {
"name": "is_public",
"type": "boolean",
"primaryKey": false,
"notNull": false,
"default": false
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"updated_by": {
"name": "updated_by",
"type": "uuid",
"primaryKey": false,
"notNull": false
},
"deleted_at": {
"name": "deleted_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"idx_contacts_customer": {
"name": "idx_contacts_customer",
"columns": [
{
"expression": "customer_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"idx_contacts_branch": {
"name": "idx_contacts_branch",
"columns": [
{
"expression": "branch_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"idx_contacts_created_by": {
"name": "idx_contacts_created_by",
"columns": [
{
"expression": "created_by",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"idx_contacts_visibility": {
"name": "idx_contacts_visibility",
"columns": [
{
"expression": "customer_id",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "created_by",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"ms_customer_contacts_branch_id_ms_branches_id_fk": {
"name": "ms_customer_contacts_branch_id_ms_branches_id_fk",
"tableFrom": "ms_customer_contacts",
"tableTo": "ms_branches",
"columnsFrom": [
"branch_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"ms_customer_contacts_customer_id_ms_customers_id_fk": {
"name": "ms_customer_contacts_customer_id_ms_customers_id_fk",
"tableFrom": "ms_customer_contacts",
"tableTo": "ms_customers",
"columnsFrom": [
"customer_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"ms_customer_contacts_created_by_users_id_fk": {
"name": "ms_customer_contacts_created_by_users_id_fk",
"tableFrom": "ms_customer_contacts",
"tableTo": "users",
"columnsFrom": [
"created_by"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"ms_customer_contacts_updated_by_users_id_fk": {
"name": "ms_customer_contacts_updated_by_users_id_fk",
"tableFrom": "ms_customer_contacts",
"tableTo": "users",
"columnsFrom": [
"updated_by"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.ms_customers": {
"name": "ms_customers",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"branch_id": {
"name": "branch_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"crm_customer_code": {
"name": "crm_customer_code",
"type": "text",
"primaryKey": false,
"notNull": true
},
"erp_customer_code": {
"name": "erp_customer_code",
"type": "text",
"primaryKey": false,
"notNull": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"abbr": {
"name": "abbr",
"type": "text",
"primaryKey": false,
"notNull": false
},
"tax_id": {
"name": "tax_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
"address": {
"name": "address",
"type": "text",
"primaryKey": false,
"notNull": false
},
"province": {
"name": "province",
"type": "text",
"primaryKey": false,
"notNull": false
},
"district": {
"name": "district",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sub_district": {
"name": "sub_district",
"type": "text",
"primaryKey": false,
"notNull": false
},
"postal_code": {
"name": "postal_code",
"type": "text",
"primaryKey": false,
"notNull": false
},
"country": {
"name": "country",
"type": "text",
"primaryKey": false,
"notNull": false,
"default": "'Thailand'"
},
"phone": {
"name": "phone",
"type": "text",
"primaryKey": false,
"notNull": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": false
},
"website": {
"name": "website",
"type": "text",
"primaryKey": false,
"notNull": false
},
"customer_type": {
"name": "customer_type",
"type": "text",
"primaryKey": false,
"notNull": false
},
"customer_old": {
"name": "customer_old",
"type": "boolean",
"primaryKey": false,
"notNull": false,
"default": false
},
"customer_ref": {
"name": "customer_ref",
"type": "text",
"primaryKey": false,
"notNull": false
},
"customer_status": {
"name": "customer_status",
"type": "text",
"primaryKey": false,
"notNull": false,
"default": "'draft'"
},
"lead_channel": {
"name": "lead_channel",
"type": "text",
"primaryKey": false,
"notNull": false
},
"awareness": {
"name": "awareness",
"type": "text",
"primaryKey": false,
"notNull": false
},
"customer_group": {
"name": "customer_group",
"type": "text",
"primaryKey": false,
"notNull": false
},
"customer_sub_group": {
"name": "customer_sub_group",
"type": "text",
"primaryKey": false,
"notNull": false
},
"credit_limit": {
"name": "credit_limit",
"type": "numeric(15, 2)",
"primaryKey": false,
"notNull": false,
"default": "'0'"
},
"payment_terms": {
"name": "payment_terms",
"type": "text",
"primaryKey": false,
"notNull": false
},
"notes": {
"name": "notes",
"type": "text",
"primaryKey": false,
"notNull": false
},
"is_active": {
"name": "is_active",
"type": "boolean",
"primaryKey": false,
"notNull": false,
"default": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"created_by": {
"name": "created_by",
"type": "uuid",
"primaryKey": false,
"notNull": false
},
"updated_by": {
"name": "updated_by",
"type": "uuid",
"primaryKey": false,
"notNull": false
},
"deleted_at": {
"name": "deleted_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"idx_customers_branch": {
"name": "idx_customers_branch",
"columns": [
{
"expression": "branch_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"idx_customers_status": {
"name": "idx_customers_status",
"columns": [
{
"expression": "customer_status",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"idx_customers_crm_code": {
"name": "idx_customers_crm_code",
"columns": [
{
"expression": "crm_customer_code",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"idx_customers_erp_code": {
"name": "idx_customers_erp_code",
"columns": [
{
"expression": "erp_customer_code",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"ms_customers_branch_id_ms_branches_id_fk": {
"name": "ms_customers_branch_id_ms_branches_id_fk",
"tableFrom": "ms_customers",
"tableTo": "ms_branches",
"columnsFrom": [
"branch_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"ms_customers_created_by_users_id_fk": {
"name": "ms_customers_created_by_users_id_fk",
"tableFrom": "ms_customers",
"tableTo": "users",
"columnsFrom": [
"created_by"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"ms_customers_updated_by_users_id_fk": {
"name": "ms_customers_updated_by_users_id_fk",
"tableFrom": "ms_customers",
"tableTo": "users",
"columnsFrom": [
"updated_by"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"ms_customers_crm_customer_code_unique": {
"name": "ms_customers_crm_customer_code_unique",
"nullsNotDistinct": false,
"columns": [
"crm_customer_code"
]
},
"ms_customers_erp_customer_code_unique": {
"name": "ms_customers_erp_customer_code_unique",
"nullsNotDistinct": false,
"columns": [
"erp_customer_code"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.document_sequences": {
"name": "document_sequences",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"document_type": {
"name": "document_type",
"type": "text",
"primaryKey": false,
"notNull": true
},
"prefix": {
"name": "prefix",
"type": "text",
"primaryKey": false,
"notNull": true
},
"period": {
"name": "period",
"type": "text",
"primaryKey": false,
"notNull": true
},
"current_number": {
"name": "current_number",
"type": "integer",
"primaryKey": false,
"notNull": true,
"default": 0
},
"padding_length": {
"name": "padding_length",
"type": "integer",
"primaryKey": false,
"notNull": true,
"default": 3
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"deleted_at": {
"name": "deleted_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"uq_document_period": {
"name": "uq_document_period",
"columns": [
{
"expression": "document_type",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "period",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
"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()"
},
"keycloak_id": {
"name": "keycloak_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"email": {
"name": "email",
"type": "text",
"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()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"users_keycloak_id_unique": {
"name": "users_keycloak_id_unique",
"nullsNotDistinct": false,
"columns": [
"keycloak_id"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.tr_quotations_attachments": {
"name": "tr_quotations_attachments",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"quotation_id": {
"name": "quotation_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"file_name": {
"name": "file_name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"original_file_name": {
"name": "original_file_name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"file_path": {
"name": "file_path",
"type": "text",
"primaryKey": false,
"notNull": true
},
"file_size": {
"name": "file_size",
"type": "text",
"primaryKey": false,
"notNull": true
},
"file_type": {
"name": "file_type",
"type": "text",
"primaryKey": false,
"notNull": true
},
"uploaded_at": {
"name": "uploaded_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"uploaded_by": {
"name": "uploaded_by",
"type": "text",
"primaryKey": false,
"notNull": false
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
},
"deleted_at": {
"name": "deleted_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {
"tr_quotations_attachments_quotation_id_tr_quotations_id_fk": {
"name": "tr_quotations_attachments_quotation_id_tr_quotations_id_fk",
"tableFrom": "tr_quotations_attachments",
"tableTo": "tr_quotations",
"columnsFrom": [
"quotation_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.tr_quotations_customers": {
"name": "tr_quotations_customers",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"quotation_id": {
"name": "quotation_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"customer_id": {
"name": "customer_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"role": {
"name": "role",
"type": "text",
"primaryKey": false,
"notNull": true
},
"is_primary": {
"name": "is_primary",
"type": "boolean",
"primaryKey": false,
"notNull": false,
"default": false
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"deleted_at": {
"name": "deleted_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"idx_qcust_quotation_id": {
"name": "idx_qcust_quotation_id",
"columns": [
{
"expression": "quotation_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"idx_qcust_customer_id": {
"name": "idx_qcust_customer_id",
"columns": [
{
"expression": "customer_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"tr_quotations_customers_quotation_id_tr_quotations_id_fk": {
"name": "tr_quotations_customers_quotation_id_tr_quotations_id_fk",
"tableFrom": "tr_quotations_customers",
"tableTo": "tr_quotations",
"columnsFrom": [
"quotation_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"tr_quotations_customers_customer_id_ms_customers_id_fk": {
"name": "tr_quotations_customers_customer_id_ms_customers_id_fk",
"tableFrom": "tr_quotations_customers",
"tableTo": "ms_customers",
"columnsFrom": [
"customer_id"
],
"columnsTo": [
"id"
],
"onDelete": "restrict",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"uq_quotations_customer": {
"name": "uq_quotations_customer",
"nullsNotDistinct": false,
"columns": [
"quotation_id",
"customer_id",
"role"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.tr_quotations_followups": {
"name": "tr_quotations_followups",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"quotation_id": {
"name": "quotation_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"followup_date": {
"name": "followup_date",
"type": "date",
"primaryKey": false,
"notNull": true
},
"followup_type": {
"name": "followup_type",
"type": "text",
"primaryKey": false,
"notNull": false
},
"contact_person": {
"name": "contact_person",
"type": "text",
"primaryKey": false,
"notNull": false
},
"contact_method": {
"name": "contact_method",
"type": "text",
"primaryKey": false,
"notNull": false
},
"outcome": {
"name": "outcome",
"type": "text",
"primaryKey": false,
"notNull": false
},
"notes": {
"name": "notes",
"type": "text",
"primaryKey": false,
"notNull": false
},
"next_followup_date": {
"name": "next_followup_date",
"type": "date",
"primaryKey": false,
"notNull": false
},
"next_action": {
"name": "next_action",
"type": "text",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"tr_quotations_followups_quotation_id_tr_quotations_id_fk": {
"name": "tr_quotations_followups_quotation_id_tr_quotations_id_fk",
"tableFrom": "tr_quotations_followups",
"tableTo": "tr_quotations",
"columnsFrom": [
"quotation_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.tr_quotations_items": {
"name": "tr_quotations_items",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"quotation_id": {
"name": "quotation_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"item_number": {
"name": "item_number",
"type": "text",
"primaryKey": false,
"notNull": true
},
"product_type": {
"name": "product_type",
"type": "text",
"primaryKey": false,
"notNull": false
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": true
},
"quantity": {
"name": "quantity",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false,
"default": "'1'"
},
"unit": {
"name": "unit",
"type": "text",
"primaryKey": false,
"notNull": false,
"default": "'pcs'"
},
"unit_price": {
"name": "unit_price",
"type": "numeric(15, 2)",
"primaryKey": false,
"notNull": false,
"default": "'0'"
},
"discount": {
"name": "discount",
"type": "numeric(15, 2)",
"primaryKey": false,
"notNull": false,
"default": "'0'"
},
"discount_type": {
"name": "discount_type",
"type": "text",
"primaryKey": false,
"notNull": false,
"default": "'percentage'"
},
"tax_rate": {
"name": "tax_rate",
"type": "numeric(5, 2)",
"primaryKey": false,
"notNull": false,
"default": "'7'"
},
"total_price": {
"name": "total_price",
"type": "numeric(15, 2)",
"primaryKey": false,
"notNull": false,
"default": "'0'"
},
"notes": {
"name": "notes",
"type": "text",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"deleted_at": {
"name": "deleted_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"idx_qitem_quotation_id": {
"name": "idx_qitem_quotation_id",
"columns": [
{
"expression": "quotation_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"tr_quotations_items_quotation_id_tr_quotations_id_fk": {
"name": "tr_quotations_items_quotation_id_tr_quotations_id_fk",
"tableFrom": "tr_quotations_items",
"tableTo": "tr_quotations",
"columnsFrom": [
"quotation_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.ms_quotations_template_mappings": {
"name": "ms_quotations_template_mappings",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"template_version_id": {
"name": "template_version_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"placeholder_key": {
"name": "placeholder_key",
"type": "text",
"primaryKey": false,
"notNull": true
},
"source_path": {
"name": "source_path",
"type": "text",
"primaryKey": false,
"notNull": true
},
"data_type": {
"name": "data_type",
"type": "text",
"primaryKey": false,
"notNull": true
},
"sheet_name": {
"name": "sheet_name",
"type": "text",
"primaryKey": false,
"notNull": false
},
"default_value": {
"name": "default_value",
"type": "text",
"primaryKey": false,
"notNull": false
},
"format_mask": {
"name": "format_mask",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sort_order": {
"name": "sort_order",
"type": "integer",
"primaryKey": false,
"notNull": false,
"default": 0
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
}
},
"indexes": {
"idx_mapping_template_version": {
"name": "idx_mapping_template_version",
"columns": [
{
"expression": "template_version_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"idx_mapping_placeholder": {
"name": "idx_mapping_placeholder",
"columns": [
{
"expression": "placeholder_key",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"ms_quotations_template_mappings_template_version_id_ms_quotations_template_versions_id_fk": {
"name": "ms_quotations_template_mappings_template_version_id_ms_quotations_template_versions_id_fk",
"tableFrom": "ms_quotations_template_mappings",
"tableTo": "ms_quotations_template_versions",
"columnsFrom": [
"template_version_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.ms_quotations_template_table_columns": {
"name": "ms_quotations_template_table_columns",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"mapping_id": {
"name": "mapping_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"column_name": {
"name": "column_name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"source_field": {
"name": "source_field",
"type": "text",
"primaryKey": false,
"notNull": true
},
"column_letter": {
"name": "column_letter",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sort_order": {
"name": "sort_order",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"format_mask": {
"name": "format_mask",
"type": "text",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
}
},
"indexes": {
"idx_tablecol_mapping": {
"name": "idx_tablecol_mapping",
"columns": [
{
"expression": "mapping_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"ms_quotations_template_table_columns_mapping_id_ms_quotations_template_mappings_id_fk": {
"name": "ms_quotations_template_table_columns_mapping_id_ms_quotations_template_mappings_id_fk",
"tableFrom": "ms_quotations_template_table_columns",
"tableTo": "ms_quotations_template_mappings",
"columnsFrom": [
"mapping_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.ms_quotations_template_versions": {
"name": "ms_quotations_template_versions",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"template_id": {
"name": "template_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"version": {
"name": "version",
"type": "text",
"primaryKey": false,
"notNull": true
},
"file_path": {
"name": "file_path",
"type": "text",
"primaryKey": false,
"notNull": true
},
"is_active": {
"name": "is_active",
"type": "boolean",
"primaryKey": false,
"notNull": false,
"default": false
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"created_by": {
"name": "created_by",
"type": "text",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {
"ms_quotations_template_versions_template_id_ms_quotations_templates_id_fk": {
"name": "ms_quotations_template_versions_template_id_ms_quotations_templates_id_fk",
"tableFrom": "ms_quotations_template_versions",
"tableTo": "ms_quotations_templates",
"columnsFrom": [
"template_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"uq_template_version": {
"name": "uq_template_version",
"nullsNotDistinct": false,
"columns": [
"template_id",
"version"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.ms_quotations_templates": {
"name": "ms_quotations_templates",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"product_type": {
"name": "product_type",
"type": "text",
"primaryKey": false,
"notNull": true
},
"file_type": {
"name": "file_type",
"type": "text",
"primaryKey": false,
"notNull": true
},
"template_name": {
"name": "template_name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"template_path": {
"name": "template_path",
"type": "text",
"primaryKey": false,
"notNull": true
},
"is_default": {
"name": "is_default",
"type": "boolean",
"primaryKey": false,
"notNull": false,
"default": false
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.ms_quotations_topic_defaults": {
"name": "ms_quotations_topic_defaults",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"product_type": {
"name": "product_type",
"type": "text",
"primaryKey": false,
"notNull": true
},
"topic_type": {
"name": "topic_type",
"type": "text",
"primaryKey": false,
"notNull": true
},
"content": {
"name": "content",
"type": "text",
"primaryKey": false,
"notNull": true
},
"sort_order": {
"name": "sort_order",
"type": "integer",
"primaryKey": false,
"notNull": false,
"default": 0
},
"is_active": {
"name": "is_active",
"type": "boolean",
"primaryKey": false,
"notNull": false,
"default": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.tr_quotations_topic_items": {
"name": "tr_quotations_topic_items",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"topic_id": {
"name": "topic_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"content": {
"name": "content",
"type": "text",
"primaryKey": false,
"notNull": true
},
"sort_order": {
"name": "sort_order",
"type": "integer",
"primaryKey": false,
"notNull": false,
"default": 0
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"tr_quotations_topic_items_topic_id_tr_quotations_topics_id_fk": {
"name": "tr_quotations_topic_items_topic_id_tr_quotations_topics_id_fk",
"tableFrom": "tr_quotations_topic_items",
"tableTo": "tr_quotations_topics",
"columnsFrom": [
"topic_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.tr_quotations_topics": {
"name": "tr_quotations_topics",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"quotation_id": {
"name": "quotation_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"topic_type": {
"name": "topic_type",
"type": "text",
"primaryKey": false,
"notNull": true
},
"sort_order": {
"name": "sort_order",
"type": "integer",
"primaryKey": false,
"notNull": false,
"default": 0
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"tr_quotations_topics_quotation_id_tr_quotations_id_fk": {
"name": "tr_quotations_topics_quotation_id_tr_quotations_id_fk",
"tableFrom": "tr_quotations_topics",
"tableTo": "tr_quotations",
"columnsFrom": [
"quotation_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.tr_quotations": {
"name": "tr_quotations",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"branch_id": {
"name": "branch_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"code": {
"name": "code",
"type": "text",
"primaryKey": false,
"notNull": true
},
"revision_no": {
"name": "revision_no",
"type": "integer",
"primaryKey": false,
"notNull": true,
"default": 1
},
"parent_quotation_id": {
"name": "parent_quotation_id",
"type": "uuid",
"primaryKey": false,
"notNull": false
},
"quotation_date": {
"name": "quotation_date",
"type": "date",
"primaryKey": false,
"notNull": true
},
"valid_until": {
"name": "valid_until",
"type": "date",
"primaryKey": false,
"notNull": false
},
"quotation_type": {
"name": "quotation_type",
"type": "text",
"primaryKey": false,
"notNull": false
},
"competitor": {
"name": "competitor",
"type": "text",
"primaryKey": false,
"notNull": false
},
"mk_job_no": {
"name": "mk_job_no",
"type": "text",
"primaryKey": false,
"notNull": false
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": false,
"default": "'draft'"
},
"is_active": {
"name": "is_active",
"type": "boolean",
"primaryKey": false,
"notNull": false,
"default": true
},
"revision": {
"name": "revision",
"type": "text",
"primaryKey": false,
"notNull": false,
"default": "'0'"
},
"revision_remark": {
"name": "revision_remark",
"type": "text",
"primaryKey": false,
"notNull": false
},
"template_id": {
"name": "template_id",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"subtotal": {
"name": "subtotal",
"type": "numeric(15, 2)",
"primaryKey": false,
"notNull": false,
"default": "'0'"
},
"discount": {
"name": "discount",
"type": "numeric(15, 2)",
"primaryKey": false,
"notNull": false,
"default": "'0'"
},
"discount_type": {
"name": "discount_type",
"type": "text",
"primaryKey": false,
"notNull": false,
"default": "'percentage'"
},
"tax_rate": {
"name": "tax_rate",
"type": "numeric(5, 2)",
"primaryKey": false,
"notNull": false,
"default": "'7'"
},
"tax_amount": {
"name": "tax_amount",
"type": "numeric(15, 2)",
"primaryKey": false,
"notNull": false,
"default": "'0'"
},
"total_amount": {
"name": "total_amount",
"type": "numeric(15, 2)",
"primaryKey": false,
"notNull": false,
"default": "'0'"
},
"salesman_id": {
"name": "salesman_id",
"type": "uuid",
"primaryKey": false,
"notNull": false
},
"sale_admin_id": {
"name": "sale_admin_id",
"type": "uuid",
"primaryKey": false,
"notNull": false
},
"currency_code": {
"name": "currency_code",
"type": "text",
"primaryKey": false,
"notNull": true,
"default": "'THB'"
},
"exchange_rate": {
"name": "exchange_rate",
"type": "numeric(12, 6)",
"primaryKey": false,
"notNull": true
},
"base_currency_amount": {
"name": "base_currency_amount",
"type": "numeric(15, 2)",
"primaryKey": false,
"notNull": false
},
"notes": {
"name": "notes",
"type": "text",
"primaryKey": false,
"notNull": false
},
"reference": {
"name": "reference",
"type": "text",
"primaryKey": false,
"notNull": false
},
"project": {
"name": "project",
"type": "text",
"primaryKey": false,
"notNull": false
},
"attention": {
"name": "attention",
"type": "text",
"primaryKey": false,
"notNull": false
},
"location_province": {
"name": "location_province",
"type": "text",
"primaryKey": false,
"notNull": false
},
"location_industrial": {
"name": "location_industrial",
"type": "text",
"primaryKey": false,
"notNull": false
},
"location_orther": {
"name": "location_orther",
"type": "text",
"primaryKey": false,
"notNull": false
},
"final_date": {
"name": "final_date",
"type": "date",
"primaryKey": false,
"notNull": false
},
"delivery_date": {
"name": "delivery_date",
"type": "date",
"primaryKey": false,
"notNull": false
},
"chance_percent": {
"name": "chance_percent",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"is_hot_project": {
"name": "is_hot_project",
"type": "boolean",
"primaryKey": false,
"notNull": false,
"default": false
},
"approved_snapshot": {
"name": "approved_snapshot",
"type": "jsonb",
"primaryKey": false,
"notNull": false
},
"approved_pdf_url": {
"name": "approved_pdf_url",
"type": "text",
"primaryKey": false,
"notNull": false
},
"is_sent": {
"name": "is_sent",
"type": "boolean",
"primaryKey": false,
"notNull": false,
"default": false
},
"sent_at": {
"name": "sent_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false
},
"sent_via": {
"name": "sent_via",
"type": "text",
"primaryKey": false,
"notNull": false
},
"accepted_at": {
"name": "accepted_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false
},
"rejected_at": {
"name": "rejected_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false
},
"rejection_reason": {
"name": "rejection_reason",
"type": "text",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"created_by": {
"name": "created_by",
"type": "uuid",
"primaryKey": false,
"notNull": false
},
"updated_by": {
"name": "updated_by",
"type": "uuid",
"primaryKey": false,
"notNull": false
},
"deleted_at": {
"name": "deleted_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"idx_quotations_branch": {
"name": "idx_quotations_branch",
"columns": [
{
"expression": "branch_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"idx_quotations_code": {
"name": "idx_quotations_code",
"columns": [
{
"expression": "code",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"idx_quotation_status": {
"name": "idx_quotation_status",
"columns": [
{
"expression": "status",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"idx_quotation_date": {
"name": "idx_quotation_date",
"columns": [
{
"expression": "quotation_date",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"idx_quotations_branch_status": {
"name": "idx_quotations_branch_status",
"columns": [
{
"expression": "branch_id",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "status",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"idx_quotations_revision": {
"name": "idx_quotations_revision",
"columns": [
{
"expression": "parent_quotation_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"tr_quotations_branch_id_ms_branches_id_fk": {
"name": "tr_quotations_branch_id_ms_branches_id_fk",
"tableFrom": "tr_quotations",
"tableTo": "ms_branches",
"columnsFrom": [
"branch_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"tr_quotations_parent_quotation_id_tr_quotations_id_fk": {
"name": "tr_quotations_parent_quotation_id_tr_quotations_id_fk",
"tableFrom": "tr_quotations",
"tableTo": "tr_quotations",
"columnsFrom": [
"parent_quotation_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"tr_quotations_salesman_id_users_id_fk": {
"name": "tr_quotations_salesman_id_users_id_fk",
"tableFrom": "tr_quotations",
"tableTo": "users",
"columnsFrom": [
"salesman_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"tr_quotations_sale_admin_id_users_id_fk": {
"name": "tr_quotations_sale_admin_id_users_id_fk",
"tableFrom": "tr_quotations",
"tableTo": "users",
"columnsFrom": [
"sale_admin_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"tr_quotations_created_by_users_id_fk": {
"name": "tr_quotations_created_by_users_id_fk",
"tableFrom": "tr_quotations",
"tableTo": "users",
"columnsFrom": [
"created_by"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"tr_quotations_updated_by_users_id_fk": {
"name": "tr_quotations_updated_by_users_id_fk",
"tableFrom": "tr_quotations",
"tableTo": "users",
"columnsFrom": [
"updated_by"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.tr_quotation_contacts": {
"name": "tr_quotation_contacts",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"quotation_id": {
"name": "quotation_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"contact_id": {
"name": "contact_id",
"type": "uuid",
"primaryKey": false,
"notNull": false
},
"snapshot_name": {
"name": "snapshot_name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"snapshot_email": {
"name": "snapshot_email",
"type": "text",
"primaryKey": false,
"notNull": false
},
"snapshot_phone": {
"name": "snapshot_phone",
"type": "text",
"primaryKey": false,
"notNull": false
},
"snapshot_mobile": {
"name": "snapshot_mobile",
"type": "text",
"primaryKey": false,
"notNull": false
},
"snapshot_position": {
"name": "snapshot_position",
"type": "text",
"primaryKey": false,
"notNull": false
},
"snapshot_department": {
"name": "snapshot_department",
"type": "text",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
}
},
"indexes": {
"idx_quotation_contact": {
"name": "idx_quotation_contact",
"columns": [
{
"expression": "quotation_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"idx_quotation_contact_contact": {
"name": "idx_quotation_contact_contact",
"columns": [
{
"expression": "contact_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"tr_quotation_contacts_quotation_id_tr_quotations_id_fk": {
"name": "tr_quotation_contacts_quotation_id_tr_quotations_id_fk",
"tableFrom": "tr_quotation_contacts",
"tableTo": "tr_quotations",
"columnsFrom": [
"quotation_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"tr_quotation_contacts_contact_id_ms_customer_contacts_id_fk": {
"name": "tr_quotation_contacts_contact_id_ms_customer_contacts_id_fk",
"tableFrom": "tr_quotation_contacts",
"tableTo": "ms_customer_contacts",
"columnsFrom": [
"contact_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.ms_industrial_estates": {
"name": "ms_industrial_estates",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"branch_id": {
"name": "branch_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"code": {
"name": "code",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"name_th": {
"name": "name_th",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"name_en": {
"name": "name_en",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"location_id": {
"name": "location_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"latitude": {
"name": "latitude",
"type": "double precision",
"primaryKey": false,
"notNull": false
},
"longitude": {
"name": "longitude",
"type": "double precision",
"primaryKey": false,
"notNull": false
},
"is_active": {
"name": "is_active",
"type": "boolean",
"primaryKey": false,
"notNull": false,
"default": true
},
"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()"
},
"created_by": {
"name": "created_by",
"type": "text",
"primaryKey": false,
"notNull": false
},
"updated_by": {
"name": "updated_by",
"type": "text",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"ms_industrial_estates_branch_id_idx": {
"name": "ms_industrial_estates_branch_id_idx",
"columns": [
{
"expression": "branch_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"ms_industrial_estates_location_id_idx": {
"name": "ms_industrial_estates_location_id_idx",
"columns": [
{
"expression": "location_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"ms_industrial_estates_branch_location_idx": {
"name": "ms_industrial_estates_branch_location_idx",
"columns": [
{
"expression": "branch_id",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "location_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"ms_industrial_estates_location_id_ms_locations_id_fk": {
"name": "ms_industrial_estates_location_id_ms_locations_id_fk",
"tableFrom": "ms_industrial_estates",
"tableTo": "ms_locations",
"columnsFrom": [
"location_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.ms_locations": {
"name": "ms_locations",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"branch_id": {
"name": "branch_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"code": {
"name": "code",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"name_th": {
"name": "name_th",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"name_en": {
"name": "name_en",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"type": {
"name": "type",
"type": "varchar(50)",
"primaryKey": false,
"notNull": true
},
"parent_id": {
"name": "parent_id",
"type": "uuid",
"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": {
"ms_locations_branch_id_idx": {
"name": "ms_locations_branch_id_idx",
"columns": [
{
"expression": "branch_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"ms_locations_type_idx": {
"name": "ms_locations_type_idx",
"columns": [
{
"expression": "type",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"ms_locations_parent_id_idx": {
"name": "ms_locations_parent_id_idx",
"columns": [
{
"expression": "parent_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"ms_locations_branch_type_idx": {
"name": "ms_locations_branch_type_idx",
"columns": [
{
"expression": "branch_id",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "type",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.ms_options": {
"name": "ms_options",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"branch_id": {
"name": "branch_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"code": {
"name": "code",
"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": false
},
"value": {
"name": "value",
"type": "text",
"primaryKey": false,
"notNull": false
},
"parent_id": {
"name": "parent_id",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"is_active": {
"name": "is_active",
"type": "boolean",
"primaryKey": false,
"notNull": false,
"default": true
},
"sort_order": {
"name": "sort_order",
"type": "integer",
"primaryKey": false,
"notNull": false,
"default": 0
},
"level": {
"name": "level",
"type": "integer",
"primaryKey": false,
"notNull": false,
"default": 0
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"created_by": {
"name": "created_by",
"type": "text",
"primaryKey": false,
"notNull": false
},
"updated_by": {
"name": "updated_by",
"type": "text",
"primaryKey": false,
"notNull": false
},
"deleted_at": {
"name": "deleted_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"ms_options_branch_id_idx": {
"name": "ms_options_branch_id_idx",
"columns": [
{
"expression": "branch_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"ms_options_category_idx": {
"name": "ms_options_category_idx",
"columns": [
{
"expression": "category",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"ms_options_branch_category_idx": {
"name": "ms_options_branch_category_idx",
"columns": [
{
"expression": "branch_id",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "category",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"ms_options_code_idx": {
"name": "ms_options_code_idx",
"columns": [
{
"expression": "code",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
}
},
"enums": {},
"schemas": {},
"sequences": {},
"roles": {},
"policies": {},
"views": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}