MssqlSchemaSnapshot class

A database's shape, written to a file, so that generating code does not need a live database.

Two things follow from that, and they are separate on purpose:

  • Generating from a snapshot is offline. It needs no server, no credentials and no network, which is what makes generation work in CI and on a laptop without a VPN.
  • Checking for drift is not. Comparing a snapshot against the database it describes is the only thing that can say whether the file is still true, and that needs the database.

A snapshot carries no connection string, user name or password: the credentials used to read the objects are not part of what it describes.

Constructors

MssqlSchemaSnapshot({required List<MssqlTableSchema> tables, required String serverVersion, required int compatibilityLevel, required DateTime capturedAt, int apiVersion = MssqlApiVersion.current})
MssqlSchemaSnapshot.fromJsonText(String source, {String? origin})
Reads a snapshot file.
factory

Properties

ambiguousNames → List<String>
Names that differ only in case, and so cannot be resolved by folding.
no setter
apiVersion → int
The API contract the snapshot was written under.
final
capturedAt → DateTime
When the snapshot was taken, in UTC. Reported in a drift message so that "the snapshot is old" is something a reader can see rather than guess.
final
checksum → String
A digest of everything except capturedAt.
latefinal
compatibilityLevel → int
The database's compatibility level, which can hold a modern server to an older set of behaviours and is therefore its own fact.
final
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
serverVersion → String
SERVERPROPERTY('ProductVersion') — what the target can do.
final
tables → List<MssqlTableSchema>
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
table(String qualifiedName) → MssqlTableSchema?
The table called qualifiedName — dbo.Orders — or null.
toJsonText() → String
The snapshot as deterministic, pretty-printed JSON.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

capture(MssqlConnection connection, {Set<String> schemas = const <String>{'dbo'}, bool includeViews = true, List<String> include = const <String>['*'], List<String> exclude = const <String>[]}) → Future<MssqlSchemaSnapshot>
Reads the live schema and the two server facts a snapshot records.

Constants

formatVersion → const int
The format this file is written in.