//
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
//
namespace MUnique.OpenMU.Persistence;
using System.Threading;
///
/// Provider for persistence contexts which supports database creation and migration.
/// TODO: find better name?.
///
public interface IMigratableDatabaseContextProvider : IPersistenceContextProvider
{
///
/// Determines if the database exists already, by checking if any migration has been applied.
///
/// The cancellation token.
///
/// True, if the database exists; Otherwise, false.
///
Task DatabaseExistsAsync(CancellationToken cancellationToken = default);
///
/// Determines whether the database schema is up to date.
///
/// The cancellation token.
///
/// true if the database is up to date; otherwise, false.
///
Task IsDatabaseUpToDateAsync(CancellationToken cancellationToken = default);
///
/// Applies all pending updates to the database schema.
///
Task ApplyAllPendingUpdatesAsync();
///
/// Waits until all database updates are applied.
///
/// The cancellation token.
Task WaitForUpdatedDatabaseAsync(CancellationToken cancellationToken = default);
///
/// Determines whether this instance can connect to the database.
///
/// The cancellation token.
///
/// true if this instance can connect to the database; otherwise, false.
///
Task CanConnectToDatabaseAsync(CancellationToken cancellationToken = default);
///
/// Determines whether this instance should do an automatic schema update
/// without asking the user.
///
/// The cancellation token.
///
/// true if this instance should do an automatic schema update
/// without asking the user.; otherwise, false.
///
Task ShouldDoAutoSchemaUpdateAsync(CancellationToken cancellationToken = default);
///
/// Recreates the database by deleting and creating it again.
///
/// The disposable which should be disposed when the data creation process is finished.
Task ReCreateDatabaseAsync();
///
/// Resets the cache of this instance.
///
void ResetCache();
}