| 1 | package home |
| 2 | |
| 3 | import ( |
| 4 | "embed" |
| 5 | |
| 6 | "amadan.net/rastrillo/rastrillo/migrate" |
| 7 | "amadan.net/rastrillo/rastrillo/passkey" |
| 8 | "amadan.net/rastrillo/rastrillo/sessions" |
| 9 | ) |
| 10 | |
| 11 | //go:embed migrations/*.sql |
| 12 | var migrationsFS embed.FS |
| 13 | |
| 14 | // Schema is this app's own migrations: forward-only, ledgered by ID and |
| 15 | // checksum, named migrations/NNNN_lowercase_name.sql. |
| 16 | var Schema = migrate.MustFromFS(migrationsFS, "home") |
| 17 | |
| 18 | // BootSchema is everything applied at boot. |
| 19 | // |
| 20 | // rastrillo/auth's schema is deliberately absent. This app does not use |
| 21 | // that package — sign-in is hand-rolled on keymaildev/signin — and |
| 22 | // auth's tables hold addresses, which must never be created here. An |
| 23 | // app that merged auth.Schema "just in case" would create an address |
| 24 | // column that gate 2's schema half cannot see, because that gate reads |
| 25 | // this repo's migrations and auth's are a dependency's. |
| 26 | // |
| 27 | // sessions.Schema carries no address either: its columns are token_hash, |
| 28 | // subject, method, auth_time, created_at, expires_at. What goes INTO |
| 29 | // subject is the part that matters — it must be the person ref, never |
| 30 | // the address — and that is enforced where sessions are minted, not |
| 31 | // here. |
| 32 | // passkey.Schema is not optional once the Gate is wired: Gate INSERTs |
| 33 | // into passkey_pending on the first enrolled sign-in, so omitting it |
| 34 | // fails at the database rather than at boot. |
| 35 | // |
| 36 | // All four passkey tables key on subject, which here is already the |
| 37 | // person ref — so the worry about inheriting an address-bearing subject |
| 38 | // does not arise. Said here rather than left to be rediscovered. |
| 39 | var BootSchema = migrate.Merge(sessions.Schema, passkey.Schema, Schema) |
| 40 | |