From 8cd8277c22defc9edf93113fbbb52893bc5eddc7 Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Sat, 1 Jun 2024 05:40:48 +0300 Subject: [PATCH] feat: add assembly for migration --- .../MysqlMigrations/MysqlMigrations.csproj | 12 ++++++++++++ .../Migrations/PsqlMigrations/PsqlMigrations.csproj | 12 ++++++++++++ .../SqliteMigrations/SqliteMigrations.csproj | 12 ++++++++++++ SqlData/Persistence/DependencyInjection.cs | 9 ++++++--- 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 SqlData/Migrations/MysqlMigrations/MysqlMigrations.csproj create mode 100644 SqlData/Migrations/PsqlMigrations/PsqlMigrations.csproj create mode 100644 SqlData/Migrations/SqliteMigrations/SqliteMigrations.csproj diff --git a/SqlData/Migrations/MysqlMigrations/MysqlMigrations.csproj b/SqlData/Migrations/MysqlMigrations/MysqlMigrations.csproj new file mode 100644 index 0000000..d9d83f2 --- /dev/null +++ b/SqlData/Migrations/MysqlMigrations/MysqlMigrations.csproj @@ -0,0 +1,12 @@ + + + + net8.0 + ..\..\Persistence\bin\ + + + + + + + diff --git a/SqlData/Migrations/PsqlMigrations/PsqlMigrations.csproj b/SqlData/Migrations/PsqlMigrations/PsqlMigrations.csproj new file mode 100644 index 0000000..d9d83f2 --- /dev/null +++ b/SqlData/Migrations/PsqlMigrations/PsqlMigrations.csproj @@ -0,0 +1,12 @@ + + + + net8.0 + ..\..\Persistence\bin\ + + + + + + + diff --git a/SqlData/Migrations/SqliteMigrations/SqliteMigrations.csproj b/SqlData/Migrations/SqliteMigrations/SqliteMigrations.csproj new file mode 100644 index 0000000..d9d83f2 --- /dev/null +++ b/SqlData/Migrations/SqliteMigrations/SqliteMigrations.csproj @@ -0,0 +1,12 @@ + + + + net8.0 + ..\..\Persistence\bin\ + + + + + + + diff --git a/SqlData/Persistence/DependencyInjection.cs b/SqlData/Persistence/DependencyInjection.cs index ad7c511..f86cd87 100644 --- a/SqlData/Persistence/DependencyInjection.cs +++ b/SqlData/Persistence/DependencyInjection.cs @@ -76,9 +76,12 @@ public static class DependencyInjection { return dbProvider switch { - DatabaseProvider.Sqlite => options.UseSqlite(connection), - DatabaseProvider.Mysql => options.UseMySql(connection, ServerVersion.AutoDetect(connection)), - DatabaseProvider.Postgresql => options.UseNpgsql(connection), + DatabaseProvider.Mysql => options.UseMySql(connection, ServerVersion.AutoDetect(connection), + x => x.MigrationsAssembly("MysqlMigrations")), + DatabaseProvider.Sqlite => options.UseSqlite(connection, + x => x.MigrationsAssembly("SqliteMigrations")), + DatabaseProvider.Postgresql => options.UseNpgsql(connection, + x => x.MigrationsAssembly("PsqlMigrations")), _ => throw new ArgumentException("Unsupported database provider", Enum.GetName(dbProvider)) }; }