schema_model library
Physical table, column, key, index, and constraint metadata.
TableSchema and Column describe storage independently of Dart row models, generated clients, and live connections. They can be assembled directly for schema tooling or consumed from generated Dart snapshots.
Collection inputs to TableSchema are copied into immutable lists. Creating metadata does not apply DDL: migration tooling validates the target engine and executes reviewed schema changes separately.
Use package:orm/schema.dart for application model declarations.
Classes
- CheckSchema
- A row CHECK expression. A null name leaves naming to the database.
-
Codec<
T> - Converts a typed Dart value to database storage and decodes it on reads.
- Codecs
- Built-in conversions for SQL scalar values, JSON, and exact numeric types.
-
Column<
T> - Physical column metadata coupled to the Dart/storage Codec.
- ComputedColumn
- Database-computed SQL using physical column names.
- Decimal
- A finite base-ten value, independent of binary floating point.
- ForeignKey
- A database foreign key described with ordered physical column names.
- IndexSchema
- A simple index over ordered physical columns.
- LocalDate
- A Gregorian calendar date, without a time or timezone. Year 0 is 1 BC; negative years use astronomical numbering.
- LocalDateTime
- Calendar date and wall-clock time, with no timezone or implied UTC instant.
- LocalTime
- A wall-clock time at microsecond resolution, including the endpoint 24:00. The fourth constructor argument is the full fractional second (0..999999).
- SqlJson
- A non-SQL-null JSON document. Its value may itself be JSON null. Drivers use this envelope for parsed JSON, including JSON string scalars.
- SqlReal
- Explicit floating-point SQL input. JavaScript cannot distinguish an integral double from int by runtime type; this preserves the SQL intention.
- TableSchema
- Immutable physical table metadata, independent of Dart model identity.
Enums
- ComputedStorage
- How a database maintains a computed column, subject to engine capabilities.
- DecimalRounding
- Rounding is explicit; exact rejects a non-zero discarded remainder.
- SqlDialect
- SQL engine used for quoting, parameter syntax, and capability validation.
Extensions
- InstantPrecision on DateTime
- Explicit precision conversion for resolved UTC instants.
Exceptions / Errors
- OrmException
- An ORM failure with a stable machine-readable code and optional cause.