Files
dbis_core/scripts/verify-column-names.sql
2026-03-02 12:14:07 -08:00

37 lines
1.3 KiB
SQL

-- Verify Database Column Names
-- Run this to check if your database uses snake_case or camelCase
-- This is CRITICAL before running migrations
-- Check ledger_entries columns
SELECT
column_name,
data_type,
is_nullable
FROM information_schema.columns
WHERE table_name = 'ledger_entries'
AND column_name IN ('ledger_id', 'ledgerId', 'reference_id', 'referenceId',
'debit_account_id', 'debitAccountId', 'credit_account_id', 'creditAccountId')
ORDER BY column_name;
-- Check bank_accounts columns
SELECT
column_name,
data_type,
is_nullable
FROM information_schema.columns
WHERE table_name = 'bank_accounts'
AND column_name IN ('available_balance', 'availableBalance',
'reserved_balance', 'reservedBalance',
'currency_code', 'currencyCode')
ORDER BY column_name;
-- Summary: Count matches
SELECT
CASE
WHEN EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'ledger_entries' AND column_name = 'ledger_id')
THEN 'Database uses snake_case (ledger_id)'
WHEN EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'ledger_entries' AND column_name = 'ledgerId')
THEN 'Database uses camelCase (ledgerId)'
ELSE 'Cannot determine - table may not exist'
END as column_naming_convention;