// Package linkstore is what is left of Docs' own Home link store: the // migrations every Docs database has already applied. Docs links Home // identities through home/connect now, in connect's home_identity_links, // and moves this package's rows there once, at boot // (internal/docs/home_links_move.go), dropping these tables as it does. // // The migrations stay because they are in every database's ledger // (migrations are immutable once applied), and because a new database // still creates docs_identity_links on the way: principalstore's first // migration puts a trigger on it, which the move then re-points. package linkstore import ( "embed" "io/fs" "amadan.net/rastrillo/rastrillo/migrate" ) //go:embed migrations/*.sql var migrations embed.FS // Schema is the applied docs_identity_link set, unchanged. var Schema = migrate.MustFromFS(migrations, "docs_identity_link") //go:embed principals/migrations/*.sql var forPrincipals embed.FS // ForPrincipals goes immediately before principalstore.Schema, and only in // the team schema. A database that moved its links onto connect while team // mode was off has no docs_identity_links, and principalstore's first // migration cannot create its trigger on a missing table, so turning team // mode on later would refuse to boot. This puts the old table back, empty, // for that one migration; the move at boot re-points the trigger and drops // it again. Wherever the table still exists it does nothing. var ForPrincipals = migrate.MustFromFS(mustSub(forPrincipals, "principals"), "docs_identity_link_principals") func mustSub(f fs.FS, dir string) fs.FS { sub, err := fs.Sub(f, dir) if err != nil { panic(err) } return sub }