capture static method
Reads the live schema and the two server facts a snapshot records.
Implementation
static Future<MssqlSchemaSnapshot> capture(
MssqlConnection connection, {
Set<String> schemas = const <String>{'dbo'},
bool includeViews = true,
List<String> include = const <String>['*'],
List<String> exclude = const <String>[],
}) async {
final tables = await MssqlSchemaReader(connection).readTables(
schemas: schemas,
includeViews: includeViews,
include: include,
exclude: exclude,
);
final row = await connection.queryTypedSingle('''
SELECT
CAST(SERVERPROPERTY('ProductVersion') AS nvarchar(128)) AS product_version,
CAST(DATABASEPROPERTYEX(DB_NAME(), 'CompatibilityLevel') AS int) AS level;
''');
return MssqlSchemaSnapshot(
tables: tables,
serverVersion: row.at(0)?.toString() ?? '',
compatibilityLevel: (row.at(1) as num?)?.toInt() ?? 0,
capturedAt: DateTime.now().toUtc(),
);
}