Your application is deployed and running, but database schema naming convention issues are preventing it from working:
❌ Issue Identified:
- Prisma schema was using camelCase (
botToken,isConnected) - Database expects snake_case (
bot_token,is_connected) - This has been FIXED in the Prisma schema
Now you need to update the database columns
- Open your Supabase project dashboard
- Navigate to SQL Editor in the left sidebar
- Click "New query" to create a new SQL script
Copy the entire script below and paste it into the SQL Editor:
-- Fix for OBS Telegram Bot Database Schema
-- Updated to use consistent snake_case naming convention
-- Add missing columns to bot_configurations table
ALTER TABLE bot_configurations
ADD COLUMN IF NOT EXISTS bot_token VARCHAR(500),
ADD COLUMN IF NOT EXISTS bot_username VARCHAR(255),
ADD COLUMN IF NOT EXISTS webhook_url VARCHAR(500),
ADD COLUMN IF NOT EXISTS is_webhook_enabled BOOLEAN DEFAULT FALSE,
ADD COLUMN IF NOT EXISTS welcome_message TEXT DEFAULT 'Welcome to OBS Control Bot! Use /help to see available commands.',
ADD COLUMN IF NOT EXISTS admin_only_commands BOOLEAN DEFAULT TRUE;
-- Add missing columns to obs_connections table
ALTER TABLE obs_connections
ADD COLUMN IF NOT EXISTS is_connected BOOLEAN DEFAULT FALSE,
ADD COLUMN IF NOT EXISTS last_connected_at TIMESTAMP;
-- Add missing columns to scenes table (if needed)
ALTER TABLE scenes
ADD COLUMN IF NOT EXISTS scene_id VARCHAR(255),
ADD COLUMN IF NOT EXISTS is_active BOOLEAN DEFAULT FALSE;
-- Add missing columns to sources table (if needed)
ALTER TABLE sources
ADD COLUMN IF NOT EXISTS source_id VARCHAR(255),
ADD COLUMN IF NOT EXISTS source_type VARCHAR(100),
ADD COLUMN IF NOT EXISTS scene_id INT,
ADD COLUMN IF NOT EXISTS is_visible BOOLEAN DEFAULT TRUE,
ADD COLUMN IF NOT EXISTS is_enabled BOOLEAN DEFAULT TRUE;
-- Add missing columns to command_histories table (if needed)
ALTER TABLE command_histories
ADD COLUMN IF NOT EXISTS parameters TEXT,
ADD COLUMN IF NOT EXISTS response TEXT,
ADD COLUMN IF NOT EXISTS status VARCHAR(50) DEFAULT 'pending',
ADD COLUMN IF NOT EXISTS execution_time INT;
-- Add missing columns to stream_sessions table (if needed)
ALTER TABLE stream_sessions
ADD COLUMN IF NOT EXISTS stream_key VARCHAR(500),
ADD COLUMN IF NOT EXISTS stream_url VARCHAR(1000),
ADD COLUMN IF NOT EXISTS is_streaming BOOLEAN DEFAULT FALSE,
ADD COLUMN IF NOT EXISTS started_at TIMESTAMP,
ADD COLUMN IF NOT EXISTS ended_at TIMESTAMP,
ADD COLUMN IF NOT EXISTS duration INT;
-- Create the application_logs table if it doesn't exist
CREATE TABLE IF NOT EXISTS application_logs (
id SERIAL PRIMARY KEY,
level VARCHAR(20) DEFAULT 'INFO',
component VARCHAR(50) NOT NULL,
message TEXT NOT NULL,
details TEXT,
user_id INT,
session_id VARCHAR(255),
created_at TIMESTAMP DEFAULT NOW()
);
-- Create indexes for better performance
CREATE INDEX IF NOT EXISTS idx_application_logs_level ON application_logs(level);
CREATE INDEX IF NOT EXISTS idx_application_logs_component ON application_logs(component);
CREATE INDEX IF NOT EXISTS idx_application_logs_created_at ON application_logs(created_at);
CREATE INDEX IF NOT EXISTS idx_application_logs_user_id ON application_logs(user_id);
-- Verify the changes by listing the tables
SELECT table_name, column_name, data_type, is_nullable, column_default
FROM information_schema.columns
WHERE table_name IN ('bot_configurations', 'obs_connections', 'application_logs')
ORDER BY table_name, ordinal_position;- Click "Run" or press Ctrl+Enter to execute the script
- Wait for the execution to complete (should take a few seconds)
- You should see the results showing the updated table structure
After execution, you should see output showing all the new columns with snake_case names:
table_name | column_name | data_type | is_nullable | column_default
---------------------+------------------------+-------------------+-------------+----------------
bot_configurations | id | integer | NO | nextval(...)
bot_configurations | created_at | timestamp | NO | now()
bot_configurations | updated_at | timestamp | NO | now()
bot_configurations | bot_token | character varying | YES | NULL
bot_configurations | bot_username | character varying | YES | NULL
bot_configurations | webhook_url | character varying | YES | NULL
bot_configurations | is_webhook_enabled | boolean | YES | false
bot_configurations | welcome_message | text | YES | Welcome to...
bot_configurations | admin_only_commands | boolean | YES | true
obs_connections | id | integer | NO | nextval(...)
obs_connections | created_at | timestamp | NO | now()
obs_connections | updated_at | timestamp | NO | now()
obs_connections | name | text | NO | NULL
obs_connections | host | text | NO | NULL
obs_connections | port | integer | NO | NULL
obs_connections | password | text | YES | NULL
obs_connections | is_connected | boolean | YES | false
obs_connections | last_connected_at | timestamp | YES | NULL
application_logs | id | integer | NO | nextval(...)
application_logs | level | character varying | YES | INFO
application_logs | component | character varying | NO | NULL
application_logs | message | text | NO | NULL
application_logs | details | text | YES | NULL
application_logs | user_id | integer | YES | NULL
application_logs | session_id | character varying | YES | NULL
application_logs | created_at | timestamp | NO | now()
✅ Prisma Schema Updated:
- Changed all camelCase field names to snake_case
botToken→bot_tokenisConnected→is_connectedlastConnectedAt→last_connected_at- And all other fields consistently
✅ SQL Script Updated:
- Now adds ALL missing columns with correct snake_case names
- Creates the
application_logstable with proper indexes - Includes comprehensive schema fixes for all tables
Once you execute this SQL script:
✅ Bot Configuration will work:
- You can save your bot token:
7821790748:AAHyjGAZqt6MQqwt_KM8QIrQ66aV5_buroI - Bot will start running automatically
- Telegram commands will be functional
✅ OBS Connections will work:
- You can add OBS connections (103.167.123.195:4455)
- Connection status will be tracked properly
- OBS controls will be functional
✅ Complete Logging System will be active:
- All operations will be logged
- You can monitor activity in the Logs tab
- Real-time monitoring will work
This is normal - the IF NOT EXISTS clause handles this safely. The script will continue executing.
Make sure you're executing with the correct database role (usually postgres or supabase_admin).
This is a comprehensive script that adds many columns and creates indexes. It may take 10-30 seconds to complete.
-
Test Bot Configuration:
- Go to your Vercel app
- Enter your bot token and save
- Verify bot starts running
-
Test OBS Connection:
- Add your OBS connection (103.167.123.195:4455)
- Test the connection
- Verify it shows as connected
-
Monitor Logs:
- Check the Logs tab for real-time activity
- Verify all operations are being logged
If you encounter any issues:
- Take a screenshot of the error in Supabase SQL Editor
- Check the Vercel function logs for any database errors
- Run the diagnostics again to verify the fix