Scheme class base
A description of a configurable part of a database schema.
The "scheme" concept, as used in this library, is a configurable part of a full database schema. That is, an SQLite database managed by this library has a schema split into two parts:
- The first part is the unchangeable foundation, which consists of the mapping table and the scheme table. The mapping table holds all application-supplied key-value data in the mandatory keyid and value columns; it also always includes the kind virtual column. The scheme table holds the overall scheme version of the second part of the schema.
- The second part is a configurable extension, which consists of additional
virtual columns for the mapping table, partial indexes for those virtual
columns, FTS indexes for application-supplied key-value data from the
mapping table, and a JSON path to extract a
Kindfrom any JSON value stored in the value column of the mapping table.
A scheme's description is defined by an application via the properties of the Scheme class: kindPath, virtualColumns, partialIndexes, and searchIndexes. Changes to the description must be accompanied by an overall scheme version change to trigger a scheme migration upon the first run of a new application build. A scheme migration updates the database schema to reflect the new configuration while leaving application-supplied key-value data intact. By increasing the Scheme.revision number, custom processing that modifies key-value data or performs other I/O operations can be added to a migration via Scheme.upgrader.
The overall scheme version is returned by the toDefinition function. A scheme migration is triggered when the overall scheme version changes, which occurs in the following cases:
- the revision changes;
- the kindPath changes;
- the map formed by the name-version pairs of the virtualColumns changes;
- the map formed by the name-version pairs of the partialIndexes changes;
- the map formed by the name-version pairs of the searchIndexes changes.
See also: VirtualColumn, PartialIndex, and SearchIndex.
- Annotations
-
- @immutable
Constructors
- Scheme({int revision = schemeInitialRevision, DatabaseUpgrader? upgrader, required String kindPath, VirtualColumns virtualColumns = const [], PartialIndexes partialIndexes = const [], SearchIndexes searchIndexes = const []})
- Creates a description of a scheme using the given parameters.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- kindPath → String
-
The JSON path to extract
Kinds from database JSON values.final - partialIndexes → PartialIndexes
-
A list of the partial index descriptions.
final
- revision → int
-
The application-provided revision number for this scheme description.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- searchIndexes → SearchIndexes
-
A list of the FTS index descriptions.
final
- upgrader → DatabaseUpgrader?
-
The callbacks invoked during scheme migration.
final
- virtualColumns → VirtualColumns
-
A list of the generated virtual column descriptions.
final
Methods
-
deactivateUpdatersLookup(
) → void - Deactivates the SearchIndexUpdaters of the FTS indexes.
-
elementsDefinition(
List< SchemeElement> elements) → Map<String, int> -
Returns a map representing the overall version of the
elements. -
getPartialIndex(
String name) → PartialIndex -
Finds a PartialIndex with the given
name. -
getSearchIndex(
String name) → SearchIndex -
Finds a SearchIndex with the given
name. -
getSearchIndexesUpdater(
Kind? kind) → SearchRowsUpdaters? -
Returns the SearchRowsUpdaters for the given
kind. -
getVirtualColumn(
String name) → VirtualColumn -
Finds a VirtualColumn with the given
name. -
initializeUpdatersLookup(
SQLite sqlite) → void - Initializes and registers the SearchIndexUpdaters of the FTS indexes.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDefinition(
) → StdMap - Returns a JSON map representing the scheme's overall version.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- kKindPath → const String
- The key for the kindPath part of the overall scheme version map.
- kPartialIndexes → const String
- The key for the partialIndexes part of the overall scheme version map.
- kRevision → const String
- The key for the revision part of the overall scheme version map.
- kSchemaVersion → const String
- The key for the schema version part of the overall scheme version map.
- kSearchIndexes → const String
- The key for the searchIndexes part of the overall scheme version map.
- kVirtualColumns → const String
- The key for the virtualColumns part of the overall scheme version map.