oficina / calendar Public

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

Plain git — no account needed to clone.

Download

Download this file

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