| 1 | // Package store holds Base's members and app installs. |
| 2 | package store |
| 3 | |
| 4 | import ( |
| 5 | "embed" |
| 6 | |
| 7 | "amadan.net/oficina/home/connect/linkstore" |
| 8 | "amadan.net/oficina/home/handoff" |
| 9 | "amadan.net/rastrillo/rastrillo/auth" |
| 10 | "amadan.net/rastrillo/rastrillo/migrate" |
| 11 | "amadan.net/rastrillo/rastrillo/passkey" |
| 12 | "amadan.net/rastrillo/rastrillo/pow" |
| 13 | "amadan.net/rastrillo/rastrillo/sessions" |
| 14 | ) |
| 15 | |
| 16 | //go:embed migrations/*.sql |
| 17 | var migrationFS embed.FS |
| 18 | |
| 19 | // Schema holds only Base's own tables. |
| 20 | var Schema = migrate.MustFromFS(migrationFS, "base") |
| 21 | |
| 22 | // BootSchema adds the framework tables the sign-in flow needs: sessions, |
| 23 | // email links, the sign-in form's proof and passkeys. |
| 24 | var BootSchema = migrate.Merge(sessions.Schema, auth.Schema, pow.Schema, passkey.Schema, Schema) |
| 25 | |
| 26 | // HomeSchema is what Oficina ID sign-in adds: the hand-off exchange and the |
| 27 | // account links, in the namespaces every Oficina app uses for them. |
| 28 | var HomeSchema = migrate.Merge( |
| 29 | migrate.MustFromFS(handoff.Migrations, "oficina_handoff"), |
| 30 | migrate.MustFromFS(linkstore.Migrations, linkstore.SchemaNamespace), |
| 31 | ) |
| 32 | |
| 33 | // Boot is the schema to apply at start-up: BootSchema, and HomeSchema too |
| 34 | // when Oficina ID sign-in is on. |
| 35 | func Boot(home bool) *migrate.Set { |
| 36 | if home { |
| 37 | return migrate.Merge(BootSchema, HomeSchema) |
| 38 | } |
| 39 | return BootSchema |
| 40 | } |
| 41 | |