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
파일 보기 프로젝트 열기: canton7/SimpleMigrations

공개 메소드들

메소드 설명
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