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

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

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

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

AcquireAdvisoryLock() публичный абстрактный Метод

Acquires an advisory lock using Connection
public abstract AcquireAdvisoryLock ( ) : void
Результат void

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

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

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

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

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

Called after migrations are run, this invokes ReleaseAdvisoryLock to release the advisory lock.
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 do whatever locking is appropriate to guard against concurrent migrators. 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. Therefore the advisory lock has already been acquired.
public GetCurrentVersion ( ) : long
Результат long

ReleaseAdvisoryLock() публичный абстрактный Метод

Releases the advisory lock held on Connection
public abstract ReleaseAdvisoryLock ( ) : 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, 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
Результат void