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
Afficher le fichier Open project: canton7/SimpleMigrations

Méthodes publiques

Méthode 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 méthode

Acquires an advisory lock using Connection
public abstract AcquireAdvisoryLock ( ) : 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 invokes AcquireAdvisoryLock to acquire the advisory lock.
public BeginOperation ( ) : DbConnection
Résultat System.Data.Common.DbConnection

DatabaseProviderBaseWithAdvisoryLock() public méthode

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
Résultat System

EndOperation() public méthode

Called after migrations are run, this invokes ReleaseAdvisoryLock to release the advisory lock.
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 do whatever locking is appropriate to guard against concurrent migrators. 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. Therefore the advisory lock has already been acquired.
public GetCurrentVersion ( ) : long
Résultat long

ReleaseAdvisoryLock() public abstract méthode

Releases the advisory lock held on Connection
public abstract ReleaseAdvisoryLock ( ) : 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, 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
Résultat void