oficina / sheets Public

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

Plain git — no account needed to clone.

Download

Download this file

1package sheets
2
3import (
4 "amadan.net/oficina/home/connect/linkstore"
5 "amadan.net/oficina/home/handoff"
6 "embed"
7
8 "amadan.net/rastrillo/rastrillo/auth"
9 "amadan.net/rastrillo/rastrillo/migrate"
10 "amadan.net/rastrillo/rastrillo/sessions"
11
12 "amadan.net/oficina/sheets/internal/sheets/store"
13)
14
15// migrationsFS embeds internal/sheets/migrations/*.sql — this package's
16// generated migrations plus the schema.sql summary `rastrillo migration
17// generate` maintains beside them. schema.sql matches the glob but is
18// never parsed as a step (migrate.FromFS excludes it by name), so the
19// go:embed directive below needs at least one *.sql file to exist before
20// this package can compile at all; that is why an empty schema.sql was
21// committed ahead of the first `rastrillo migration generate` run rather
22// than left for it to create.
23//
24//go:embed migrations/*.sql
25var migrationsFS embed.FS
26
27// Schema is Sheets' own migration set: what `rastrillo migration
28// generate`/`check` diff Models against. Never hand-edit a file under
29// migrations/ once it has shipped — add a new one instead
30// (`rastrillo migration new <name>`).
31var Schema = migrate.MustFromFS(migrationsFS, "sheets")
32
33// BootSchema is everything migrate.Apply runs at boot, in apply order —
34// the shape SKILL.md documents as `migrate.Merge(subsystemSchemas...,
35// Schema)`.
36//
37// The order is not a preference. auth's backfill migration reads the
38// sessions table, so sessions.Schema must apply first; migrate.Merge's
39// argument order IS apply order. Sheets and optional Home protocol schemas
40// follow the local authentication schemas.
41var BootSchema = migrate.Merge(sessions.Schema, auth.Schema, Schema, migrate.MustFromFS(handoff.Migrations, "oficina_handoff"), migrate.MustFromFS(linkstore.Migrations, linkstore.SchemaNamespace))
42
43// Models lists every GORM model `rastrillo migration generate`/`check`
44// diff Schema against — Sheet, Tab, Row, Col, Cell, Format and Member
45// from models.go, plus Event.
46//
47// Every model but Member is declared in package store, beside the
48// persistence that owns it. The list is a []any of values, so it names
49// them across the package boundary without needing them declared here —
50// which is what lets the CLI read one Models from one package while the
51// structs live where they belong. See store/models.go for why they
52// moved.
53var Models = []any{
54 store.Sheet{}, store.Tab{}, store.Row{}, store.Col{},
55 store.Cell{}, store.Format{}, store.Event{}, Member{}, Grant{}, ShareLink{}, Comment{}, TabView{},
56}
57