mall数据库文件

This commit is contained in:
comlibmb
2026-01-30 16:11:23 +08:00
parent b53d2376ff
commit cfec4a16c0
71 changed files with 11786 additions and 1009 deletions

View File

@@ -0,0 +1,190 @@
# doc_mall 项目迁移脚本 (PowerShell)
# 用途: 将 doc_mall 模块迁移到新仓库
# 使用: .\migrate.ps1 -TargetPath "C:\path\to\new-repo"
param(
[Parameter(Mandatory = $true)]
[string]$TargetPath,
[Parameter(Mandatory = $false)]
[string]$SourcePath = ".",
[Parameter(Mandatory = $false)]
[switch]$CopySupabaseComponents = $false,
[Parameter(Mandatory = $false)]
[switch]$CopyUtils = $false,
[Parameter(Mandatory = $false)]
[switch]$DryRun = $false
)
Write-Host "===========================================" -ForegroundColor Cyan
Write-Host " doc_mall 项目迁移脚本" -ForegroundColor Cyan
Write-Host "===========================================" -ForegroundColor Cyan
Write-Host ""
# 获取脚本所在目录
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$SourceRoot = Resolve-Path $SourcePath
Write-Host "源项目路径: $SourceRoot" -ForegroundColor Green
Write-Host "目标项目路径: $TargetPath" -ForegroundColor Green
Write-Host ""
# 创建目标目录结构
$Directories = @(
"$TargetPath\doc_mall\analysis",
"$TargetPath\doc_mall\database",
"$TargetPath\doc_mall\reports",
"$TargetPath\pages\mall",
"$TargetPath\types",
"$TargetPath\components\supadb",
"$TargetPath\utils"
)
Write-Host "创建目标目录结构..." -ForegroundColor Yellow
foreach ($dir in $Directories) {
if (-not (Test-Path $dir)) {
if ($DryRun) {
Write-Host " [DRY RUN] 将创建: $dir" -ForegroundColor Gray
}
else {
New-Item -ItemType Directory -Path $dir -Force | Out-Null
Write-Host " ✓ 已创建: $dir" -ForegroundColor Green
}
}
else {
Write-Host " - 已存在: $dir" -ForegroundColor Gray
}
}
Write-Host ""
# 定义需要复制的文件和目录
$CopyItems = @(
@{
Source = "$SourceRoot\doc_mall\*"
Target = "$TargetPath\doc_mall\"
Description = "doc_mall 文档目录"
},
@{
Source = "$SourceRoot\pages\mall\*"
Target = "$TargetPath\pages\mall\"
Description = "pages/mall 页面代码"
},
@{
Source = "$SourceRoot\types\mall-types.uts"
Target = "$TargetPath\types\mall-types.uts"
Description = "类型定义文件"
}
)
# 可选复制项
if ($CopySupabaseComponents) {
$CopyItems += @{
Source = "$SourceRoot\components\supadb\*"
Target = "$TargetPath\components\supadb\"
Description = "Supabase 客户端组件"
}
}
if ($CopyUtils) {
Write-Host "检查需要的工具函数..." -ForegroundColor Yellow
# 扫描 pages/mall 中的 utils 引用
$utilsFiles = Get-ChildItem -Path "$SourceRoot\pages\mall" -Recurse -Filter "*.uvue" |
Select-String -Pattern "from '@/utils" |
ForEach-Object {
if ($_.Line -match "from '@/utils/([^']+)'") {
$matches[1]
}
} | Sort-Object -Unique
foreach ($util in $utilsFiles) {
$utilPath = "$SourceRoot\utils\$util"
if (Test-Path $utilPath) {
Write-Host " 发现依赖: utils/$util" -ForegroundColor Cyan
}
}
}
Write-Host ""
Write-Host "开始复制文件..." -ForegroundColor Yellow
Write-Host ""
$totalFiles = 0
$copiedFiles = 0
$skippedFiles = 0
foreach ($item in $CopyItems) {
$source = $item.Source
$target = $item.Target
$description = $item.Description
Write-Host "处理: $description" -ForegroundColor Cyan
if (-not (Test-Path $source)) {
Write-Host " ✗ 源路径不存在: $source" -ForegroundColor Red
continue
}
if ($DryRun) {
Write-Host " [DRY RUN] 将复制: $source -> $target" -ForegroundColor Gray
$files = Get-ChildItem -Path $source -Recurse -File -ErrorAction SilentlyContinue
$totalFiles += $files.Count
Write-Host " 预计复制 $($files.Count) 个文件" -ForegroundColor Gray
}
else {
try {
# 如果是文件
if (Test-Path $source -PathType Leaf) {
$targetDir = Split-Path -Parent $target
if (-not (Test-Path $targetDir)) {
New-Item -ItemType Directory -Path $targetDir -Force | Out-Null
}
Copy-Item -Path $source -Destination $target -Force
$copiedFiles++
Write-Host " ✓ 已复制文件: $source" -ForegroundColor Green
}
# 如果是目录
else {
$files = Get-ChildItem -Path $source -Recurse -File -ErrorAction SilentlyContinue
$totalFiles += $files.Count
Copy-Item -Path $source -Destination $target -Recurse -Force -ErrorAction Stop
$copiedFiles += $files.Count
Write-Host " ✓ 已复制目录: $($files.Count) 个文件" -ForegroundColor Green
}
}
catch {
Write-Host " ✗ 复制失败: $_" -ForegroundColor Red
$skippedFiles++
}
}
Write-Host ""
}
Write-Host "===========================================" -ForegroundColor Cyan
if ($DryRun) {
Write-Host " [DRY RUN] 预览完成" -ForegroundColor Yellow
Write-Host " 预计复制文件数: $totalFiles" -ForegroundColor Yellow
}
else {
Write-Host " 迁移完成!" -ForegroundColor Green
Write-Host " 已复制文件数: $copiedFiles" -ForegroundColor Green
if ($skippedFiles -gt 0) {
Write-Host " 跳过文件数: $skippedFiles" -ForegroundColor Yellow
}
}
Write-Host "===========================================" -ForegroundColor Cyan
Write-Host ""
if (-not $DryRun) {
Write-Host "后续步骤:" -ForegroundColor Yellow
Write-Host "1. 检查目标目录: $TargetPath" -ForegroundColor White
Write-Host "2. 更新导入路径(如需要)" -ForegroundColor White
Write-Host "3. 配置 Supabase 连接信息" -ForegroundColor White
Write-Host "4. 执行数据库脚本" -ForegroundColor White
Write-Host "5. 运行测试验证" -ForegroundColor White
Write-Host ""
Write-Host "详细步骤请参考: doc_mall/MIGRATION_GUIDE.md" -ForegroundColor Cyan
}

178
mall_sql/scripts/migrate.sh Normal file
View File

@@ -0,0 +1,178 @@
#!/bin/bash
# doc_mall 项目迁移脚本 (Bash)
# 用途: 将 doc_mall 模块迁移到新仓库
# 使用: ./migrate.sh /path/to/new-repo
set -e
# 颜色定义
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# 参数检查
if [ $# -eq 0 ]; then
echo -e "${RED}错误: 请提供目标路径${NC}"
echo "用法: $0 <目标路径> [选项]"
echo "选项:"
echo " --copy-supabase 复制 Supabase 组件"
echo " --copy-utils 复制工具函数"
echo " --dry-run 预览模式,不实际复制"
exit 1
fi
TARGET_PATH="$1"
SOURCE_PATH="${2:-.}"
COPY_SUPABASE=false
COPY_UTILS=false
DRY_RUN=false
# 解析选项
shift
while [[ $# -gt 0 ]]; do
case $1 in
--copy-supabase)
COPY_SUPABASE=true
shift
;;
--copy-utils)
COPY_UTILS=true
shift
;;
--dry-run)
DRY_RUN=true
shift
;;
*)
echo -e "${RED}未知选项: $1${NC}"
exit 1
;;
esac
done
# 获取脚本所在目录
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SOURCE_ROOT="$( cd "$SOURCE_PATH" && pwd )"
echo -e "${CYAN}===========================================${NC}"
echo -e "${CYAN} doc_mall 项目迁移脚本${NC}"
echo -e "${CYAN}===========================================${NC}"
echo ""
echo -e "${GREEN}源项目路径: $SOURCE_ROOT${NC}"
echo -e "${GREEN}目标项目路径: $TARGET_PATH${NC}"
echo ""
# 创建目标目录结构
DIRECTORIES=(
"$TARGET_PATH/doc_mall/analysis"
"$TARGET_PATH/doc_mall/database"
"$TARGET_PATH/doc_mall/reports"
"$TARGET_PATH/pages/mall"
"$TARGET_PATH/types"
"$TARGET_PATH/components/supadb"
"$TARGET_PATH/utils"
)
echo -e "${YELLOW}创建目标目录结构...${NC}"
for dir in "${DIRECTORIES[@]}"; do
if [ ! -d "$dir" ]; then
if [ "$DRY_RUN" = true ]; then
echo -e " ${YELLOW}[DRY RUN]${NC} 将创建: $dir"
else
mkdir -p "$dir"
echo -e " ${GREEN}${NC} 已创建: $dir"
fi
else
echo -e " - 已存在: $dir"
fi
done
echo ""
# 复制函数
copy_item() {
local source="$1"
local target="$2"
local description="$3"
echo -e "${CYAN}处理: $description${NC}"
if [ ! -e "$source" ]; then
echo -e " ${RED}${NC} 源路径不存在: $source"
return 1
fi
if [ "$DRY_RUN" = true ]; then
if [ -f "$source" ]; then
echo -e " ${YELLOW}[DRY RUN]${NC} 将复制文件: $source -> $target"
else
file_count=$(find "$source" -type f 2>/dev/null | wc -l)
echo -e " ${YELLOW}[DRY RUN]${NC} 将复制目录: $source -> $target"
echo -e " 预计复制 $file_count 个文件"
fi
return 0
fi
if [ -f "$source" ]; then
target_dir=$(dirname "$target")
mkdir -p "$target_dir"
cp "$source" "$target"
echo -e " ${GREEN}${NC} 已复制文件"
else
file_count=$(find "$source" -type f 2>/dev/null | wc -l)
cp -r "$source" "$target"
echo -e " ${GREEN}${NC} 已复制目录: $file_count 个文件"
fi
echo ""
}
# 复制必需文件
echo -e "${YELLOW}开始复制文件...${NC}"
echo ""
copy_item "$SOURCE_ROOT/doc_mall" "$TARGET_PATH/doc_mall" "doc_mall 文档目录"
copy_item "$SOURCE_ROOT/pages/mall" "$TARGET_PATH/pages/mall" "pages/mall 页面代码"
copy_item "$SOURCE_ROOT/types/mall-types.uts" "$TARGET_PATH/types/mall-types.uts" "类型定义文件"
# 可选复制项
if [ "$COPY_SUPABASE" = true ]; then
copy_item "$SOURCE_ROOT/components/supadb" "$TARGET_PATH/components/supadb" "Supabase 客户端组件"
fi
if [ "$COPY_UTILS" = true ]; then
echo -e "${YELLOW}检查需要的工具函数...${NC}"
# 查找 pages/mall 中的 utils 引用
if [ -d "$SOURCE_ROOT/pages/mall" ]; then
grep -r "from '@/utils" "$SOURCE_ROOT/pages/mall" --include="*.uvue" | \
sed -n "s/.*from '\(@\/utils\/[^']*\)'.*/\1/p" | \
sort -u | while read -r util_ref; do
util_file=$(echo "$util_ref" | sed "s/@\/utils\///")
util_path="$SOURCE_ROOT/utils/$util_file"
if [ -f "$util_path" ]; then
echo -e " ${CYAN}发现依赖: utils/$util_file${NC}"
fi
done
fi
echo ""
fi
echo -e "${CYAN}===========================================${NC}"
if [ "$DRY_RUN" = true ]; then
echo -e "${YELLOW} [DRY RUN] 预览完成${NC}"
else
echo -e "${GREEN} 迁移完成!${NC}"
fi
echo -e "${CYAN}===========================================${NC}"
echo ""
if [ "$DRY_RUN" = false ]; then
echo -e "${YELLOW}后续步骤:${NC}"
echo "1. 检查目标目录: $TARGET_PATH"
echo "2. 更新导入路径(如需要)"
echo "3. 配置 Supabase 连接信息"
echo "4. 执行数据库脚本"
echo "5. 运行测试验证"
echo ""
echo -e "${CYAN}详细步骤请参考: doc_mall/MIGRATION_GUIDE.md${NC}"
fi