Repository navigation
Database migrations
Fresh installation and upgrade are intentionally different:
-
fresh install:
./configureloads the currentinstall/mediabot.sqlreference schema; - existing database: back up, inspect drift, apply only required official migrations in order, then require zero strict drift.
The authoritative order is install/migrations/README.md in the exact source being deployed. This page explains the operator workflow; it does not replace that file.
Record the instance, config, database and source revision before changing anything:
cd /home/mediabot/mediabot_v3 || exit 1
git rev-parse --short HEAD
cat VERSION
sudo systemctl status mediabot@dev.service --no-pager -l
perl install/configure_config.pl \
--config mediabot.conf \
--get mysql.MAIN_PROG_DDBNAMEUse the actual instance/config. Stop the selected bot before applying schema changes:
sudo systemctl stop mediabot@dev.serviceUse a privileged local database path without exposing a password in process arguments. Example with the root socket:
sudo install -d -o root -g root -m 700 /var/backups/mediabot
sudo mariadb-dump \
--protocol=socket \
--single-transaction \
--routines \
--triggers \
--events \
--default-character-set=utf8mb4 \
DATABASE_NAME | sudo tee /var/backups/mediabot/pre-upgrade.sql >/dev/null
sudo chmod 600 /var/backups/mediabot/pre-upgrade.sqlReplace DATABASE_NAME only after reading it safely from the selected config. Test the backup on a disposable database for high-risk/long-lived upgrades.
perl tools/check_schema_drift.pl \
--conf=mediabot.conf \
--generate-migration \
--types \
--indexesThe generated plan is evidence, not an instruction to paste blindly. Compare it with the official migration order and the version you are upgrading from.
Current order in the supplied 3.6dev tree:
20260502_channel_ban.sql
20260502_user_seen.sql
mediabot_fun_commands_migration_20260512.sql
20260515_claude_chanset.sql
20260521_trivia_scores_note.sql
20260603_karma_log.sql
20260604_achievement_announce_chanset.sql
20260604_chansets_mb115_mb118.sql
20260706_channel_log_channel_ts.sql
20260707_channel_report_chanset.sql
20260707_didyoumean_chanset.sql
20260707_factoid.sql
20260707_factoids_chanset.sql
20260708_onthisday_chanset.sql
20260708_onthisday_digest_chanset.sql
20260710_quotes_hits.sql
20260724_lang_chansets.sql
20260816_achievements_db.sql
20260822_rss_feeds.sql
20260823_legacy_schema_reconciliation.sql
20260825_wit_chanset.sql
20260827_spark_chanset.sql
20260827_vdm_chanset.sql
20260827_danstonchat_chanset.sql
20260828_spark_action_chanset.sql
20260902_hailo_policy_chansets.sql
20260902_gemini_chanset.sql
20260903_fullop_chanset.sql
20260904_mbweb_sessions.sql
20260905_quotes_512_contract.sql
20260909_quip_chanset.sql
20260911_radio_chanset.sql
Apply only files missing from the source version/schema you are upgrading. Released migrations are immutable history; never edit one to make a local database pass.
Interactive root example:
./install/db_migrate.sh \
DATABASE_NAME \
install/migrations/20260911_radio_chanset.sql \
rootFor automation, use a private non-symlink MariaDB option file with no group/other permissions:
sudo ./install/db_migrate.sh \
--defaults-extra-file /root/.mediabot-mysql.cnf \
DATABASE_NAME \
install/migrations/20260911_radio_chanset.sqlThe helper accepts only SQL files under install/migrations/ and imports them with explicit utf8mb4 settings.
perl tools/check_schema_drift.pl \
--conf=mediabot.conf \
--strict \
--types \
--indexesDo not restart the bot on a non-zero result.
perl -I. -c mediabot.pl
perl t/test_commands.pl --fast --progress
sudo systemctl start mediabot@dev.service
sudo systemctl status mediabot@dev.service --no-pager -l
tail -n 120 /home/mediabot/mediabot_v3/mediabot.logThen confirm !version, !help and affected features on IRC.
-
20260823_legacy_schema_reconciliation.sqlis for long-lived databases predating the canonical schema history. Rehearse it on a clone. -
20260904_mbweb_sessions.sqlcreatesMBWEB_SESSION; it creates no mbweb account or grants. -
20260905_quotes_512_contract.sqlwidens legacy quote text only after fail-closed preconditions. - Chanset migrations register names but do not enable channels.
Rollback means restoring the private pre-upgrade database dump and the previous application tree as one matched pair. A source rollback without a database decision can be unsafe.
Document the exact dump, source revision, config backup and service instance before starting. See Release and upgrade notes.
Mediabot v3 documentation · Home · Installation · Commands · Troubleshooting · GitHub
- Start: notation and parameters
- Public commands
- Complete command reference
- Private and admin commands
- News and RSS
- Quotes and automatic quotes
- Dynamic commands
- AI and Hailo
- Access levels
- Chansets