Database Migration
Database Migration updates the database schema to add new tables, columns, and features required by the admin panel.
What It Doesโ
The Database Migration:
- Checks which migrations have already run
- Adds new tables if needed
- Adds new columns to existing tables
- Creates indexes for performance
- Reports what was added or updated
When to Useโ
Required Timesโ
Run the migration:
- First-time setup: When setting up the admin panel initially
- After code updates: When you've pulled new code that requires database changes
- New feature deployment: When release notes mention database changes
Safe to Run Multiple Timesโ
The migration is idempotent - it checks what already exists before making changes. Running it multiple times won't cause problems.
What Gets Addedโ
The Admin Features Migration includes:
New Tablesโ
| Table | Purpose |
|---|---|
| admin_activity_log | Tracks all admin actions (edits, deletes, etc.) |
| cache_hit_log | Records when cached responses are served |
New Columns on cached_responsesโ
| Column | Purpose |
|---|---|
| positive_feedback | Count of thumbs up |
| negative_feedback | Count of thumbs down |
| neutral_feedback | Count of neutral feedback |
| created_by | Admin who created the entry |
| admin_notes | Internal notes |
| source_conversation_ids | Links to source conversations |
Indexesโ
Performance indexes on frequently queried columns like:
- Feedback columns
- Timestamps
- Status fields
How to Useโ
Before Runningโ
This modifies your database schema. Only run if:
- You're setting up the admin panel for the first time
- You've pulled new code that requires database changes
- You understand what migrations do
Running the Migrationโ
- Go to the Maintenance page
- Find the Database Migrations section
- Click Run Admin Features Migration
- Confirm the action in the popup
- Wait for results to appear
Understanding Resultsโ
The output panel shows what happened:
๐๏ธ Running admin features migration...
โ
Migration completed successfully
- Created table: admin_activity_log
- Created table: cache_hit_log
- Added columns to cached_responses
- Created 5 indexes
Or if already run:
โ
Migration completed successfully
- All tables already exist
- All columns already present
- No changes needed
After Runningโ
Verify Successโ
- Check the output for errors
- The result should show "Migration completed"
- Test admin features to confirm they work
If Errors Occurโ
- Read the error message carefully
- Common issues: permission problems, connection issues
- Contact technical support if needed
Frequently Asked Questionsโ
Can I run this multiple times?โ
Yes! The migration checks what exists before making changes. Running it multiple times is safe.
Will I lose data?โ
No. The migration only adds tables and columns. It doesn't delete or modify existing data.
Do I need to back up first?โ
It's always good practice to have backups, but this migration is non-destructive. It only adds new structures.
How long does it take?โ
Usually just a few seconds. The migration is quick because it's only adding structures, not processing data.
What if it fails?โ
- Note the error message
- Try running again (sometimes connection issues are temporary)
- Contact technical support if problems persist
Technical Detailsโ
For technical staff, the migration:
- Uses
IF NOT EXISTSclauses - Creates tables with proper foreign keys
- Adds columns only if they don't exist
- Creates indexes for query performance
This ensures safe, repeatable execution.
Related: