Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some fixes #9

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

internal class ClickHouseMigrationContext : ClickHouseContext<ClickHouseMigrationContext>
{

public ClickHouseMigrationFacade MigrationFacade => GetFacade<ClickHouseMigrationFacade>();
}
6 changes: 3 additions & 3 deletions src/ClickHouse.Facades/Migrations/ClickHouseMigrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public async Task ApplyMigrationsAsync(CancellationToken cancellationToken = def
{
await using var context = _migrationContextFactory.CreateContext();

var facade = context.GetFacade<ClickHouseMigrationFacade>();
var facade = context.MigrationFacade;

await EnsureDatabaseCreated(context, cancellationToken);
await facade.EnsureMigrationsTableCreatedAsync(cancellationToken);
Expand All @@ -44,7 +44,7 @@ public async Task RollbackAsync(ulong targetMigrationId, CancellationToken cance
{
await using var context = _migrationContextFactory.CreateContext();

var facade = context.GetFacade<ClickHouseMigrationFacade>();
var facade = context.MigrationFacade;

var migrationsResolver = new MigrationsResolver(
await facade.GetAppliedMigrationsAsync(cancellationToken),
Expand All @@ -64,7 +64,7 @@ private static async Task EnsureDatabaseCreated(

context.ChangeDatabase("");

await context.GetFacade<ClickHouseMigrationFacade>()
await context.MigrationFacade
.EnsureDatabaseCreatedAsync(cancellationToken);

context.ChangeDatabase(database);
Expand Down
13 changes: 8 additions & 5 deletions src/ClickHouse.Facades/Migrations/MigrationsResolver.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace ClickHouse.Facades.Migrations;
using ClickHouse.Facades.Utility;

namespace ClickHouse.Facades.Migrations;

internal class MigrationsResolver
{
Expand All @@ -9,11 +11,12 @@ public MigrationsResolver(
IEnumerable<AppliedMigration> appliedMigrations,
IEnumerable<ClickHouseMigration> locatedMigrations)
{
_appliedMigrations = appliedMigrations.OrderBy(m => m.Id)
?? throw new ArgumentNullException(nameof(appliedMigrations));
ExceptionHelpers.ThrowIfNull(appliedMigrations);
ExceptionHelpers.ThrowIfNull(locatedMigrations);

_appliedMigrations = appliedMigrations.OrderBy(m => m.Id);

_locatedMigrations = locatedMigrations.OrderBy(m => m.Index)
?? throw new ArgumentNullException(nameof(locatedMigrations));
_locatedMigrations = locatedMigrations.OrderBy(m => m.Index);
}

public IOrderedEnumerable<ClickHouseMigration> GetMigrationsToApply()
Expand Down