-- CreateTable (merged from create_tool_c_session.sql for shadow database compatibility)
CREATE TABLE IF NOT EXISTS "dc_schema"."dc_tool_c_sessions" (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  user_id VARCHAR(255) NOT NULL,
  file_name VARCHAR(500) NOT NULL,
  file_key VARCHAR(500) NOT NULL,
  total_rows INTEGER NOT NULL,
  total_cols INTEGER NOT NULL,
  columns JSONB NOT NULL,
  encoding VARCHAR(50),
  file_size INTEGER NOT NULL,
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  expires_at TIMESTAMP NOT NULL
);

CREATE INDEX IF NOT EXISTS idx_dc_tool_c_sessions_user_id ON "dc_schema"."dc_tool_c_sessions"(user_id);
CREATE INDEX IF NOT EXISTS idx_dc_tool_c_sessions_expires_at ON "dc_schema"."dc_tool_c_sessions"(expires_at);

-- AlterTable
-- 添加 column_mapping 字段到 dc_tool_c_sessions 表
-- 用于解决表头特殊字符问题

ALTER TABLE "dc_schema"."dc_tool_c_sessions" 
ADD COLUMN IF NOT EXISTS "column_mapping" JSONB;

-- 添加注释
COMMENT ON COLUMN "dc_schema"."dc_tool_c_sessions"."column_mapping" IS '列名映射：[{originalName, safeName, displayName}] 解决特殊字符问题';





































































