Migrate from Teldrive v1
Migrate a legacy v1 PostgreSQL database to the v2 schema.
Teldrive v2 detects v1 by the legacy public.goose_db_version table.
Before migration
- stop v1 writes;
- back up PostgreSQL;
- keep the old binary/image and configuration;
- configure a stable v2
security.data-key.
Enable migration
Default:
database:
auto-migrate-legacy: trueBoth teldrive run and teldrive check can trigger migration during initialization.
Requirements:
- v1 and v2 use the same PostgreSQL database;
- final v2 schema is
teldrive; security.data-keyis configured;- the database user can create/rename schemas and migrate data.
What it creates
The migrator takes an advisory lock and stages the conversion in separate schemas:
legacy source
↓
teldrive_v2_staging_<timestamp>
↓ validate/swap
teldrive
teldrive_legacy_backup_<timestamp>The legacy schema is preserved under teldrive_legacy_backup_* after a successful swap.
Run migration
teldrive check --config /etc/teldrive/config.tomlor:
docker compose run --rm teldrive checkCheck logs for database.legacy_migration.completed and the reported row counts.
Verify
After starting v2, verify users, channels, bots, folder structure, files, and known downloads. Keep the legacy backup schema until you also have a separate tested PostgreSQL backup.
Disable automatic migration
database:
auto-migrate-legacy: falseWith this setting, detecting v1 fails initialization instead of migrating it.
Rollback
Restore the pre-migration PostgreSQL backup and old application version/configuration. Do not reuse a partially migrated database as a rollback plan.