C# Class SimpleMigrations.DatabaseProvider.DatabaseProviderBaseWithVersionTableLock

DatabaseProviderBase subclass for databases which use a transaction on the VersionInfo table to guard against concurrent migrators.
This uses two connections for each operation: one which uses a transaction to acquire a lock on the VersionInfo table and to update it, and another to run migrations on.
Inheritance: DatabaseProviderBase
Afficher le fichier Open project: canton7/SimpleMigrations

Méthodes publiques

Méthode Description
BeginOperation ( ) : DbConnection

Called when SimpleMigrator{TConnection, TMigrationBase}.MigrateTo(long) or SimpleMigrator{TConnection, TMigrationBase}.Baseline(long) is invoked, before any migrations are run. This creates the VersionTableConnection and MigrationsConnection, and invokes AcquireVersionTableLock to acquire the VersionInfo table lock.

DatabaseProviderBaseWithVersionTableLock ( Func connectionFactory ) : System

Initialises a new instance of the DatabaseProviderBaseWithVersionTableLock class

EndOperation ( ) : void

Called after migrations are run, this invokes AcquireVersionTableLock to release the VersionInfo table lock, and then closes VersionTableConnection and MigrationsConnection"/>

EnsureCreatedAndGetCurrentVersion ( ) : long

Ensures that the version table is created, and returns the current version.

This is not surrounded by calls to BeginOperation or EndOperation, so it should create its own connection. If the version table is empty, this should return 0.

GetCurrentVersion ( ) : long

Fetch the current database schema version, or 0.

This method is always invoked after a call to BeginOperation, but before a call to EndOperation. It should use VersionTableConnection and VersionTableLockTransaction

UpdateVersion ( long oldVersion, long newVersion, string newDescription ) : void

Update the VersionInfo table to indicate that the given migration was successfully applied.

This is always invoked after a call to BeginOperation but before a call to EndOperation, It should use VersionTableConnection and VersionTableLockTransaction

Méthodes protégées

Méthode Description
AcquireVersionTableLock ( ) : void

Creates and sets VersionTableLockTransaction, and uses it to lock the VersionInfo table

ReleaseVersionTableLock ( ) : void

Destroys VersionTableLockTransaction, thus releasing the VersionInfo table lock

Method Details

AcquireVersionTableLock() protected abstract méthode

Creates and sets VersionTableLockTransaction, and uses it to lock the VersionInfo table
protected abstract AcquireVersionTableLock ( ) : void
Résultat void

BeginOperation() public méthode

Called when SimpleMigrator{TConnection, TMigrationBase}.MigrateTo(long) or SimpleMigrator{TConnection, TMigrationBase}.Baseline(long) is invoked, before any migrations are run. This creates the VersionTableConnection and MigrationsConnection, and invokes AcquireVersionTableLock to acquire the VersionInfo table lock.
public BeginOperation ( ) : DbConnection
Résultat System.Data.Common.DbConnection

DatabaseProviderBaseWithVersionTableLock() public méthode

Initialises a new instance of the DatabaseProviderBaseWithVersionTableLock class
public DatabaseProviderBaseWithVersionTableLock ( Func connectionFactory ) : System
connectionFactory Func Factory to be used to create new connections
Résultat System

EndOperation() public méthode

Called after migrations are run, this invokes AcquireVersionTableLock to release the VersionInfo table lock, and then closes VersionTableConnection and MigrationsConnection"/>
public EndOperation ( ) : void
Résultat void

EnsureCreatedAndGetCurrentVersion() public méthode

Ensures that the version table is created, and returns the current version.
This is not surrounded by calls to BeginOperation or EndOperation, so it should create its own connection. If the version table is empty, this should return 0.
public EnsureCreatedAndGetCurrentVersion ( ) : long
Résultat long

GetCurrentVersion() public méthode

Fetch the current database schema version, or 0.
This method is always invoked after a call to BeginOperation, but before a call to EndOperation. It should use VersionTableConnection and VersionTableLockTransaction
public GetCurrentVersion ( ) : long
Résultat long

ReleaseVersionTableLock() protected abstract méthode

Destroys VersionTableLockTransaction, thus releasing the VersionInfo table lock
protected abstract ReleaseVersionTableLock ( ) : void
Résultat void

UpdateVersion() public méthode

Update the VersionInfo table to indicate that the given migration was successfully applied.
This is always invoked after a call to BeginOperation but before a call to EndOperation, It should use VersionTableConnection and VersionTableLockTransaction
public UpdateVersion ( long oldVersion, long newVersion, string newDescription ) : void
oldVersion long The previous version of the database schema
newVersion long The version of the new database schema
newDescription string The description of the migration which was applied
Résultat void