Schema generation and verification #
Schema.defineText turns the mapped types into one TypeQL define: attribute types with their
value types, entity and relation types with sub, owns (with @key and @card) and
relates, and the plays of every role player. Schema.verify checks a live database against
the same mappings and lists every difference.
What the schema needs to know about one mapped type.
- label : String
- kind : ORM.Kind
- fields : Array ORM.FieldSpec
Instances For
Equations
- TypeDB.instReprTypeSpec = { reprPrec := TypeDB.instReprTypeSpec.repr }
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
The schema description of a mapped type: TypeSpec.of Person.
Equations
- TypeDB.TypeSpec.of α = { label := TypeDB.ORM.Mapped.label α, kind := TypeDB.ORM.Mapped.kind α, parent := TypeDB.ORM.Mapped.parent α, fields := TypeDB.ORM.Mapped.fields α }
Instances For
The define query for the mapped types.
Equations
- TypeDB.Schema.define specs = (fun (x : String) => { text := x }) <$> TypeDB.Schema.defineText specs
Instances For
Defines the mapped types in the current schema transaction. Unchanged types are left as they are, so running it again is harmless.
Equations
- TypeDB.Schema.defineTx specs = match TypeDB.Schema.define specs with | Except.ok q => TypeDB.exec q | Except.error e => TypeDB.Tx.fail (TypeDB.TypeDBError.internal e)
Instances For
Runs the TypeQL in a file, e.g. a define schema.
Equations
- TypeDB.Schema.load path = do let __do_lift ← liftM (IO.FS.readFile path) TypeDB.exec (TypeDB.Query.raw TypeDB.TxMode.schema __do_lift)
Instances For
Every difference between the mapped types and the database's schema.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Fails with TypeDBError.schemaMismatch unless the database matches the mapped types.
Equations
- TypeDB.Schema.verify! specs = do let issues ← TypeDB.Schema.verify specs if issues.isEmpty = true then pure () else TypeDB.Tx.fail (TypeDB.TypeDBError.schemaMismatch issues)