// Package migrate exposes the canonical, ordered migration source list for // the application. Each source runs against its own goose ledger table // (goose_db_version_) with its native file numbering, so a source's // version numbers no longer depend on its position in this slice. Ordering // is still meaningful, in three tiers: core first, because every other // schema's FKs point at core (never the reverse); then core-module streams // (currently just `domains`), which FK into core and whose objects // integrations grant on and write; then the integration streams. Within // the integration tier order is insignificant — there are no // integration-to-integration FK edges, so fedwiki and stripe (and any // future integration) may appear in any order relative to each other. // Every caller — app boot, the migrate CLI, and DB-backed tests — must // assemble sources through this package rather than hand-building a subset. package migrate import ( "git.coopcloud.tech/wiki-cafe/member-console/internal/db" "git.coopcloud.tech/wiki-cafe/member-console/internal/domains" "git.coopcloud.tech/wiki-cafe/member-console/internal/integrations" ) // Sources returns every migration source in dependency order: core first, // then the core-module streams, then one source per registered integration // (see internal/integrations.All). The tiers are load-bearing — core owns // the FK targets and core_reader; domains owns registry tables that // integration migrations grant on (fedwiki grants domains_writer to // fedwiki_writer) and that integration runtime code writes — but the // relative order of integrations is insignificant; each runs against its // own version ledger. The core source (internal/db's own baseline) is // prefixed via db.BaseSources(). func Sources() []db.MigrationSource { sources := db.BaseSources() sources = append(sources, domains.MigrationSource()) for _, integ := range integrations.All() { sources = append(sources, integ.MigrationSource()) } return sources }