C# Class SimpleMigrations.DatabaseProvider.DatabaseProviderBaseWithAdvisoryLock

DatabaseProviderBase subclass for databases which use an advisory lock to guard against concurrent migrators.
This uses a single connection, which it does not take ownership of (i.e. it is up to the caller to close it).
Inheritance: DatabaseProviderBase
ファイルを表示 Open project: canton7/SimpleMigrations

Public Methods

Method Description
AcquireAdvisoryLock ( ) : void

Acquires an advisory lock using Connection

BeginOperation ( ) : DbConnection

Called when SimpleMigrator{TConnection, TMigrationBase}.MigrateTo(long) or SimpleMigrator{TConnection, TMigrationBase}.Baseline(long) is invoked, before any migrations are run. This invokes AcquireAdvisoryLock to acquire the advisory lock.

DatabaseProviderBaseWithAdvisoryLock ( DbConnection connection ) : System

Initialises a new instance of the DatabaseProviderBaseWithAdvisoryLock class

EndOperation ( ) : void

Called after migrations are run, this invokes ReleaseAdvisoryLock to release the advisory lock.

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 do whatever locking is appropriate to guard against concurrent migrators. 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. Therefore the advisory lock has already been acquired.

ReleaseAdvisoryLock ( ) : void

Releases the advisory lock held on Connection

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, Therefore the advisory lock has already been acquired.

Method Details

AcquireAdvisoryLock() public abstract method

Acquires an advisory lock using Connection
public abstract AcquireAdvisoryLock ( ) : void
return void

BeginOperation() public method

Called when SimpleMigrator{TConnection, TMigrationBase}.MigrateTo(long) or SimpleMigrator{TConnection, TMigrationBase}.Baseline(long) is invoked, before any migrations are run. This invokes AcquireAdvisoryLock to acquire the advisory lock.
public BeginOperation ( ) : DbConnection
return System.Data.Common.DbConnection

DatabaseProviderBaseWithAdvisoryLock() public method

Initialises a new instance of the DatabaseProviderBaseWithAdvisoryLock class
public DatabaseProviderBaseWithAdvisoryLock ( DbConnection connection ) : System
connection System.Data.Common.DbConnection Database connection to use for all operations
return System

EndOperation() public method

Called after migrations are run, this invokes ReleaseAdvisoryLock to release the advisory lock.
public EndOperation ( ) : void
return void

EnsureCreatedAndGetCurrentVersion() public method

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 do whatever locking is appropriate to guard against concurrent migrators. If the version table is empty, this should return 0.
public EnsureCreatedAndGetCurrentVersion ( ) : long
return long

GetCurrentVersion() public method

Fetch the current database schema version, or 0.
This method is always invoked after a call to BeginOperation, but before a call to EndOperation. Therefore the advisory lock has already been acquired.
public GetCurrentVersion ( ) : long
return long

ReleaseAdvisoryLock() public abstract method

Releases the advisory lock held on Connection
public abstract ReleaseAdvisoryLock ( ) : void
return void

UpdateVersion() public method

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, Therefore the advisory lock has already been acquired.
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
return void