Friend Import & Mapping
Overview
There are two mechanisms for bringing external data in and attaching it to LINE friends.
- LINE user import — upload a CSV containing LINE userIds to create new rows in
line_user. Used when migrating from another system, or when a list of userIds already exists. - Import mapping — upload a CSV of customer data and map it onto friends who already exist, matching on a chosen key such as
mobile_noor a key of the formcustom.<key>.
Both run asynchronously in worker-go and record their outcome statistics in JSONB columns.
Core Data Structure
line_user_import (model LineUserImport)
One row per uploaded file, holding title, file_name, file_path, archive_path along with the progress counters total_records, total_processed and process_attempt.
Job state lives in status (enum LineUserImportStatus: new, processing, completed, failed), accompanied by summary_stats JSONB, note, line_oa_id and organization_id.
line_user_import_detail (model LineUserImportDetail)
One row per CSV line, keyed by UUID and linked back through import_id (FK to line_user_import.id).
It stores line_user_id (the LINE userId read from the file), line_user_profile JSONB, status (enum LineUserImportDetailStatus: new, insert, exist, undefined, error_format) and error_message.
import_mapping_job
Created through manual SQL only and absent from Prisma, this table drives the import-mapping flow.
file_name,file_pathandstatus(pending,processing,success,partial,failed)unique_keyJSONB — the matching key, e.g.{"field":"mobile_no","csvColumn":"Phone Number"}mappingsJSONB — the column-to-target mapping, e.g.[{"csvColumn":"Member Tier","target":"custom.member_tier"}]validationJSONB — the pre-import dry run summarising total, willUpdate, noMatch, errors and their reasonsstatsJSONB — the actual post-run results, pluserror_log_pathfor downloading the log- Index on
(line_oa_id, status)
The migration that creates this table also registers the import-mapping module into system_module, system_role_module and organization_module.
Related Files
prisma/schema.prisma:716— modelLineUserImportprisma/schema.prisma:742— modelLineUserImportDetailmanual-sql/9.import_mapping.sql— createsimport_mapping_joband grants the module permissionsschema-dumps/2026-07-24/schema.sql:2281,:2306and:1984
Connections to Other Services
- cms-api-go — accepts the upload, creates the job, renders the result summary, and serves the error log download.
- worker-go — processes the
import_mapping_jobqueue and LINE user import jobs, writing results back intoline_user. During bulk updates it setsapp.skip_triggers='true'so theattribute_changedtrigger does not fire on every row. - The destination of all this data is LINE Friends, and the mapping keys reference definitions in Attribute Definitions.