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

Migrations de BDD #69

Merged
merged 2 commits into from
Jul 4, 2024
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
6 changes: 3 additions & 3 deletions .github/workflows/Vérifications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ jobs:
uses: actions/setup-python@v4.7.1
with:
python-version: '3.11'
if: github.event_name != 'pull_request'
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
- name: Install Paramiko
run: python3 -m pip install paramiko
if: github.event_name != 'pull_request'
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
- name: Deploy build
env:
DEPLOY_HOSTNAME: ${{ secrets.DEPLOY_HOSTNAME }}
DEPLOY_USERNAME: ${{ secrets.DEPLOY_USERNAME }}
DEPLOY_PASSWORD: ${{ secrets.DEPLOY_PASSWORD }}
run: python3 .deployment/galliumplus-deploy
if: github.event_name != 'pull_request'
if: github.event_name == 'push' && github.ref == 'refs/heads/main'

unit-tests:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

MariaDbTests
appsettings.Development.json

# User-specific files
*.rsuser
Expand Down
7 changes: 7 additions & 0 deletions .idea/.idea.Gallium+ API/.idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/.idea.Gallium+ API/.idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/.idea.Gallium+ API/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gallium+ API.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeNamespaceBody/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/NAMESPACE_BODY/@EntryValue">FileScoped</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=galliumplus/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using KiwiQuery;
using MySqlConnector;

namespace GalliumPlus.WebApi.Data.MariaDb
namespace GalliumPlus.WebApi.Data.MariaDb.Implementations
{
public class CategoryDao : Dao, ICategoryDao
{
Expand Down
6 changes: 3 additions & 3 deletions MariaDb/ClientDao.cs → MariaDb/Implementations/ClientDao.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using GalliumPlus.WebApi.Core;
using System.Data;
using GalliumPlus.WebApi.Core;
using GalliumPlus.WebApi.Core.Applications;
using GalliumPlus.WebApi.Core.Data;
using GalliumPlus.WebApi.Core.Exceptions;
using GalliumPlus.WebApi.Core.Users;
using KiwiQuery;
using MySqlConnector;
using System.Data;

namespace GalliumPlus.WebApi.Data.MariaDb
namespace GalliumPlus.WebApi.Data.MariaDb.Implementations
{
public class ClientDao : Dao, IClientDao
{
Expand Down
12 changes: 6 additions & 6 deletions MariaDb/HistoryDao.cs → MariaDb/Implementations/HistoryDao.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using GalliumPlus.WebApi.Core.Data;
using System.Data;
using GalliumPlus.WebApi.Core.Data;
using GalliumPlus.WebApi.Core.Data.HistorySearch;
using GalliumPlus.WebApi.Core.Exceptions;
using GalliumPlus.WebApi.Core.History;
using KiwiQuery;
using MySqlConnector;
using System.Data;

namespace GalliumPlus.WebApi.Data.MariaDb
namespace GalliumPlus.WebApi.Data.MariaDb.Implementations
{
public class HistoryDao : Dao, IHistoryDao
{
Expand Down Expand Up @@ -51,7 +51,7 @@ private int EnsureUserIsInHistory(string userId, Schema db)
{
try
{
if (FindHistoryUserId(userId, db, out int id))
if (this.FindHistoryUserId(userId, db, out int id))
{
return id;
}
Expand All @@ -63,7 +63,7 @@ private int EnsureUserIsInHistory(string userId, Schema db)
catch (MySqlException error)
{
if (error.ErrorCode == MySqlErrorCode.DuplicateKeyEntry
&& FindHistoryUserId(userId, db, out int id))
&& this.FindHistoryUserId(userId, db, out int id))
{
return id;
}
Expand All @@ -75,7 +75,7 @@ public void CheckUserNotInHistory(string userId)
{
using var connection = this.Connect();

if (FindHistoryUserId(userId, new Schema(connection), out int _))
if (this.FindHistoryUserId(userId, new Schema(connection), out int _))
{
throw new DuplicateItemException("Un autre utilisateur avec cet identifiant existe déjà dans l'historique.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using KiwiQuery;
using MySqlConnector;

namespace GalliumPlus.WebApi.Data.MariaDb
namespace GalliumPlus.WebApi.Data.MariaDb.Implementations
{
public class ProductDao : Dao, IProductDao
{
Expand Down
2 changes: 1 addition & 1 deletion MariaDb/RoleDao.cs → MariaDb/Implementations/RoleDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using KiwiQuery;
using MySqlConnector;

namespace GalliumPlus.WebApi.Data.MariaDb
namespace GalliumPlus.WebApi.Data.MariaDb.Implementations
{
public class RoleDao : Dao, IRoleDao
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using GalliumPlus.WebApi.Core.Applications;
using GalliumPlus.WebApi.Core.Data;
using GalliumPlus.WebApi.Core.Data;
using GalliumPlus.WebApi.Core.Exceptions;
using GalliumPlus.WebApi.Core.Users;
using KiwiQuery;
using MySqlConnector;

namespace GalliumPlus.WebApi.Data.MariaDb
namespace GalliumPlus.WebApi.Data.MariaDb.Implementations
{
public class SessionDao : Dao, ISessionDao
{
Expand Down
7 changes: 3 additions & 4 deletions MariaDb/UserDao.cs → MariaDb/Implementations/UserDao.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using GalliumPlus.WebApi.Core;
using GalliumPlus.WebApi.Core.Applications;
using System.Data;
using GalliumPlus.WebApi.Core;
using GalliumPlus.WebApi.Core.Data;
using GalliumPlus.WebApi.Core.Exceptions;
using GalliumPlus.WebApi.Core.Users;
using KiwiQuery;
using MySqlConnector;
using System.Data;

namespace GalliumPlus.WebApi.Data.MariaDb
namespace GalliumPlus.WebApi.Data.MariaDb.Implementations
{
public class UserDao : Dao, IUserDao
{
Expand Down
3 changes: 3 additions & 0 deletions MariaDb/MariaDb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentMigrator" Version="5.2.0" />
<PackageReference Include="FluentMigrator.Runner" Version="5.2.0" />
<PackageReference Include="FluentMigrator.Runner.MySql" Version="5.2.0" />
<PackageReference Include="KiwiQuery" Version="0.4.0" />
<PackageReference Include="MySqlConnector" Version="2.3.1" />
</ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions MariaDb/MariaDbOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ public class MariaDbOptions
public string Schema { get; set; } = "galliumplus";

public uint Port { get; set; } = 3306;

public string ToConnectionString() =>
$"Server={this.Host};Port={this.Port};User ID={this.UserId};Password={this.Password};Database={this.Schema}";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Data;
using FluentMigrator;

namespace GalliumPlus.WebApi.Data.MariaDb.Migrations.v1_00_00;

// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedType.Global
[Migration(2024_07_03_016)]
public class CreateForeignKey_BotClient_extends_Client : Migration
{
public override void Up()
{
this.Create.ForeignKey("FK_BotClient_extends_Client")
.FromTable("BotClient").ForeignColumn("id").ToTable("Client").PrimaryColumn("id")
.OnUpdate(Rule.Cascade) .OnDelete(Rule.Cascade);
}

public override void Down()
{
this.Delete.ForeignKey("BotClient_extends_Client");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Data;
using FluentMigrator;

namespace GalliumPlus.WebApi.Data.MariaDb.Migrations.v1_00_00;

// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedType.Global
[Migration(2024_07_03_019)]
public class CreateForeignKey_HistoryAction_HistoryUser_actor : Migration
{
public override void Up()
{
this.Create.ForeignKey("FK_HistoryAction_HistoryUser_actor")
.FromTable("HistoryAction").ForeignColumn("actor").ToTable("HistoryUser").PrimaryColumn("id")
.OnUpdate(Rule.None).OnDelete(Rule.None);
}

public override void Down()
{
this.Delete.ForeignKey("HistoryAction_HistoryUser_actor");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Data;
using FluentMigrator;

namespace GalliumPlus.WebApi.Data.MariaDb.Migrations.v1_00_00;

// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedType.Global
[Migration(2024_07_03_020)]
public class CreateForeignKey_HistoryAction_HistoryUser_target : Migration
{
public override void Up()
{
this.Create.ForeignKey("FK_HistoryAction_HistoryUser_target")
.FromTable("HistoryAction").ForeignColumn("target").ToTable("HistoryUser").PrimaryColumn("id")
.OnUpdate(Rule.None).OnDelete(Rule.None);
}

public override void Down()
{
this.Delete.ForeignKey("HistoryAction_HistoryUser_target");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Data;
using FluentMigrator;

namespace GalliumPlus.WebApi.Data.MariaDb.Migrations.v1_00_00;

// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedType.Global
[Migration(2024_07_03_013)]
public class CreateForeignKey_PasswordResetToken_User_userId : Migration
{
public override void Up()
{
this.Create.ForeignKey("FK_PasswordResetToken_User_userId")
.FromTable("PasswordResetToken").ForeignColumn("userId").ToTable("User").PrimaryColumn("userId")
.OnUpdate(Rule.Cascade).OnDelete(Rule.Cascade);

}

public override void Down()
{
this.Delete.ForeignKey("FK_PasswordResetToken_User_userId");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Data;
using FluentMigrator;

namespace GalliumPlus.WebApi.Data.MariaDb.Migrations.v1_00_00;

// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedType.Global
[Migration(2024_07_03_018)]
public class CreateForeignKey_Product_Category_category : Migration
{
public override void Up()
{
this.Create.ForeignKey("FK_Product_Category_category")
.FromTable("Product").ForeignColumn("category").ToTable("Category").PrimaryColumn("id")
.OnUpdate(Rule.Cascade) .OnDelete(Rule.None);
}

public override void Down()
{
this.Delete.ForeignKey("Product_Category_category");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Data;
using FluentMigrator;

namespace GalliumPlus.WebApi.Data.MariaDb.Migrations.v1_00_00;

// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedType.Global
[Migration(2024_07_03_015)]
public class CreateForeignKey_Session_Client_client : Migration
{
public override void Up()
{
this.Create.ForeignKey("FK_Session_Client_client")
.FromTable("Session").ForeignColumn("client").ToTable("Client").PrimaryColumn("id")
.OnUpdate(Rule.Cascade) .OnDelete(Rule.Cascade);
}

public override void Down()
{
this.Delete.ForeignKey("Session_Client_client");
}
}
22 changes: 22 additions & 0 deletions MariaDb/Migrations/v1_00_00/CreateForeignKey_Session_User_user.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Data;
using FluentMigrator;

namespace GalliumPlus.WebApi.Data.MariaDb.Migrations.v1_00_00;

// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedType.Global
[Migration(2024_07_03_014)]
public class CreateForeignKey_Session_User_user : Migration
{
public override void Up()
{
this.Create.ForeignKey("FK_Session_User_user")
.FromTable("Session").ForeignColumn("user").ToTable("User").PrimaryColumn("id")
.OnUpdate(Rule.Cascade) .OnDelete(Rule.Cascade);
}

public override void Down()
{
this.Delete.ForeignKey("Session_User_user");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Data;
using FluentMigrator;

namespace GalliumPlus.WebApi.Data.MariaDb.Migrations.v1_00_00;

// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedType.Global
[Migration(2024_07_03_017)]
public class CreateForeignKey_SsoClient_extends_Client : Migration
{
public override void Up()
{
this.Create.ForeignKey("FK_SsoClient_extends_Client")
.FromTable("SsoClient").ForeignColumn("id").ToTable("Client").PrimaryColumn("id")
.OnUpdate(Rule.Cascade) .OnDelete(Rule.Cascade);
}

public override void Down()
{
this.Delete.ForeignKey("SsoClient_extends_Client");
}
}
Loading
Loading