oficina / slides Public

Clone
git clone https://amadan.net/oficina/slides

Plain git — no account needed to clone.

Download

Download this file

1package slides
2
3import (
4 "amadan.net/oficina/home/dashboard"
5 "embed"
6
7 rauth "amadan.net/rastrillo/rastrillo/auth"
8 "amadan.net/rastrillo/rastrillo/migrate"
9 "amadan.net/rastrillo/rastrillo/sessions"
10)
11
12//go:embed migrations/*.sql
13var migrationFS embed.FS
14
15// Schema is this app's own migrations, in order — nothing else. It is
16// what `rastrillo migration generate` and `rastrillo migration check` read
17// and write: both work by replaying a set into an in-memory database
18// and diffing the result against Models, so Schema must never carry a
19// framework subsystem's migrations too — mixed in, the diff would see
20// tables (sessions, auth_links, ...) that Models knows nothing about
21// and want to drop every one of them.
22//
23// Add to it with `rastrillo migration generate` after changing a
24// model, or `rastrillo migration new <name>` to write one by hand.
25// Migrations apply at boot and are never re-run or reversed: never
26// edit one that has shipped, add a new one instead.
27var Schema = migrate.MustFromFS(migrationFS, "slides")
28
29// BootSchema is everything applied at boot, in order — this app's own
30// Schema plus every framework subsystem's — and it is what New() (app.go)
31// hands to migrate.Apply. It is a separate variable from Schema for
32// the same reason Schema must stay narrow: generate and check would
33// misread a subsystem's tables as ones Models forgot.
34//
35// Merge's argument order is apply order, so a subsystem whose
36// migrations another one reads goes first: rastrillo/auth's own
37// backfill migration reads the sessions table, so sessions.Schema
38// must apply before auth.Schema, and this app's own Schema last.
39// Get this line wrong and either boot silently skips a subsystem's
40// tables, or generate/check try to drop them.
41var BootSchema = migrate.Merge(migrate.MustFromFS(dashboard.Migrations, "oficina_dashboard"), sessions.Schema, rauth.Schema, Schema)
42