rastrillo / idear Public

Clone
git clone https://amadan.net/rastrillo/idear

Plain git — no account needed to clone.

Download

Download this file

1package idear
2
3import (
4 "embed"
5
6 "github.com/carlosframework/rastrillo/migrate"
7)
8
9//go:embed migrations
10var migrationFS embed.FS
11
12// Schema is idear's migration set, following the sessions / auth /
13// blobs convention exactly.
14//
15// Merge it into your app's BootSchema —
16// migrate.Merge(sessions.Schema, idear.Schema, Schema) — and apply
17// that merged set at boot. Never merge it into your app's own Schema,
18// and never add idear's model structs to your app's own Models list:
19// rastrillo's `migration check`/`generate` diff one app's Schema
20// against that same app's Models as a matched pair, so mixing idear's
21// models into your app's list compares them against a Schema that has
22// no idear migrations in it. That makes `migration check` permanently
23// red and makes `generate` write a second, GORM-flavoured
24// `CREATE TABLE idear_members` into your app's own migration file —
25// one that collides at boot with idear's own
26// `CREATE TABLE IF NOT EXISTS idear_members` from BootSchema. idear's
27// Schema and its model structs are a pair scoped to idear alone; no
28// core subsystem (sessions, auth, blobs, passkey) exports its models
29// for the same reason.
30var Schema = migrate.MustFromFS(migrationFS, "idear")
31
32// models is idear's own model list, used only by idear's tests to
33// check Schema and the struct tags agree. It is deliberately
34// unexported — see Schema's doc comment for why an app must never be
35// handed this list.
36func models() []any {
37 return []any{&Member{}, &Invitation{}}
38}
39