Skip to main content

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:

  1. Checks which migrations have already run
  2. Adds new tables if needed
  3. Adds new columns to existing tables
  4. Creates indexes for performance
  5. 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โ€‹

TablePurpose
admin_activity_logTracks all admin actions (edits, deletes, etc.)
cache_hit_logRecords when cached responses are served

New Columns on cached_responsesโ€‹

ColumnPurpose
positive_feedbackCount of thumbs up
negative_feedbackCount of thumbs down
neutral_feedbackCount of neutral feedback
created_byAdmin who created the entry
admin_notesInternal notes
source_conversation_idsLinks to source conversations

Indexesโ€‹

Performance indexes on frequently queried columns like:

  • Feedback columns
  • Timestamps
  • Status fields

How to Useโ€‹

Before Runningโ€‹

Understand the Impact

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โ€‹

  1. Go to the Maintenance page
  2. Find the Database Migrations section
  3. Click Run Admin Features Migration
  4. Confirm the action in the popup
  5. 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 EXISTS clauses
  • 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: