C# Класс 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.
Наследование: DatabaseProviderBase
Показать файл Открыть проект

Открытые методы

Метод Описание
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

Защищенные методы

Метод Описание
AcquireVersionTableLock ( ) : void

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

ReleaseVersionTableLock ( ) : void

Destroys VersionTableLockTransaction, thus releasing the VersionInfo table lock

Описание методов

AcquireVersionTableLock() защищенный абстрактный Метод

Creates and sets VersionTableLockTransaction, and uses it to lock the VersionInfo table
protected abstract AcquireVersionTableLock ( ) : void
Результат void

BeginOperation() публичный Метод

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
Результат System.Data.Common.DbConnection

DatabaseProviderBaseWithVersionTableLock() публичный Метод

Initialises a new instance of the DatabaseProviderBaseWithVersionTableLock class
public DatabaseProviderBaseWithVersionTableLock ( Func connectionFactory ) : System
connectionFactory Func Factory to be used to create new connections
Результат System

EndOperation() публичный Метод

Called after migrations are run, this invokes AcquireVersionTableLock to release the VersionInfo table lock, and then closes VersionTableConnection and MigrationsConnection"/>
public EndOperation ( ) : void
Результат void

EnsureCreatedAndGetCurrentVersion() публичный Метод

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
Результат long

GetCurrentVersion() публичный Метод

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
Результат long

ReleaseVersionTableLock() защищенный абстрактный Метод

Destroys VersionTableLockTransaction, thus releasing the VersionInfo table lock
protected abstract ReleaseVersionTableLock ( ) : void
Результат void

UpdateVersion() публичный Метод

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
Результат void