4.0 KiB
4.0 KiB
Chart of Accounts Migration - Ready to Run
✅ Status: All Files Prepared
The Chart of Accounts migration and initialization scripts are ready. You need to provide database connection information to proceed.
📋 What's Ready
- ✅ Prisma Model:
ChartOfAccountadded to schema - ✅ Migration Script:
scripts/run-chart-of-accounts-migration.sh - ✅ Initialization Script:
scripts/initialize-chart-of-accounts.ts - ✅ Prisma Client: Generated (includes ChartOfAccount model)
🚀 To Run Migration
Option 1: Set DATABASE_URL Environment Variable
cd /home/intlc/projects/proxmox/dbis_core
# Set DATABASE_URL (replace with your actual connection string)
export DATABASE_URL="postgresql://user:password@host:port/database"
# Run the migration script
./scripts/run-chart-of-accounts-migration.sh
Option 2: Create .env File
cd /home/intlc/projects/proxmox/dbis_core
# Create .env file
cat > .env << EOF
DATABASE_URL=postgresql://user:password@host:port/database
EOF
# Run the migration script
./scripts/run-chart-of-accounts-migration.sh
Option 3: Manual Steps
cd /home/intlc/projects/proxmox/dbis_core
# 1. Set DATABASE_URL
export DATABASE_URL="postgresql://user:password@host:port/database"
# 2. Generate Prisma client (already done, but can re-run)
npx prisma generate
# 3. Create and apply migration
npx prisma migrate dev --name add_chart_of_accounts
# 4. Initialize accounts
ts-node scripts/initialize-chart-of-accounts.ts
🔗 Database Connection Examples
Local Development
export DATABASE_URL="postgresql://postgres:password@localhost:5432/dbis_core"
Production (Based on Deployment Docs)
export DATABASE_URL="postgresql://dbis:8cba649443f97436db43b34ab2c0e75b5cf15611bef9c099cee6fb22cc3d7771@192.168.11.100:5432/dbis_core"
✅ What the Script Does
- Generates Prisma Client - Updates client with ChartOfAccount model
- Creates Migration - Creates SQL migration file for
chart_of_accountstable - Applies Migration - Runs the migration against your database
- Initializes Accounts - Creates 50+ standard accounts with USGAAP/IFRS classifications
📊 Expected Output
After successful run, you should see:
==========================================
Chart of Accounts Migration & Setup
==========================================
Step 1: Generating Prisma client...
✔ Generated Prisma Client
Step 2: Creating migration...
✔ Migration created and applied
Step 3: Initializing Chart of Accounts...
Initializing Chart of Accounts...
✅ Chart of Accounts initialized successfully!
✅ Total accounts created: 50+
📊 Account Summary:
Assets: 15+
Liabilities: 8+
Equity: 6+
Revenue: 5+
Expenses: 8+
==========================================
✅ Chart of Accounts setup complete!
==========================================
🔍 Verification
After migration, verify accounts were created:
# Via Prisma Studio (GUI)
npx prisma studio
# Via SQL
psql $DATABASE_URL -c "SELECT COUNT(*) FROM chart_of_accounts;"
psql $DATABASE_URL -c "SELECT account_code, account_name, category FROM chart_of_accounts WHERE level = 1 ORDER BY account_code;"
⚠️ Important Notes
- Database Must Exist: Ensure the database exists before running migration
- Connection Required: You need network access to the database
- Permissions: Database user needs CREATE TABLE and INSERT permissions
- Backup: Consider backing up database before migration (if production)
🐛 Troubleshooting
"DATABASE_URL not found"
- Set
export DATABASE_URL="..."or create.envfile
"Migration already exists"
- If partially applied:
npx prisma migrate resolve --applied add_chart_of_accounts - Or reset (⚠️ deletes data):
npx prisma migrate reset
"Cannot connect to database"
- Check database is running
- Verify connection string is correct
- Check network/firewall settings
Ready to run! Just provide the DATABASE_URL and execute the script.