Skip to content

Ansible: migrate an empty database with -fresh - #352

Merged
rufuspollock merged 1 commit into
mainfrom
fix-fresh-install-migrate
Nov 5, 2026
Merged

rufuspollock merged 1 commit into
mainfrom
fix-fresh-install-migrate

Conversation

@rufuspollock

Copy link
Copy Markdown
Member

Fixes the new-install gap documented in #350: the playbook's plain migrate seeded Datopian's records into a fresh database.

  • control_api role counts applied migrations; zero (or no schema_migrations table) → wg-migrate -fresh.
  • New default migrate_on_empty_database: fresh; seed keeps the old behaviour.
  • Populated databases (Datopian staging/production) migrate exactly as before.
  • getting-started: workaround removed.

Tests and evidence

  • ansible-playbook --syntax-check site.yml passes.
  • Decision tasks run locally against simulated psql results: no table → -fresh; 0 rows → -fresh; 89 applied → plain; connection error → plain; seed mode → plain.
  • Not yet run on a real empty host. The next staging deploy exercises the populated path (count > 0 → plain).

Security and permission impact

Reduces disclosure risk: a new deployment no longer receives Datopian's people and client records. No new permissions. No bead (no local Beads DB).

On a new deployment the playbook ran a plain migrate, which applies the
seed migrations and installs Datopian's organisation, people, projects
and repositories into somebody else's database. The role now counts the
applied migrations first and passes -fresh when there are none.

migrate_on_empty_database (default fresh; 'seed' keeps the old
behaviour) decides what an empty database gets. A database with any
migration applied is migrated exactly as before, so existing
deployments are unaffected. Only a missing schema_migrations table or a
zero count reads as empty; any other psql failure falls through to the
plain migrate, and -fresh itself refuses a populated database.

Checked: ansible-playbook --syntax-check on site.yml, and the decision
tasks run locally against five simulated psql results (no table, zero
rows, 89 applied, connection failure, seed mode).

getting-started: drop the --skip-tags workaround; step 4 is just wg-init.
@coderabbitai

coderabbitai Bot commented Nov 5, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9479b964-5343-4f85-b0fb-09dfb06be450
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@rufuspollock
rufuspollock merged commit d6d10ba into main Nov 5, 2026
6 of 7 checks passed
@rufuspollock
rufuspollock deleted the fix-fresh-install-migrate branch November 5, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant