summaryrefslogtreecommitdiff
path: root/lib/oracle-db/nonsap/run-generate-schema.sh
blob: b2e215ae71af3de25c595f1dd16ee5390eee5f70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash

# NonSAP Oracle to PostgreSQL 스키마 생성 스크립트

echo "🚀 NonSAP Oracle to PostgreSQL Schema Generation"
echo "================================================"

# 현재 디렉토리 확인
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"

echo "📍 Working directory: $SCRIPT_DIR"

# CSV 파일 존재 확인
if [ ! -f "1.table-and-columns-info.csv" ]; then
    echo "❌ Error: 1.table-and-columns-info.csv not found"
    exit 1
fi

echo "✅ Found CSV file: 1.table-and-columns-info.csv"

# 1. Oracle TypeScript 타입 생성
echo ""
echo "📝 Step 1: Generating Oracle TypeScript types..."
if command -v python3 &> /dev/null; then
    python3 2.generate-oracle-types.py
    if [ $? -eq 0 ]; then
        echo "✅ Oracle TypeScript types generated successfully"
    else
        echo "❌ Failed to generate Oracle TypeScript types"
        exit 1
    fi
else
    echo "❌ Error: Python3 not found. Please install Python3"
    exit 1
fi

# 2. PostgreSQL Drizzle 스키마 생성
echo ""
echo "🐘 Step 2: Generating PostgreSQL Drizzle schema..."
if command -v npx &> /dev/null; then
    npx tsx 3.generate-postgres-drizzle-schema.ts
    if [ $? -eq 0 ]; then
        echo "✅ PostgreSQL Drizzle schema generated successfully"
    else
        echo "❌ Failed to generate PostgreSQL Drizzle schema"
        exit 1
    fi
else
    echo "❌ Error: npx not found. Please install Node.js and npm"
    exit 1
fi

echo ""
echo "🎉 Schema generation completed!"
echo ""
echo "📄 Generated files:"
echo "  - oracle-schema.ts (TypeScript types)"
echo "  - schema.ts (Drizzle schema)"
echo ""
echo "💡 Usage:"
echo "  import { Table } from './oracle-schema';"
echo "  import { cmctbVendorGeneral } from './schema';"