From 7a40eba2951c5de2faaef326df74a99cfeb79843 Mon Sep 17 00:00:00 2001 From: Stanley Dimant Date: Mon, 1 Aug 2022 00:48:21 +0200 Subject: [PATCH] migrate to postgresql --- .../Data/MareDbContext.cs | 12 +- .../MareSynchronosServer/Hubs/MareHub.User.cs | 5 + .../MareSynchronosServer.csproj | 7 +- .../20220629173313_InitialCreate.Designer.cs | 150 ----------- .../20220629173313_InitialCreate.cs | 117 --------- ...173544_AddForbiddenUploadEntry.Designer.cs | 163 ------------ .../20220629173544_AddForbiddenUploadEntry.cs | 30 --- ...annedAdminAndReceivingMessages.Designer.cs | 179 ------------- ...4351_AddBannedAdminAndReceivingMessages.cs | 51 ---- ...20220629212721_AddBannedReason.Designer.cs | 182 ------------- .../20220629212721_AddBannedReason.cs | 25 -- ...9230923_ChangeAdminToModerator.Designer.cs | 185 -------------- .../20220629230923_ChangeAdminToModerator.cs | 26 -- ...0704113233_RemoveCharacterData.Designer.cs | 166 ------------ .../20220704113233_RemoveCharacterData.cs | 32 --- ...104014_AddTimestampToAllTables.Designer.cs | 176 ------------- .../20220710104014_AddTimestampToAllTables.cs | 38 --- .../20220712082237_SetMaxLengths.Designer.cs | 175 ------------- .../20220712082237_SetMaxLengths.cs | 141 ---------- .../20220712102941_ClientPairKey.Designer.cs | 175 ------------- .../20220712102941_ClientPairKey.cs | 131 ---------- ...083057_MoveAuthToSeparateTable.Designer.cs | 197 -------------- .../20220713083057_MoveAuthToSeparateTable.cs | 53 ---- .../20220713104127_AddIndexes.Designer.cs | 200 --------------- .../Migrations/20220713104127_AddIndexes.cs | 72 ------ .../20220718071653_UserLoginDateTime.cs | 27 -- ... 20220731210149_InitialCreate.Designer.cs} | 124 +++++---- .../20220731210149_InitialCreate.cs | 164 ++++++++++++ ...731211419_RenameLowerSnakeCase.Designer.cs | 241 ++++++++++++++++++ .../20220731211419_RenameLowerSnakeCase.cs | 133 ++++++++++ .../Migrations/MareDbContextModelSnapshot.cs | 132 ++++++---- .../MareSynchronosServer/Program.cs | 5 +- .../MareSynchronosServer/Startup.cs | 8 +- .../MareSynchronosServer/appsettings.json | 2 +- 34 files changed, 731 insertions(+), 2793 deletions(-) delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220629173313_InitialCreate.Designer.cs delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220629173313_InitialCreate.cs delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220629173544_AddForbiddenUploadEntry.Designer.cs delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220629173544_AddForbiddenUploadEntry.cs delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220629184351_AddBannedAdminAndReceivingMessages.Designer.cs delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220629184351_AddBannedAdminAndReceivingMessages.cs delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220629212721_AddBannedReason.Designer.cs delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220629212721_AddBannedReason.cs delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220629230923_ChangeAdminToModerator.Designer.cs delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220629230923_ChangeAdminToModerator.cs delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220704113233_RemoveCharacterData.Designer.cs delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220704113233_RemoveCharacterData.cs delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220710104014_AddTimestampToAllTables.Designer.cs delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220710104014_AddTimestampToAllTables.cs delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220712082237_SetMaxLengths.Designer.cs delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220712082237_SetMaxLengths.cs delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220712102941_ClientPairKey.Designer.cs delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220712102941_ClientPairKey.cs delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220713083057_MoveAuthToSeparateTable.Designer.cs delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220713083057_MoveAuthToSeparateTable.cs delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220713104127_AddIndexes.Designer.cs delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220713104127_AddIndexes.cs delete mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220718071653_UserLoginDateTime.cs rename MareSynchronosServer/MareSynchronosServer/Migrations/{20220718071653_UserLoginDateTime.Designer.cs => 20220731210149_InitialCreate.Designer.cs} (52%) create mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220731210149_InitialCreate.cs create mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220731211419_RenameLowerSnakeCase.Designer.cs create mode 100644 MareSynchronosServer/MareSynchronosServer/Migrations/20220731211419_RenameLowerSnakeCase.cs diff --git a/MareSynchronosServer/MareSynchronosServer/Data/MareDbContext.cs b/MareSynchronosServer/MareSynchronosServer/Data/MareDbContext.cs index 3b8cc99..f455ce3 100644 --- a/MareSynchronosServer/MareSynchronosServer/Data/MareDbContext.cs +++ b/MareSynchronosServer/MareSynchronosServer/Data/MareDbContext.cs @@ -19,17 +19,17 @@ namespace MareSynchronosServer.Data protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.Entity().ToTable("Auth"); - modelBuilder.Entity().ToTable("Users"); + modelBuilder.Entity().ToTable("auth"); + modelBuilder.Entity().ToTable("users"); modelBuilder.Entity().HasIndex(c => c.CharacterIdentification); - modelBuilder.Entity().ToTable("FileCaches"); + modelBuilder.Entity().ToTable("file_caches"); modelBuilder.Entity().HasIndex(c => c.UploaderUID); - modelBuilder.Entity().ToTable("ClientPairs"); + modelBuilder.Entity().ToTable("client_pairs"); modelBuilder.Entity().HasKey(u => new { u.UserUID, u.OtherUserUID }); modelBuilder.Entity().HasIndex(c => c.UserUID); modelBuilder.Entity().HasIndex(c => c.OtherUserUID); - modelBuilder.Entity().ToTable("ForbiddenUploadEntries"); - modelBuilder.Entity().ToTable("BannedUsers"); + modelBuilder.Entity().ToTable("forbidden_upload_entries"); + modelBuilder.Entity().ToTable("banned_users"); } } } diff --git a/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.User.cs b/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.User.cs index d594e5d..a92ee94 100644 --- a/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.User.cs +++ b/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.User.cs @@ -28,6 +28,11 @@ namespace MareSynchronosServer.Hubs var ownPairData = await _dbContext.ClientPairs.Where(u => u.User.UID == userid).ToListAsync(); var auth = await _dbContext.Auth.SingleAsync(u => u.UserUID == userid); + while (_dbContext.Files.Any(f => f.Uploader == userEntry)) + { + await Task.Delay(1000); + } + MareMetrics.Pairs.Dec(ownPairData.Count); MareMetrics.PairsPaused.Dec(ownPairData.Count(c => c.IsPaused)); diff --git a/MareSynchronosServer/MareSynchronosServer/MareSynchronosServer.csproj b/MareSynchronosServer/MareSynchronosServer/MareSynchronosServer.csproj index cb7a413..c1c417d 100644 --- a/MareSynchronosServer/MareSynchronosServer/MareSynchronosServer.csproj +++ b/MareSynchronosServer/MareSynchronosServer/MareSynchronosServer.csproj @@ -8,18 +8,19 @@ + - all runtime; build; native; contentfiles; analyzers; buildtransitive + @@ -28,4 +29,8 @@ + + + + diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220629173313_InitialCreate.Designer.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220629173313_InitialCreate.Designer.cs deleted file mode 100644 index 0f9da4e..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220629173313_InitialCreate.Designer.cs +++ /dev/null @@ -1,150 +0,0 @@ -// -using System; -using MareSynchronosServer.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - [DbContext(typeof(MareDbContext))] - [Migration("20220629173313_InitialCreate")] - partial class InitialCreate - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("MareSynchronosServer.Models.CharacterData", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("JobId") - .HasColumnType("int"); - - b.Property("CharacterCache") - .HasColumnType("nvarchar(max)"); - - b.Property("Hash") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId", "JobId"); - - b.ToTable("CharacterData", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("IsPaused") - .HasColumnType("bit"); - - b.Property("OtherUserUID") - .HasColumnType("nvarchar(450)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.Property("UserUID") - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("OtherUserUID"); - - b.HasIndex("UserUID"); - - b.ToTable("ClientPairs", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => - { - b.Property("Hash") - .HasColumnType("nvarchar(450)"); - - b.Property("LastAccessTime") - .HasColumnType("datetime2"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.Property("Uploaded") - .HasColumnType("bit"); - - b.Property("UploaderUID") - .HasColumnType("nvarchar(450)"); - - b.HasKey("Hash"); - - b.HasIndex("UploaderUID"); - - b.ToTable("FileCaches", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.User", b => - { - b.Property("UID") - .HasColumnType("nvarchar(450)"); - - b.Property("CharacterIdentification") - .HasColumnType("nvarchar(max)"); - - b.Property("SecretKey") - .HasColumnType("nvarchar(max)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("UID"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => - { - b.HasOne("MareSynchronosServer.Models.User", "OtherUser") - .WithMany() - .HasForeignKey("OtherUserUID"); - - b.HasOne("MareSynchronosServer.Models.User", "User") - .WithMany() - .HasForeignKey("UserUID"); - - b.Navigation("OtherUser"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => - { - b.HasOne("MareSynchronosServer.Models.User", "Uploader") - .WithMany() - .HasForeignKey("UploaderUID"); - - b.Navigation("Uploader"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220629173313_InitialCreate.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220629173313_InitialCreate.cs deleted file mode 100644 index 1d3fe7b..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220629173313_InitialCreate.cs +++ /dev/null @@ -1,117 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - public partial class InitialCreate : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "CharacterData", - columns: table => new - { - UserId = table.Column(type: "nvarchar(450)", nullable: false), - JobId = table.Column(type: "int", nullable: false), - CharacterCache = table.Column(type: "nvarchar(max)", nullable: true), - Hash = table.Column(type: "nvarchar(max)", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CharacterData", x => new { x.UserId, x.JobId }); - }); - - migrationBuilder.CreateTable( - name: "Users", - columns: table => new - { - UID = table.Column(type: "nvarchar(450)", nullable: false), - SecretKey = table.Column(type: "nvarchar(max)", nullable: true), - CharacterIdentification = table.Column(type: "nvarchar(max)", nullable: true), - Timestamp = table.Column(type: "rowversion", rowVersion: true, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Users", x => x.UID); - }); - - migrationBuilder.CreateTable( - name: "ClientPairs", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - UserUID = table.Column(type: "nvarchar(450)", nullable: true), - OtherUserUID = table.Column(type: "nvarchar(450)", nullable: true), - IsPaused = table.Column(type: "bit", nullable: false), - Timestamp = table.Column(type: "rowversion", rowVersion: true, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_ClientPairs", x => x.Id); - table.ForeignKey( - name: "FK_ClientPairs_Users_OtherUserUID", - column: x => x.OtherUserUID, - principalTable: "Users", - principalColumn: "UID"); - table.ForeignKey( - name: "FK_ClientPairs_Users_UserUID", - column: x => x.UserUID, - principalTable: "Users", - principalColumn: "UID"); - }); - - migrationBuilder.CreateTable( - name: "FileCaches", - columns: table => new - { - Hash = table.Column(type: "nvarchar(450)", nullable: false), - UploaderUID = table.Column(type: "nvarchar(450)", nullable: true), - Uploaded = table.Column(type: "bit", nullable: false), - LastAccessTime = table.Column(type: "datetime2", nullable: false), - Timestamp = table.Column(type: "rowversion", rowVersion: true, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_FileCaches", x => x.Hash); - table.ForeignKey( - name: "FK_FileCaches_Users_UploaderUID", - column: x => x.UploaderUID, - principalTable: "Users", - principalColumn: "UID"); - }); - - migrationBuilder.CreateIndex( - name: "IX_ClientPairs_OtherUserUID", - table: "ClientPairs", - column: "OtherUserUID"); - - migrationBuilder.CreateIndex( - name: "IX_ClientPairs_UserUID", - table: "ClientPairs", - column: "UserUID"); - - migrationBuilder.CreateIndex( - name: "IX_FileCaches_UploaderUID", - table: "FileCaches", - column: "UploaderUID"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "CharacterData"); - - migrationBuilder.DropTable( - name: "ClientPairs"); - - migrationBuilder.DropTable( - name: "FileCaches"); - - migrationBuilder.DropTable( - name: "Users"); - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220629173544_AddForbiddenUploadEntry.Designer.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220629173544_AddForbiddenUploadEntry.Designer.cs deleted file mode 100644 index f371318..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220629173544_AddForbiddenUploadEntry.Designer.cs +++ /dev/null @@ -1,163 +0,0 @@ -// -using System; -using MareSynchronosServer.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - [DbContext(typeof(MareDbContext))] - [Migration("20220629173544_AddForbiddenUploadEntry")] - partial class AddForbiddenUploadEntry - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("MareSynchronosServer.Models.CharacterData", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("JobId") - .HasColumnType("int"); - - b.Property("CharacterCache") - .HasColumnType("nvarchar(max)"); - - b.Property("Hash") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId", "JobId"); - - b.ToTable("CharacterData", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("IsPaused") - .HasColumnType("bit"); - - b.Property("OtherUserUID") - .HasColumnType("nvarchar(450)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.Property("UserUID") - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("OtherUserUID"); - - b.HasIndex("UserUID"); - - b.ToTable("ClientPairs", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => - { - b.Property("Hash") - .HasColumnType("nvarchar(450)"); - - b.Property("LastAccessTime") - .HasColumnType("datetime2"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.Property("Uploaded") - .HasColumnType("bit"); - - b.Property("UploaderUID") - .HasColumnType("nvarchar(450)"); - - b.HasKey("Hash"); - - b.HasIndex("UploaderUID"); - - b.ToTable("FileCaches", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ForbiddenUploadEntry", b => - { - b.Property("Hash") - .HasColumnType("nvarchar(450)"); - - b.Property("ForbiddenBy") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Hash"); - - b.ToTable("ForbiddenUploadEntries", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.User", b => - { - b.Property("UID") - .HasColumnType("nvarchar(450)"); - - b.Property("CharacterIdentification") - .HasColumnType("nvarchar(max)"); - - b.Property("SecretKey") - .HasColumnType("nvarchar(max)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("UID"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => - { - b.HasOne("MareSynchronosServer.Models.User", "OtherUser") - .WithMany() - .HasForeignKey("OtherUserUID"); - - b.HasOne("MareSynchronosServer.Models.User", "User") - .WithMany() - .HasForeignKey("UserUID"); - - b.Navigation("OtherUser"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => - { - b.HasOne("MareSynchronosServer.Models.User", "Uploader") - .WithMany() - .HasForeignKey("UploaderUID"); - - b.Navigation("Uploader"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220629173544_AddForbiddenUploadEntry.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220629173544_AddForbiddenUploadEntry.cs deleted file mode 100644 index f2761a3..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220629173544_AddForbiddenUploadEntry.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - public partial class AddForbiddenUploadEntry : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "ForbiddenUploadEntries", - columns: table => new - { - Hash = table.Column(type: "nvarchar(450)", nullable: false), - ForbiddenBy = table.Column(type: "nvarchar(max)", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_ForbiddenUploadEntries", x => x.Hash); - }); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "ForbiddenUploadEntries"); - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220629184351_AddBannedAdminAndReceivingMessages.Designer.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220629184351_AddBannedAdminAndReceivingMessages.Designer.cs deleted file mode 100644 index 8f4098d..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220629184351_AddBannedAdminAndReceivingMessages.Designer.cs +++ /dev/null @@ -1,179 +0,0 @@ -// -using System; -using MareSynchronosServer.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - [DbContext(typeof(MareDbContext))] - [Migration("20220629184351_AddBannedAdminAndReceivingMessages")] - partial class AddBannedAdminAndReceivingMessages - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("MareSynchronosServer.Models.Banned", b => - { - b.Property("CharacterIdentification") - .HasColumnType("nvarchar(450)"); - - b.HasKey("CharacterIdentification"); - - b.ToTable("BannedUsers", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.CharacterData", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("JobId") - .HasColumnType("int"); - - b.Property("CharacterCache") - .HasColumnType("nvarchar(max)"); - - b.Property("Hash") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId", "JobId"); - - b.ToTable("CharacterData", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("AllowReceivingMessages") - .HasColumnType("bit"); - - b.Property("IsPaused") - .HasColumnType("bit"); - - b.Property("OtherUserUID") - .HasColumnType("nvarchar(450)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.Property("UserUID") - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("OtherUserUID"); - - b.HasIndex("UserUID"); - - b.ToTable("ClientPairs", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => - { - b.Property("Hash") - .HasColumnType("nvarchar(450)"); - - b.Property("LastAccessTime") - .HasColumnType("datetime2"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.Property("Uploaded") - .HasColumnType("bit"); - - b.Property("UploaderUID") - .HasColumnType("nvarchar(450)"); - - b.HasKey("Hash"); - - b.HasIndex("UploaderUID"); - - b.ToTable("FileCaches", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ForbiddenUploadEntry", b => - { - b.Property("Hash") - .HasColumnType("nvarchar(450)"); - - b.Property("ForbiddenBy") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Hash"); - - b.ToTable("ForbiddenUploadEntries", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.User", b => - { - b.Property("UID") - .HasColumnType("nvarchar(450)"); - - b.Property("CharacterIdentification") - .HasColumnType("nvarchar(max)"); - - b.Property("IsAdmin") - .HasColumnType("bit"); - - b.Property("SecretKey") - .HasColumnType("nvarchar(max)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("UID"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => - { - b.HasOne("MareSynchronosServer.Models.User", "OtherUser") - .WithMany() - .HasForeignKey("OtherUserUID"); - - b.HasOne("MareSynchronosServer.Models.User", "User") - .WithMany() - .HasForeignKey("UserUID"); - - b.Navigation("OtherUser"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => - { - b.HasOne("MareSynchronosServer.Models.User", "Uploader") - .WithMany() - .HasForeignKey("UploaderUID"); - - b.Navigation("Uploader"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220629184351_AddBannedAdminAndReceivingMessages.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220629184351_AddBannedAdminAndReceivingMessages.cs deleted file mode 100644 index 310bf7b..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220629184351_AddBannedAdminAndReceivingMessages.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - public partial class AddBannedAdminAndReceivingMessages : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "IsAdmin", - table: "Users", - type: "bit", - nullable: false, - defaultValue: false); - - migrationBuilder.AddColumn( - name: "AllowReceivingMessages", - table: "ClientPairs", - type: "bit", - nullable: false, - defaultValue: false); - - migrationBuilder.CreateTable( - name: "BannedUsers", - columns: table => new - { - CharacterIdentification = table.Column(type: "nvarchar(450)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_BannedUsers", x => x.CharacterIdentification); - }); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "BannedUsers"); - - migrationBuilder.DropColumn( - name: "IsAdmin", - table: "Users"); - - migrationBuilder.DropColumn( - name: "AllowReceivingMessages", - table: "ClientPairs"); - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220629212721_AddBannedReason.Designer.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220629212721_AddBannedReason.Designer.cs deleted file mode 100644 index f16feff..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220629212721_AddBannedReason.Designer.cs +++ /dev/null @@ -1,182 +0,0 @@ -// -using System; -using MareSynchronosServer.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - [DbContext(typeof(MareDbContext))] - [Migration("20220629212721_AddBannedReason")] - partial class AddBannedReason - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("MareSynchronosServer.Models.Banned", b => - { - b.Property("CharacterIdentification") - .HasColumnType("nvarchar(450)"); - - b.Property("Reason") - .HasColumnType("nvarchar(max)"); - - b.HasKey("CharacterIdentification"); - - b.ToTable("BannedUsers", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.CharacterData", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("JobId") - .HasColumnType("int"); - - b.Property("CharacterCache") - .HasColumnType("nvarchar(max)"); - - b.Property("Hash") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId", "JobId"); - - b.ToTable("CharacterData", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("AllowReceivingMessages") - .HasColumnType("bit"); - - b.Property("IsPaused") - .HasColumnType("bit"); - - b.Property("OtherUserUID") - .HasColumnType("nvarchar(450)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.Property("UserUID") - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("OtherUserUID"); - - b.HasIndex("UserUID"); - - b.ToTable("ClientPairs", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => - { - b.Property("Hash") - .HasColumnType("nvarchar(450)"); - - b.Property("LastAccessTime") - .HasColumnType("datetime2"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.Property("Uploaded") - .HasColumnType("bit"); - - b.Property("UploaderUID") - .HasColumnType("nvarchar(450)"); - - b.HasKey("Hash"); - - b.HasIndex("UploaderUID"); - - b.ToTable("FileCaches", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ForbiddenUploadEntry", b => - { - b.Property("Hash") - .HasColumnType("nvarchar(450)"); - - b.Property("ForbiddenBy") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Hash"); - - b.ToTable("ForbiddenUploadEntries", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.User", b => - { - b.Property("UID") - .HasColumnType("nvarchar(450)"); - - b.Property("CharacterIdentification") - .HasColumnType("nvarchar(max)"); - - b.Property("IsAdmin") - .HasColumnType("bit"); - - b.Property("SecretKey") - .HasColumnType("nvarchar(max)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("UID"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => - { - b.HasOne("MareSynchronosServer.Models.User", "OtherUser") - .WithMany() - .HasForeignKey("OtherUserUID"); - - b.HasOne("MareSynchronosServer.Models.User", "User") - .WithMany() - .HasForeignKey("UserUID"); - - b.Navigation("OtherUser"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => - { - b.HasOne("MareSynchronosServer.Models.User", "Uploader") - .WithMany() - .HasForeignKey("UploaderUID"); - - b.Navigation("Uploader"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220629212721_AddBannedReason.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220629212721_AddBannedReason.cs deleted file mode 100644 index 9a76727..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220629212721_AddBannedReason.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - public partial class AddBannedReason : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Reason", - table: "BannedUsers", - type: "nvarchar(max)", - nullable: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Reason", - table: "BannedUsers"); - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220629230923_ChangeAdminToModerator.Designer.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220629230923_ChangeAdminToModerator.Designer.cs deleted file mode 100644 index e5642a9..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220629230923_ChangeAdminToModerator.Designer.cs +++ /dev/null @@ -1,185 +0,0 @@ -// -using System; -using MareSynchronosServer.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - [DbContext(typeof(MareDbContext))] - [Migration("20220629230923_ChangeAdminToModerator")] - partial class ChangeAdminToModerator - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("MareSynchronosServer.Models.Banned", b => - { - b.Property("CharacterIdentification") - .HasColumnType("nvarchar(450)"); - - b.Property("Reason") - .HasColumnType("nvarchar(max)"); - - b.HasKey("CharacterIdentification"); - - b.ToTable("BannedUsers", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.CharacterData", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("JobId") - .HasColumnType("int"); - - b.Property("CharacterCache") - .HasColumnType("nvarchar(max)"); - - b.Property("Hash") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId", "JobId"); - - b.ToTable("CharacterData", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("AllowReceivingMessages") - .HasColumnType("bit"); - - b.Property("IsPaused") - .HasColumnType("bit"); - - b.Property("OtherUserUID") - .HasColumnType("nvarchar(450)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.Property("UserUID") - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("OtherUserUID"); - - b.HasIndex("UserUID"); - - b.ToTable("ClientPairs", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => - { - b.Property("Hash") - .HasColumnType("nvarchar(450)"); - - b.Property("LastAccessTime") - .HasColumnType("datetime2"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.Property("Uploaded") - .HasColumnType("bit"); - - b.Property("UploaderUID") - .HasColumnType("nvarchar(450)"); - - b.HasKey("Hash"); - - b.HasIndex("UploaderUID"); - - b.ToTable("FileCaches", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ForbiddenUploadEntry", b => - { - b.Property("Hash") - .HasColumnType("nvarchar(450)"); - - b.Property("ForbiddenBy") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Hash"); - - b.ToTable("ForbiddenUploadEntries", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.User", b => - { - b.Property("UID") - .HasColumnType("nvarchar(450)"); - - b.Property("CharacterIdentification") - .HasColumnType("nvarchar(max)"); - - b.Property("IsAdmin") - .HasColumnType("bit"); - - b.Property("IsModerator") - .HasColumnType("bit"); - - b.Property("SecretKey") - .HasColumnType("nvarchar(max)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("UID"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => - { - b.HasOne("MareSynchronosServer.Models.User", "OtherUser") - .WithMany() - .HasForeignKey("OtherUserUID"); - - b.HasOne("MareSynchronosServer.Models.User", "User") - .WithMany() - .HasForeignKey("UserUID"); - - b.Navigation("OtherUser"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => - { - b.HasOne("MareSynchronosServer.Models.User", "Uploader") - .WithMany() - .HasForeignKey("UploaderUID"); - - b.Navigation("Uploader"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220629230923_ChangeAdminToModerator.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220629230923_ChangeAdminToModerator.cs deleted file mode 100644 index 2f21a6b..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220629230923_ChangeAdminToModerator.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - public partial class ChangeAdminToModerator : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "IsModerator", - table: "Users", - type: "bit", - nullable: false, - defaultValue: false); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "IsModerator", - table: "Users"); - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220704113233_RemoveCharacterData.Designer.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220704113233_RemoveCharacterData.Designer.cs deleted file mode 100644 index ef7185a..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220704113233_RemoveCharacterData.Designer.cs +++ /dev/null @@ -1,166 +0,0 @@ -// -using System; -using MareSynchronosServer.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - [DbContext(typeof(MareDbContext))] - [Migration("20220704113233_RemoveCharacterData")] - partial class RemoveCharacterData - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("MareSynchronosServer.Models.Banned", b => - { - b.Property("CharacterIdentification") - .HasColumnType("nvarchar(450)"); - - b.Property("Reason") - .HasColumnType("nvarchar(max)"); - - b.HasKey("CharacterIdentification"); - - b.ToTable("BannedUsers", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("AllowReceivingMessages") - .HasColumnType("bit"); - - b.Property("IsPaused") - .HasColumnType("bit"); - - b.Property("OtherUserUID") - .HasColumnType("nvarchar(450)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.Property("UserUID") - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("OtherUserUID"); - - b.HasIndex("UserUID"); - - b.ToTable("ClientPairs", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => - { - b.Property("Hash") - .HasColumnType("nvarchar(450)"); - - b.Property("LastAccessTime") - .HasColumnType("datetime2"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.Property("Uploaded") - .HasColumnType("bit"); - - b.Property("UploaderUID") - .HasColumnType("nvarchar(450)"); - - b.HasKey("Hash"); - - b.HasIndex("UploaderUID"); - - b.ToTable("FileCaches", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ForbiddenUploadEntry", b => - { - b.Property("Hash") - .HasColumnType("nvarchar(450)"); - - b.Property("ForbiddenBy") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Hash"); - - b.ToTable("ForbiddenUploadEntries", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.User", b => - { - b.Property("UID") - .HasColumnType("nvarchar(450)"); - - b.Property("CharacterIdentification") - .HasColumnType("nvarchar(max)"); - - b.Property("IsAdmin") - .HasColumnType("bit"); - - b.Property("IsModerator") - .HasColumnType("bit"); - - b.Property("SecretKey") - .HasColumnType("nvarchar(max)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("UID"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => - { - b.HasOne("MareSynchronosServer.Models.User", "OtherUser") - .WithMany() - .HasForeignKey("OtherUserUID"); - - b.HasOne("MareSynchronosServer.Models.User", "User") - .WithMany() - .HasForeignKey("UserUID"); - - b.Navigation("OtherUser"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => - { - b.HasOne("MareSynchronosServer.Models.User", "Uploader") - .WithMany() - .HasForeignKey("UploaderUID"); - - b.Navigation("Uploader"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220704113233_RemoveCharacterData.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220704113233_RemoveCharacterData.cs deleted file mode 100644 index d2b5ad1..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220704113233_RemoveCharacterData.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - public partial class RemoveCharacterData : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "CharacterData"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "CharacterData", - columns: table => new - { - UserId = table.Column(type: "nvarchar(450)", nullable: false), - JobId = table.Column(type: "int", nullable: false), - CharacterCache = table.Column(type: "nvarchar(max)", nullable: true), - Hash = table.Column(type: "nvarchar(max)", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CharacterData", x => new { x.UserId, x.JobId }); - }); - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220710104014_AddTimestampToAllTables.Designer.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220710104014_AddTimestampToAllTables.Designer.cs deleted file mode 100644 index 7a30d66..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220710104014_AddTimestampToAllTables.Designer.cs +++ /dev/null @@ -1,176 +0,0 @@ -// -using System; -using MareSynchronosServer.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - [DbContext(typeof(MareDbContext))] - [Migration("20220710104014_AddTimestampToAllTables")] - partial class AddTimestampToAllTables - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("MareSynchronosServer.Models.Banned", b => - { - b.Property("CharacterIdentification") - .HasColumnType("nvarchar(450)"); - - b.Property("Reason") - .HasColumnType("nvarchar(max)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("CharacterIdentification"); - - b.ToTable("BannedUsers", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("AllowReceivingMessages") - .HasColumnType("bit"); - - b.Property("IsPaused") - .HasColumnType("bit"); - - b.Property("OtherUserUID") - .HasColumnType("nvarchar(450)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.Property("UserUID") - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("OtherUserUID"); - - b.HasIndex("UserUID"); - - b.ToTable("ClientPairs", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => - { - b.Property("Hash") - .HasColumnType("nvarchar(450)"); - - b.Property("LastAccessTime") - .HasColumnType("datetime2"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.Property("Uploaded") - .HasColumnType("bit"); - - b.Property("UploaderUID") - .HasColumnType("nvarchar(450)"); - - b.HasKey("Hash"); - - b.HasIndex("UploaderUID"); - - b.ToTable("FileCaches", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ForbiddenUploadEntry", b => - { - b.Property("Hash") - .HasColumnType("nvarchar(450)"); - - b.Property("ForbiddenBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("Hash"); - - b.ToTable("ForbiddenUploadEntries", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.User", b => - { - b.Property("UID") - .HasColumnType("nvarchar(450)"); - - b.Property("CharacterIdentification") - .HasColumnType("nvarchar(max)"); - - b.Property("IsAdmin") - .HasColumnType("bit"); - - b.Property("IsModerator") - .HasColumnType("bit"); - - b.Property("SecretKey") - .HasColumnType("nvarchar(max)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("UID"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => - { - b.HasOne("MareSynchronosServer.Models.User", "OtherUser") - .WithMany() - .HasForeignKey("OtherUserUID"); - - b.HasOne("MareSynchronosServer.Models.User", "User") - .WithMany() - .HasForeignKey("UserUID"); - - b.Navigation("OtherUser"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => - { - b.HasOne("MareSynchronosServer.Models.User", "Uploader") - .WithMany() - .HasForeignKey("UploaderUID"); - - b.Navigation("Uploader"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220710104014_AddTimestampToAllTables.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220710104014_AddTimestampToAllTables.cs deleted file mode 100644 index 01836c3..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220710104014_AddTimestampToAllTables.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - public partial class AddTimestampToAllTables : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Timestamp", - table: "ForbiddenUploadEntries", - type: "rowversion", - rowVersion: true, - nullable: true); - - migrationBuilder.AddColumn( - name: "Timestamp", - table: "BannedUsers", - type: "rowversion", - rowVersion: true, - nullable: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Timestamp", - table: "ForbiddenUploadEntries"); - - migrationBuilder.DropColumn( - name: "Timestamp", - table: "BannedUsers"); - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220712082237_SetMaxLengths.Designer.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220712082237_SetMaxLengths.Designer.cs deleted file mode 100644 index 4a89585..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220712082237_SetMaxLengths.Designer.cs +++ /dev/null @@ -1,175 +0,0 @@ -// -using System; -using MareSynchronosServer.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - [DbContext(typeof(MareDbContext))] - [Migration("20220712082237_SetMaxLengths")] - partial class SetMaxLengths - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("MareSynchronosServer.Models.Banned", b => - { - b.Property("CharacterIdentification") - .HasColumnType("nvarchar(450)"); - - b.Property("Reason") - .HasColumnType("nvarchar(max)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("CharacterIdentification"); - - b.ToTable("BannedUsers", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("AllowReceivingMessages") - .HasColumnType("bit"); - - b.Property("IsPaused") - .HasColumnType("bit"); - - b.Property("OtherUserUID") - .HasColumnType("nvarchar(10)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.Property("UserUID") - .HasColumnType("nvarchar(10)"); - - b.HasKey("Id"); - - b.HasIndex("OtherUserUID"); - - b.HasIndex("UserUID"); - - b.ToTable("ClientPairs", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => - { - b.Property("Hash") - .HasMaxLength(20) - .HasColumnType("nvarchar(40)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.Property("Uploaded") - .HasColumnType("bit"); - - b.Property("UploaderUID") - .HasColumnType("nvarchar(10)"); - - b.HasKey("Hash"); - - b.HasIndex("UploaderUID"); - - b.ToTable("FileCaches", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ForbiddenUploadEntry", b => - { - b.Property("Hash") - .HasColumnType("nvarchar(450)"); - - b.Property("ForbiddenBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("Hash"); - - b.ToTable("ForbiddenUploadEntries", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.User", b => - { - b.Property("UID") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b.Property("CharacterIdentification") - .HasColumnType("nvarchar(max)"); - - b.Property("IsAdmin") - .HasColumnType("bit"); - - b.Property("IsModerator") - .HasColumnType("bit"); - - b.Property("SecretKey") - .HasColumnType("nvarchar(max)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("UID"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => - { - b.HasOne("MareSynchronosServer.Models.User", "OtherUser") - .WithMany() - .HasForeignKey("OtherUserUID"); - - b.HasOne("MareSynchronosServer.Models.User", "User") - .WithMany() - .HasForeignKey("UserUID"); - - b.Navigation("OtherUser"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => - { - b.HasOne("MareSynchronosServer.Models.User", "Uploader") - .WithMany() - .HasForeignKey("UploaderUID"); - - b.Navigation("Uploader"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220712082237_SetMaxLengths.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220712082237_SetMaxLengths.cs deleted file mode 100644 index fc8c77a..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220712082237_SetMaxLengths.cs +++ /dev/null @@ -1,141 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - public partial class SetMaxLengths : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "LastAccessTime", - table: "FileCaches"); - - migrationBuilder.DropForeignKey("FK_FileCaches_Users_UploaderUID", "FileCaches"); - migrationBuilder.DropForeignKey("FK_ClientPairs_Users_UserUID", "ClientPairs"); - migrationBuilder.DropForeignKey("FK_ClientPairs_Users_OtherUserUID", "ClientPairs"); - migrationBuilder.DropPrimaryKey("PK_FileCaches", "FileCaches"); - migrationBuilder.DropPrimaryKey("PK_Users", "Users"); - - migrationBuilder.AlterColumn( - name: "UploaderUID", - table: "FileCaches", - type: "nvarchar(10)", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(450)", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Hash", - table: "FileCaches", - type: "nvarchar(40)", - maxLength: 20, - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(450)"); - - migrationBuilder.AlterColumn( - name: "UserUID", - table: "ClientPairs", - type: "nvarchar(10)", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(450)", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "OtherUserUID", - table: "ClientPairs", - type: "nvarchar(10)", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(450)", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "UID", - table: "Users", - type: "nvarchar(10)", - maxLength: 10, - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(450)"); - - migrationBuilder.AddPrimaryKey("PK_Users", "Users", "UID"); - migrationBuilder.AddPrimaryKey("PK_FileCaches", "FileCaches", "Hash"); - migrationBuilder.AddForeignKey("FK_FileCaches_Users_UploaderUID", "FileCaches", "UploaderUID", "Users"); - migrationBuilder.AddForeignKey("FK_ClientPairs_Users_UserUID", "ClientPairs", "UserUID", "Users"); - migrationBuilder.AddForeignKey("FK_ClientPairs_Users_OtherUserUID", "ClientPairs", "UserUID", "Users"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey("FK_FileCaches_Users_UploaderUID", "FileCaches"); - migrationBuilder.DropForeignKey("FK_ClientPairs_Users_UserUID", "ClientPairs"); - migrationBuilder.DropForeignKey("FK_ClientPairs_Users_OtherUserUID", "ClientPairs"); - migrationBuilder.DropPrimaryKey("PK_FileCaches", "FileCaches"); - migrationBuilder.DropPrimaryKey("PK_Users", "Users"); - - migrationBuilder.AlterColumn( - name: "UID", - table: "Users", - type: "nvarchar(450)", - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(10)", - oldMaxLength: 10); - - migrationBuilder.AlterColumn( - name: "UploaderUID", - table: "FileCaches", - type: "nvarchar(450)", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(10)", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Hash", - table: "FileCaches", - type: "nvarchar(450)", - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(20)", - oldMaxLength: 20); - - migrationBuilder.AddColumn( - name: "LastAccessTime", - table: "FileCaches", - type: "datetime2", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - - migrationBuilder.AlterColumn( - name: "UserUID", - table: "ClientPairs", - type: "nvarchar(450)", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(10)", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "OtherUserUID", - table: "ClientPairs", - type: "nvarchar(450)", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(10)", - oldNullable: true); - - migrationBuilder.AddPrimaryKey("PK_Users", "Users", "UID"); - migrationBuilder.AddPrimaryKey("PK_FileCaches", "FileCaches", "Hash"); - migrationBuilder.AddForeignKey("FK_FileCaches_Users_UploaderUID", "FileCaches", "UploaderUID", "Users"); - migrationBuilder.AddForeignKey("FK_ClientPairs_Users_UserUID", "ClientPairs", "UserUID", "Users"); - migrationBuilder.AddForeignKey("FK_ClientPairs_Users_OtherUserUID", "ClientPairs", "UserUID", "Users"); - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220712102941_ClientPairKey.Designer.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220712102941_ClientPairKey.Designer.cs deleted file mode 100644 index f5c7073..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220712102941_ClientPairKey.Designer.cs +++ /dev/null @@ -1,175 +0,0 @@ -// -using System; -using MareSynchronosServer.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - [DbContext(typeof(MareDbContext))] - [Migration("20220712102941_ClientPairKey")] - partial class ClientPairKey - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("MareSynchronosServer.Models.Banned", b => - { - b.Property("CharacterIdentification") - .HasColumnType("nvarchar(450)"); - - b.Property("Reason") - .HasColumnType("nvarchar(max)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("CharacterIdentification"); - - b.ToTable("BannedUsers", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => - { - b.Property("UserUID") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b.Property("OtherUserUID") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b.Property("AllowReceivingMessages") - .HasColumnType("bit"); - - b.Property("IsPaused") - .HasColumnType("bit"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("UserUID", "OtherUserUID"); - - b.HasIndex("OtherUserUID"); - - b.HasIndex("UserUID"); - - b.ToTable("ClientPairs", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => - { - b.Property("Hash") - .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.Property("Uploaded") - .HasColumnType("bit"); - - b.Property("UploaderUID") - .HasColumnType("nvarchar(10)"); - - b.HasKey("Hash"); - - b.HasIndex("UploaderUID"); - - b.ToTable("FileCaches", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ForbiddenUploadEntry", b => - { - b.Property("Hash") - .HasColumnType("nvarchar(450)"); - - b.Property("ForbiddenBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("Hash"); - - b.ToTable("ForbiddenUploadEntries", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.User", b => - { - b.Property("UID") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b.Property("CharacterIdentification") - .HasColumnType("nvarchar(max)"); - - b.Property("IsAdmin") - .HasColumnType("bit"); - - b.Property("IsModerator") - .HasColumnType("bit"); - - b.Property("SecretKey") - .HasColumnType("nvarchar(max)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("UID"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => - { - b.HasOne("MareSynchronosServer.Models.User", "OtherUser") - .WithMany() - .HasForeignKey("OtherUserUID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MareSynchronosServer.Models.User", "User") - .WithMany() - .HasForeignKey("UserUID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("OtherUser"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => - { - b.HasOne("MareSynchronosServer.Models.User", "Uploader") - .WithMany() - .HasForeignKey("UploaderUID"); - - b.Navigation("Uploader"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220712102941_ClientPairKey.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220712102941_ClientPairKey.cs deleted file mode 100644 index f812b37..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220712102941_ClientPairKey.cs +++ /dev/null @@ -1,131 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - public partial class ClientPairKey : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_ClientPairs_Users_OtherUserUID", - table: "ClientPairs"); - - migrationBuilder.DropForeignKey( - name: "FK_ClientPairs_Users_UserUID", - table: "ClientPairs"); - - migrationBuilder.DropPrimaryKey( - name: "PK_ClientPairs", - table: "ClientPairs"); - - migrationBuilder.DropColumn( - name: "Id", - table: "ClientPairs"); - - migrationBuilder.AlterColumn( - name: "UserUID", - table: "ClientPairs", - type: "nvarchar(10)", - maxLength: 10, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "nvarchar(10)", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "OtherUserUID", - table: "ClientPairs", - type: "nvarchar(10)", - maxLength: 10, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "nvarchar(10)", - oldNullable: true); - - migrationBuilder.AddPrimaryKey( - name: "PK_ClientPairs", - table: "ClientPairs", - columns: new[] { "UserUID", "OtherUserUID" }); - - migrationBuilder.AddForeignKey( - name: "FK_ClientPairs_Users_OtherUserUID", - table: "ClientPairs", - column: "OtherUserUID", - principalTable: "Users", - principalColumn: "UID", - onDelete: ReferentialAction.NoAction); - - migrationBuilder.AddForeignKey( - name: "FK_ClientPairs_Users_UserUID", - table: "ClientPairs", - column: "UserUID", - principalTable: "Users", - principalColumn: "UID", - onDelete: ReferentialAction.NoAction); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_ClientPairs_Users_OtherUserUID", - table: "ClientPairs"); - - migrationBuilder.DropForeignKey( - name: "FK_ClientPairs_Users_UserUID", - table: "ClientPairs"); - - migrationBuilder.DropPrimaryKey( - name: "PK_ClientPairs", - table: "ClientPairs"); - - migrationBuilder.AlterColumn( - name: "OtherUserUID", - table: "ClientPairs", - type: "nvarchar(10)", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(10)", - oldMaxLength: 10); - - migrationBuilder.AlterColumn( - name: "UserUID", - table: "ClientPairs", - type: "nvarchar(10)", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(10)", - oldMaxLength: 10); - - migrationBuilder.AddColumn( - name: "Id", - table: "ClientPairs", - type: "int", - nullable: false, - defaultValue: 0) - .Annotation("SqlServer:Identity", "1, 1"); - - migrationBuilder.AddPrimaryKey( - name: "PK_ClientPairs", - table: "ClientPairs", - column: "Id"); - - migrationBuilder.AddForeignKey( - name: "FK_ClientPairs_Users_OtherUserUID", - table: "ClientPairs", - column: "OtherUserUID", - principalTable: "Users", - principalColumn: "UID"); - - migrationBuilder.AddForeignKey( - name: "FK_ClientPairs_Users_UserUID", - table: "ClientPairs", - column: "UserUID", - principalTable: "Users", - principalColumn: "UID"); - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220713083057_MoveAuthToSeparateTable.Designer.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220713083057_MoveAuthToSeparateTable.Designer.cs deleted file mode 100644 index b17fa3b..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220713083057_MoveAuthToSeparateTable.Designer.cs +++ /dev/null @@ -1,197 +0,0 @@ -// -using System; -using MareSynchronosServer.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - [DbContext(typeof(MareDbContext))] - [Migration("20220713083057_MoveAuthToSeparateTable")] - partial class MoveAuthToSeparateTable - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("MareSynchronosServer.Models.Auth", b => - { - b.Property("HashedKey") - .HasMaxLength(64) - .HasColumnType("nvarchar(64)"); - - b.Property("UserUID") - .HasColumnType("nvarchar(10)"); - - b.HasKey("HashedKey"); - - b.HasIndex("UserUID"); - - b.ToTable("Auth", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.Banned", b => - { - b.Property("CharacterIdentification") - .HasColumnType("nvarchar(450)"); - - b.Property("Reason") - .HasColumnType("nvarchar(max)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("CharacterIdentification"); - - b.ToTable("BannedUsers", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => - { - b.Property("UserUID") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b.Property("OtherUserUID") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b.Property("AllowReceivingMessages") - .HasColumnType("bit"); - - b.Property("IsPaused") - .HasColumnType("bit"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("UserUID", "OtherUserUID"); - - b.HasIndex("OtherUserUID"); - - b.HasIndex("UserUID"); - - b.ToTable("ClientPairs", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => - { - b.Property("Hash") - .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.Property("Uploaded") - .HasColumnType("bit"); - - b.Property("UploaderUID") - .HasColumnType("nvarchar(10)"); - - b.HasKey("Hash"); - - b.HasIndex("UploaderUID"); - - b.ToTable("FileCaches", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ForbiddenUploadEntry", b => - { - b.Property("Hash") - .HasColumnType("nvarchar(450)"); - - b.Property("ForbiddenBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("Hash"); - - b.ToTable("ForbiddenUploadEntries", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.User", b => - { - b.Property("UID") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b.Property("CharacterIdentification") - .HasColumnType("nvarchar(max)"); - - b.Property("IsAdmin") - .HasColumnType("bit"); - - b.Property("IsModerator") - .HasColumnType("bit"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("UID"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.Auth", b => - { - b.HasOne("MareSynchronosServer.Models.User", "User") - .WithMany() - .HasForeignKey("UserUID"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => - { - b.HasOne("MareSynchronosServer.Models.User", "OtherUser") - .WithMany() - .HasForeignKey("OtherUserUID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MareSynchronosServer.Models.User", "User") - .WithMany() - .HasForeignKey("UserUID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("OtherUser"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => - { - b.HasOne("MareSynchronosServer.Models.User", "Uploader") - .WithMany() - .HasForeignKey("UploaderUID"); - - b.Navigation("Uploader"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220713083057_MoveAuthToSeparateTable.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220713083057_MoveAuthToSeparateTable.cs deleted file mode 100644 index 10e52a3..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220713083057_MoveAuthToSeparateTable.cs +++ /dev/null @@ -1,53 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - public partial class MoveAuthToSeparateTable : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Auth", - columns: table => new - { - HashedKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - UserUID = table.Column(type: "nvarchar(10)", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Auth", x => x.HashedKey); - table.ForeignKey( - name: "FK_Auth_Users_UserUID", - column: x => x.UserUID, - principalTable: "Users", - principalColumn: "UID"); - }); - - migrationBuilder.Sql("INSERT INTO Auth SELECT SecretKey, UID FROM Users"); - - migrationBuilder.DropColumn( - name: "SecretKey", - table: "Users"); - - migrationBuilder.CreateIndex( - name: "IX_Auth_UserUID", - table: "Auth", - column: "UserUID"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Auth"); - - migrationBuilder.AddColumn( - name: "SecretKey", - table: "Users", - type: "nvarchar(max)", - nullable: true); - - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220713104127_AddIndexes.Designer.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220713104127_AddIndexes.Designer.cs deleted file mode 100644 index ca4953f..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220713104127_AddIndexes.Designer.cs +++ /dev/null @@ -1,200 +0,0 @@ -// -using System; -using MareSynchronosServer.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - [DbContext(typeof(MareDbContext))] - [Migration("20220713104127_AddIndexes")] - partial class AddIndexes - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("MareSynchronosServer.Models.Auth", b => - { - b.Property("HashedKey") - .HasMaxLength(64) - .HasColumnType("nvarchar(64)"); - - b.Property("UserUID") - .HasColumnType("nvarchar(10)"); - - b.HasKey("HashedKey"); - - b.HasIndex("UserUID"); - - b.ToTable("Auth", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.Banned", b => - { - b.Property("CharacterIdentification") - .HasColumnType("nvarchar(450)"); - - b.Property("Reason") - .HasColumnType("nvarchar(max)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("CharacterIdentification"); - - b.ToTable("BannedUsers", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => - { - b.Property("UserUID") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b.Property("OtherUserUID") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b.Property("AllowReceivingMessages") - .HasColumnType("bit"); - - b.Property("IsPaused") - .HasColumnType("bit"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("UserUID", "OtherUserUID"); - - b.HasIndex("OtherUserUID"); - - b.HasIndex("UserUID"); - - b.ToTable("ClientPairs", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => - { - b.Property("Hash") - .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.Property("Uploaded") - .HasColumnType("bit"); - - b.Property("UploaderUID") - .HasColumnType("nvarchar(10)"); - - b.HasKey("Hash"); - - b.HasIndex("UploaderUID"); - - b.ToTable("FileCaches", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ForbiddenUploadEntry", b => - { - b.Property("Hash") - .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); - - b.Property("ForbiddenBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("Hash"); - - b.ToTable("ForbiddenUploadEntries", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.User", b => - { - b.Property("UID") - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b.Property("CharacterIdentification") - .HasColumnType("nvarchar(450)"); - - b.Property("IsAdmin") - .HasColumnType("bit"); - - b.Property("IsModerator") - .HasColumnType("bit"); - - b.Property("Timestamp") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); - - b.HasKey("UID"); - - b.HasIndex("CharacterIdentification"); - - b.ToTable("Users", (string)null); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.Auth", b => - { - b.HasOne("MareSynchronosServer.Models.User", "User") - .WithMany() - .HasForeignKey("UserUID"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => - { - b.HasOne("MareSynchronosServer.Models.User", "OtherUser") - .WithMany() - .HasForeignKey("OtherUserUID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MareSynchronosServer.Models.User", "User") - .WithMany() - .HasForeignKey("UserUID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("OtherUser"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => - { - b.HasOne("MareSynchronosServer.Models.User", "Uploader") - .WithMany() - .HasForeignKey("UploaderUID"); - - b.Navigation("Uploader"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220713104127_AddIndexes.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220713104127_AddIndexes.cs deleted file mode 100644 index 82dc742..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220713104127_AddIndexes.cs +++ /dev/null @@ -1,72 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - public partial class AddIndexes : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "CharacterIdentification", - table: "Users", - type: "nvarchar(450)", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(max)", - oldNullable: true); - - migrationBuilder.DropPrimaryKey( - name: "PK_ForbiddenUploadEntries", - table: "ForbiddenUploadEntries"); - - migrationBuilder.AlterColumn( - name: "Hash", - table: "ForbiddenUploadEntries", - type: "nvarchar(40)", - maxLength: 40, - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(450)"); - - migrationBuilder.AddPrimaryKey( - name: "PK_ForbiddenUploadEntries", - table: "ForbiddenUploadEntries", - column: "Hash"); - - migrationBuilder.CreateIndex( - name: "IX_Users_CharacterIdentification", - table: "Users", - column: "CharacterIdentification"); - - migrationBuilder.Sql("ALTER DATABASE CURRENT SET ALLOW_SNAPSHOT_ISOLATION ON", true); - migrationBuilder.Sql("ALTER DATABASE CURRENT SET READ_COMMITTED_SNAPSHOT ON", true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropIndex( - name: "IX_Users_CharacterIdentification", - table: "Users"); - - migrationBuilder.AlterColumn( - name: "CharacterIdentification", - table: "Users", - type: "nvarchar(max)", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(450)", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Hash", - table: "ForbiddenUploadEntries", - type: "nvarchar(450)", - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(40)", - oldMaxLength: 40); - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220718071653_UserLoginDateTime.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220718071653_UserLoginDateTime.cs deleted file mode 100644 index 558ee61..0000000 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220718071653_UserLoginDateTime.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MareSynchronosServer.Migrations -{ - public partial class UserLoginDateTime : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "LastLoggedIn", - table: "Users", - type: "datetime2", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "LastLoggedIn", - table: "Users"); - } - } -} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220718071653_UserLoginDateTime.Designer.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220731210149_InitialCreate.Designer.cs similarity index 52% rename from MareSynchronosServer/MareSynchronosServer/Migrations/20220718071653_UserLoginDateTime.Designer.cs rename to MareSynchronosServer/MareSynchronosServer/Migrations/20220731210149_InitialCreate.Designer.cs index d711e60..ddfded1 100644 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/20220718071653_UserLoginDateTime.Designer.cs +++ b/MareSynchronosServer/MareSynchronosServer/Migrations/20220731210149_InitialCreate.Designer.cs @@ -3,39 +3,43 @@ using System; using MareSynchronosServer.Data; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace MareSynchronosServer.Migrations { [DbContext(typeof(MareDbContext))] - [Migration("20220718071653_UserLoginDateTime")] - partial class UserLoginDateTime + [Migration("20220731210149_InitialCreate")] + partial class InitialCreate { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder .HasAnnotation("ProductVersion", "6.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 128); + .HasAnnotation("Relational:MaxIdentifierLength", 63); - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("MareSynchronosServer.Models.Auth", b => { b.Property("HashedKey") .HasMaxLength(64) - .HasColumnType("nvarchar(64)"); + .HasColumnType("character varying(64)") + .HasColumnName("hashed_key"); b.Property("UserUID") - .HasColumnType("nvarchar(10)"); + .HasColumnType("character varying(10)") + .HasColumnName("user_uid"); - b.HasKey("HashedKey"); + b.HasKey("HashedKey") + .HasName("pk_auth"); - b.HasIndex("UserUID"); + b.HasIndex("UserUID") + .HasDatabaseName("ix_auth_user_uid"); b.ToTable("Auth", (string)null); }); @@ -43,17 +47,21 @@ namespace MareSynchronosServer.Migrations modelBuilder.Entity("MareSynchronosServer.Models.Banned", b => { b.Property("CharacterIdentification") - .HasColumnType("nvarchar(450)"); + .HasColumnType("text") + .HasColumnName("character_identification"); b.Property("Reason") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text") + .HasColumnName("reason"); b.Property("Timestamp") .IsConcurrencyToken() .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); + .HasColumnType("bytea") + .HasColumnName("timestamp"); - b.HasKey("CharacterIdentification"); + b.HasKey("CharacterIdentification") + .HasName("pk_banned_users"); b.ToTable("BannedUsers", (string)null); }); @@ -62,28 +70,36 @@ namespace MareSynchronosServer.Migrations { b.Property("UserUID") .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); + .HasColumnType("character varying(10)") + .HasColumnName("user_uid"); b.Property("OtherUserUID") .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); + .HasColumnType("character varying(10)") + .HasColumnName("other_user_uid"); b.Property("AllowReceivingMessages") - .HasColumnType("bit"); + .HasColumnType("boolean") + .HasColumnName("allow_receiving_messages"); b.Property("IsPaused") - .HasColumnType("bit"); + .HasColumnType("boolean") + .HasColumnName("is_paused"); b.Property("Timestamp") .IsConcurrencyToken() .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); + .HasColumnType("bytea") + .HasColumnName("timestamp"); - b.HasKey("UserUID", "OtherUserUID"); + b.HasKey("UserUID", "OtherUserUID") + .HasName("pk_client_pairs"); - b.HasIndex("OtherUserUID"); + b.HasIndex("OtherUserUID") + .HasDatabaseName("ix_client_pairs_other_user_uid"); - b.HasIndex("UserUID"); + b.HasIndex("UserUID") + .HasDatabaseName("ix_client_pairs_user_uid"); b.ToTable("ClientPairs", (string)null); }); @@ -92,22 +108,28 @@ namespace MareSynchronosServer.Migrations { b.Property("Hash") .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); + .HasColumnType("character varying(40)") + .HasColumnName("hash"); b.Property("Timestamp") .IsConcurrencyToken() .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); + .HasColumnType("bytea") + .HasColumnName("timestamp"); b.Property("Uploaded") - .HasColumnType("bit"); + .HasColumnType("boolean") + .HasColumnName("uploaded"); b.Property("UploaderUID") - .HasColumnType("nvarchar(10)"); + .HasColumnType("character varying(10)") + .HasColumnName("uploader_uid"); - b.HasKey("Hash"); + b.HasKey("Hash") + .HasName("pk_file_caches"); - b.HasIndex("UploaderUID"); + b.HasIndex("UploaderUID") + .HasDatabaseName("ix_file_caches_uploader_uid"); b.ToTable("FileCaches", (string)null); }); @@ -116,17 +138,21 @@ namespace MareSynchronosServer.Migrations { b.Property("Hash") .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); + .HasColumnType("character varying(40)") + .HasColumnName("hash"); b.Property("ForbiddenBy") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text") + .HasColumnName("forbidden_by"); b.Property("Timestamp") .IsConcurrencyToken() .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); + .HasColumnType("bytea") + .HasColumnName("timestamp"); - b.HasKey("Hash"); + b.HasKey("Hash") + .HasName("pk_forbidden_upload_entries"); b.ToTable("ForbiddenUploadEntries", (string)null); }); @@ -135,28 +161,36 @@ namespace MareSynchronosServer.Migrations { b.Property("UID") .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); + .HasColumnType("character varying(10)") + .HasColumnName("uid"); b.Property("CharacterIdentification") - .HasColumnType("nvarchar(450)"); + .HasColumnType("text") + .HasColumnName("character_identification"); b.Property("IsAdmin") - .HasColumnType("bit"); + .HasColumnType("boolean") + .HasColumnName("is_admin"); b.Property("IsModerator") - .HasColumnType("bit"); + .HasColumnType("boolean") + .HasColumnName("is_moderator"); b.Property("LastLoggedIn") - .HasColumnType("datetime2"); + .HasColumnType("timestamp with time zone") + .HasColumnName("last_logged_in"); b.Property("Timestamp") .IsConcurrencyToken() .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); + .HasColumnType("bytea") + .HasColumnName("timestamp"); - b.HasKey("UID"); + b.HasKey("UID") + .HasName("pk_users"); - b.HasIndex("CharacterIdentification"); + b.HasIndex("CharacterIdentification") + .HasDatabaseName("ix_users_character_identification"); b.ToTable("Users", (string)null); }); @@ -165,7 +199,8 @@ namespace MareSynchronosServer.Migrations { b.HasOne("MareSynchronosServer.Models.User", "User") .WithMany() - .HasForeignKey("UserUID"); + .HasForeignKey("UserUID") + .HasConstraintName("fk_auth_users_user_uid"); b.Navigation("User"); }); @@ -176,13 +211,15 @@ namespace MareSynchronosServer.Migrations .WithMany() .HasForeignKey("OtherUserUID") .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .IsRequired() + .HasConstraintName("fk_client_pairs_users_other_user_uid"); b.HasOne("MareSynchronosServer.Models.User", "User") .WithMany() .HasForeignKey("UserUID") .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .IsRequired() + .HasConstraintName("fk_client_pairs_users_user_uid"); b.Navigation("OtherUser"); @@ -193,7 +230,8 @@ namespace MareSynchronosServer.Migrations { b.HasOne("MareSynchronosServer.Models.User", "Uploader") .WithMany() - .HasForeignKey("UploaderUID"); + .HasForeignKey("UploaderUID") + .HasConstraintName("fk_file_caches_users_uploader_uid"); b.Navigation("Uploader"); }); diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220731210149_InitialCreate.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220731210149_InitialCreate.cs new file mode 100644 index 0000000..132a6b6 --- /dev/null +++ b/MareSynchronosServer/MareSynchronosServer/Migrations/20220731210149_InitialCreate.cs @@ -0,0 +1,164 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MareSynchronosServer.Migrations +{ + public partial class InitialCreate : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "BannedUsers", + columns: table => new + { + character_identification = table.Column(type: "text", nullable: false), + reason = table.Column(type: "text", nullable: true), + timestamp = table.Column(type: "bytea", rowVersion: true, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_banned_users", x => x.character_identification); + }); + + migrationBuilder.CreateTable( + name: "ForbiddenUploadEntries", + columns: table => new + { + hash = table.Column(type: "character varying(40)", maxLength: 40, nullable: false), + forbidden_by = table.Column(type: "text", nullable: true), + timestamp = table.Column(type: "bytea", rowVersion: true, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_forbidden_upload_entries", x => x.hash); + }); + + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + uid = table.Column(type: "character varying(10)", maxLength: 10, nullable: false), + character_identification = table.Column(type: "text", nullable: true), + timestamp = table.Column(type: "bytea", rowVersion: true, nullable: true), + is_moderator = table.Column(type: "boolean", nullable: false), + is_admin = table.Column(type: "boolean", nullable: false), + last_logged_in = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_users", x => x.uid); + }); + + migrationBuilder.CreateTable( + name: "Auth", + columns: table => new + { + hashed_key = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + user_uid = table.Column(type: "character varying(10)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_auth", x => x.hashed_key); + table.ForeignKey( + name: "fk_auth_users_user_uid", + column: x => x.user_uid, + principalTable: "Users", + principalColumn: "uid"); + }); + + migrationBuilder.CreateTable( + name: "ClientPairs", + columns: table => new + { + user_uid = table.Column(type: "character varying(10)", maxLength: 10, nullable: false), + other_user_uid = table.Column(type: "character varying(10)", maxLength: 10, nullable: false), + is_paused = table.Column(type: "boolean", nullable: false), + allow_receiving_messages = table.Column(type: "boolean", nullable: false), + timestamp = table.Column(type: "bytea", rowVersion: true, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_client_pairs", x => new { x.user_uid, x.other_user_uid }); + table.ForeignKey( + name: "fk_client_pairs_users_other_user_uid", + column: x => x.other_user_uid, + principalTable: "Users", + principalColumn: "uid", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "fk_client_pairs_users_user_uid", + column: x => x.user_uid, + principalTable: "Users", + principalColumn: "uid", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "FileCaches", + columns: table => new + { + hash = table.Column(type: "character varying(40)", maxLength: 40, nullable: false), + uploader_uid = table.Column(type: "character varying(10)", nullable: true), + uploaded = table.Column(type: "boolean", nullable: false), + timestamp = table.Column(type: "bytea", rowVersion: true, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_file_caches", x => x.hash); + table.ForeignKey( + name: "fk_file_caches_users_uploader_uid", + column: x => x.uploader_uid, + principalTable: "Users", + principalColumn: "uid"); + }); + + migrationBuilder.CreateIndex( + name: "ix_auth_user_uid", + table: "Auth", + column: "user_uid"); + + migrationBuilder.CreateIndex( + name: "ix_client_pairs_other_user_uid", + table: "ClientPairs", + column: "other_user_uid"); + + migrationBuilder.CreateIndex( + name: "ix_client_pairs_user_uid", + table: "ClientPairs", + column: "user_uid"); + + migrationBuilder.CreateIndex( + name: "ix_file_caches_uploader_uid", + table: "FileCaches", + column: "uploader_uid"); + + migrationBuilder.CreateIndex( + name: "ix_users_character_identification", + table: "Users", + column: "character_identification"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Auth"); + + migrationBuilder.DropTable( + name: "BannedUsers"); + + migrationBuilder.DropTable( + name: "ClientPairs"); + + migrationBuilder.DropTable( + name: "FileCaches"); + + migrationBuilder.DropTable( + name: "ForbiddenUploadEntries"); + + migrationBuilder.DropTable( + name: "Users"); + } + } +} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220731211419_RenameLowerSnakeCase.Designer.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220731211419_RenameLowerSnakeCase.Designer.cs new file mode 100644 index 0000000..9c8495c --- /dev/null +++ b/MareSynchronosServer/MareSynchronosServer/Migrations/20220731211419_RenameLowerSnakeCase.Designer.cs @@ -0,0 +1,241 @@ +// +using System; +using MareSynchronosServer.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MareSynchronosServer.Migrations +{ + [DbContext(typeof(MareDbContext))] + [Migration("20220731211419_RenameLowerSnakeCase")] + partial class RenameLowerSnakeCase + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.6") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("MareSynchronosServer.Models.Auth", b => + { + b.Property("HashedKey") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasColumnName("hashed_key"); + + b.Property("UserUID") + .HasColumnType("character varying(10)") + .HasColumnName("user_uid"); + + b.HasKey("HashedKey") + .HasName("pk_auth"); + + b.HasIndex("UserUID") + .HasDatabaseName("ix_auth_user_uid"); + + b.ToTable("auth", (string)null); + }); + + modelBuilder.Entity("MareSynchronosServer.Models.Banned", b => + { + b.Property("CharacterIdentification") + .HasColumnType("text") + .HasColumnName("character_identification"); + + b.Property("Reason") + .HasColumnType("text") + .HasColumnName("reason"); + + b.Property("Timestamp") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("bytea") + .HasColumnName("timestamp"); + + b.HasKey("CharacterIdentification") + .HasName("pk_banned_users"); + + b.ToTable("banned_users", (string)null); + }); + + modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => + { + b.Property("UserUID") + .HasMaxLength(10) + .HasColumnType("character varying(10)") + .HasColumnName("user_uid"); + + b.Property("OtherUserUID") + .HasMaxLength(10) + .HasColumnType("character varying(10)") + .HasColumnName("other_user_uid"); + + b.Property("AllowReceivingMessages") + .HasColumnType("boolean") + .HasColumnName("allow_receiving_messages"); + + b.Property("IsPaused") + .HasColumnType("boolean") + .HasColumnName("is_paused"); + + b.Property("Timestamp") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("bytea") + .HasColumnName("timestamp"); + + b.HasKey("UserUID", "OtherUserUID") + .HasName("pk_client_pairs"); + + b.HasIndex("OtherUserUID") + .HasDatabaseName("ix_client_pairs_other_user_uid"); + + b.HasIndex("UserUID") + .HasDatabaseName("ix_client_pairs_user_uid"); + + b.ToTable("client_pairs", (string)null); + }); + + modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => + { + b.Property("Hash") + .HasMaxLength(40) + .HasColumnType("character varying(40)") + .HasColumnName("hash"); + + b.Property("Timestamp") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("bytea") + .HasColumnName("timestamp"); + + b.Property("Uploaded") + .HasColumnType("boolean") + .HasColumnName("uploaded"); + + b.Property("UploaderUID") + .HasColumnType("character varying(10)") + .HasColumnName("uploader_uid"); + + b.HasKey("Hash") + .HasName("pk_file_caches"); + + b.HasIndex("UploaderUID") + .HasDatabaseName("ix_file_caches_uploader_uid"); + + b.ToTable("file_caches", (string)null); + }); + + modelBuilder.Entity("MareSynchronosServer.Models.ForbiddenUploadEntry", b => + { + b.Property("Hash") + .HasMaxLength(40) + .HasColumnType("character varying(40)") + .HasColumnName("hash"); + + b.Property("ForbiddenBy") + .HasColumnType("text") + .HasColumnName("forbidden_by"); + + b.Property("Timestamp") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("bytea") + .HasColumnName("timestamp"); + + b.HasKey("Hash") + .HasName("pk_forbidden_upload_entries"); + + b.ToTable("forbidden_upload_entries", (string)null); + }); + + modelBuilder.Entity("MareSynchronosServer.Models.User", b => + { + b.Property("UID") + .HasMaxLength(10) + .HasColumnType("character varying(10)") + .HasColumnName("uid"); + + b.Property("CharacterIdentification") + .HasColumnType("text") + .HasColumnName("character_identification"); + + b.Property("IsAdmin") + .HasColumnType("boolean") + .HasColumnName("is_admin"); + + b.Property("IsModerator") + .HasColumnType("boolean") + .HasColumnName("is_moderator"); + + b.Property("LastLoggedIn") + .HasColumnType("timestamp with time zone") + .HasColumnName("last_logged_in"); + + b.Property("Timestamp") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("bytea") + .HasColumnName("timestamp"); + + b.HasKey("UID") + .HasName("pk_users"); + + b.HasIndex("CharacterIdentification") + .HasDatabaseName("ix_users_character_identification"); + + b.ToTable("users", (string)null); + }); + + modelBuilder.Entity("MareSynchronosServer.Models.Auth", b => + { + b.HasOne("MareSynchronosServer.Models.User", "User") + .WithMany() + .HasForeignKey("UserUID") + .HasConstraintName("fk_auth_users_user_temp_id"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => + { + b.HasOne("MareSynchronosServer.Models.User", "OtherUser") + .WithMany() + .HasForeignKey("OtherUserUID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_client_pairs_users_other_user_temp_id1"); + + b.HasOne("MareSynchronosServer.Models.User", "User") + .WithMany() + .HasForeignKey("UserUID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_client_pairs_users_user_temp_id2"); + + b.Navigation("OtherUser"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => + { + b.HasOne("MareSynchronosServer.Models.User", "Uploader") + .WithMany() + .HasForeignKey("UploaderUID") + .HasConstraintName("fk_file_caches_users_uploader_uid"); + + b.Navigation("Uploader"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/20220731211419_RenameLowerSnakeCase.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/20220731211419_RenameLowerSnakeCase.cs new file mode 100644 index 0000000..aaaf083 --- /dev/null +++ b/MareSynchronosServer/MareSynchronosServer/Migrations/20220731211419_RenameLowerSnakeCase.cs @@ -0,0 +1,133 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MareSynchronosServer.Migrations +{ + public partial class RenameLowerSnakeCase : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "fk_auth_users_user_uid", + table: "Auth"); + + migrationBuilder.DropForeignKey( + name: "fk_client_pairs_users_other_user_uid", + table: "ClientPairs"); + + migrationBuilder.DropForeignKey( + name: "fk_client_pairs_users_user_uid", + table: "ClientPairs"); + + migrationBuilder.RenameTable( + name: "Users", + newName: "users"); + + migrationBuilder.RenameTable( + name: "Auth", + newName: "auth"); + + migrationBuilder.RenameTable( + name: "ForbiddenUploadEntries", + newName: "forbidden_upload_entries"); + + migrationBuilder.RenameTable( + name: "FileCaches", + newName: "file_caches"); + + migrationBuilder.RenameTable( + name: "ClientPairs", + newName: "client_pairs"); + + migrationBuilder.RenameTable( + name: "BannedUsers", + newName: "banned_users"); + + migrationBuilder.AddForeignKey( + name: "fk_auth_users_user_temp_id", + table: "auth", + column: "user_uid", + principalTable: "users", + principalColumn: "uid"); + + migrationBuilder.AddForeignKey( + name: "fk_client_pairs_users_other_user_temp_id1", + table: "client_pairs", + column: "other_user_uid", + principalTable: "users", + principalColumn: "uid", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "fk_client_pairs_users_user_temp_id2", + table: "client_pairs", + column: "user_uid", + principalTable: "users", + principalColumn: "uid", + onDelete: ReferentialAction.Cascade); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "fk_auth_users_user_temp_id", + table: "auth"); + + migrationBuilder.DropForeignKey( + name: "fk_client_pairs_users_other_user_temp_id1", + table: "client_pairs"); + + migrationBuilder.DropForeignKey( + name: "fk_client_pairs_users_user_temp_id2", + table: "client_pairs"); + + migrationBuilder.RenameTable( + name: "users", + newName: "Users"); + + migrationBuilder.RenameTable( + name: "auth", + newName: "Auth"); + + migrationBuilder.RenameTable( + name: "forbidden_upload_entries", + newName: "ForbiddenUploadEntries"); + + migrationBuilder.RenameTable( + name: "file_caches", + newName: "FileCaches"); + + migrationBuilder.RenameTable( + name: "client_pairs", + newName: "ClientPairs"); + + migrationBuilder.RenameTable( + name: "banned_users", + newName: "BannedUsers"); + + migrationBuilder.AddForeignKey( + name: "fk_auth_users_user_uid", + table: "Auth", + column: "user_uid", + principalTable: "Users", + principalColumn: "uid"); + + migrationBuilder.AddForeignKey( + name: "fk_client_pairs_users_other_user_uid", + table: "ClientPairs", + column: "other_user_uid", + principalTable: "Users", + principalColumn: "uid", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "fk_client_pairs_users_user_uid", + table: "ClientPairs", + column: "user_uid", + principalTable: "Users", + principalColumn: "uid", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/MareSynchronosServer/MareSynchronosServer/Migrations/MareDbContextModelSnapshot.cs b/MareSynchronosServer/MareSynchronosServer/Migrations/MareDbContextModelSnapshot.cs index 2a56c4c..a9c98bc 100644 --- a/MareSynchronosServer/MareSynchronosServer/Migrations/MareDbContextModelSnapshot.cs +++ b/MareSynchronosServer/MareSynchronosServer/Migrations/MareDbContextModelSnapshot.cs @@ -3,8 +3,8 @@ using System; using MareSynchronosServer.Data; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable @@ -18,152 +18,187 @@ namespace MareSynchronosServer.Migrations #pragma warning disable 612, 618 modelBuilder .HasAnnotation("ProductVersion", "6.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 128); + .HasAnnotation("Relational:MaxIdentifierLength", 63); - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("MareSynchronosServer.Models.Auth", b => { b.Property("HashedKey") .HasMaxLength(64) - .HasColumnType("nvarchar(64)"); + .HasColumnType("character varying(64)") + .HasColumnName("hashed_key"); b.Property("UserUID") - .HasColumnType("nvarchar(10)"); + .HasColumnType("character varying(10)") + .HasColumnName("user_uid"); - b.HasKey("HashedKey"); + b.HasKey("HashedKey") + .HasName("pk_auth"); - b.HasIndex("UserUID"); + b.HasIndex("UserUID") + .HasDatabaseName("ix_auth_user_uid"); - b.ToTable("Auth", (string)null); + b.ToTable("auth", (string)null); }); modelBuilder.Entity("MareSynchronosServer.Models.Banned", b => { b.Property("CharacterIdentification") - .HasColumnType("nvarchar(450)"); + .HasColumnType("text") + .HasColumnName("character_identification"); b.Property("Reason") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text") + .HasColumnName("reason"); b.Property("Timestamp") .IsConcurrencyToken() .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); + .HasColumnType("bytea") + .HasColumnName("timestamp"); - b.HasKey("CharacterIdentification"); + b.HasKey("CharacterIdentification") + .HasName("pk_banned_users"); - b.ToTable("BannedUsers", (string)null); + b.ToTable("banned_users", (string)null); }); modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b => { b.Property("UserUID") .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); + .HasColumnType("character varying(10)") + .HasColumnName("user_uid"); b.Property("OtherUserUID") .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); + .HasColumnType("character varying(10)") + .HasColumnName("other_user_uid"); b.Property("AllowReceivingMessages") - .HasColumnType("bit"); + .HasColumnType("boolean") + .HasColumnName("allow_receiving_messages"); b.Property("IsPaused") - .HasColumnType("bit"); + .HasColumnType("boolean") + .HasColumnName("is_paused"); b.Property("Timestamp") .IsConcurrencyToken() .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); + .HasColumnType("bytea") + .HasColumnName("timestamp"); - b.HasKey("UserUID", "OtherUserUID"); + b.HasKey("UserUID", "OtherUserUID") + .HasName("pk_client_pairs"); - b.HasIndex("OtherUserUID"); + b.HasIndex("OtherUserUID") + .HasDatabaseName("ix_client_pairs_other_user_uid"); - b.HasIndex("UserUID"); + b.HasIndex("UserUID") + .HasDatabaseName("ix_client_pairs_user_uid"); - b.ToTable("ClientPairs", (string)null); + b.ToTable("client_pairs", (string)null); }); modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b => { b.Property("Hash") .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); + .HasColumnType("character varying(40)") + .HasColumnName("hash"); b.Property("Timestamp") .IsConcurrencyToken() .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); + .HasColumnType("bytea") + .HasColumnName("timestamp"); b.Property("Uploaded") - .HasColumnType("bit"); + .HasColumnType("boolean") + .HasColumnName("uploaded"); b.Property("UploaderUID") - .HasColumnType("nvarchar(10)"); + .HasColumnType("character varying(10)") + .HasColumnName("uploader_uid"); - b.HasKey("Hash"); + b.HasKey("Hash") + .HasName("pk_file_caches"); - b.HasIndex("UploaderUID"); + b.HasIndex("UploaderUID") + .HasDatabaseName("ix_file_caches_uploader_uid"); - b.ToTable("FileCaches", (string)null); + b.ToTable("file_caches", (string)null); }); modelBuilder.Entity("MareSynchronosServer.Models.ForbiddenUploadEntry", b => { b.Property("Hash") .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); + .HasColumnType("character varying(40)") + .HasColumnName("hash"); b.Property("ForbiddenBy") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text") + .HasColumnName("forbidden_by"); b.Property("Timestamp") .IsConcurrencyToken() .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); + .HasColumnType("bytea") + .HasColumnName("timestamp"); - b.HasKey("Hash"); + b.HasKey("Hash") + .HasName("pk_forbidden_upload_entries"); - b.ToTable("ForbiddenUploadEntries", (string)null); + b.ToTable("forbidden_upload_entries", (string)null); }); modelBuilder.Entity("MareSynchronosServer.Models.User", b => { b.Property("UID") .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); + .HasColumnType("character varying(10)") + .HasColumnName("uid"); b.Property("CharacterIdentification") - .HasColumnType("nvarchar(450)"); + .HasColumnType("text") + .HasColumnName("character_identification"); b.Property("IsAdmin") - .HasColumnType("bit"); + .HasColumnType("boolean") + .HasColumnName("is_admin"); b.Property("IsModerator") - .HasColumnType("bit"); + .HasColumnType("boolean") + .HasColumnName("is_moderator"); b.Property("LastLoggedIn") - .HasColumnType("datetime2"); + .HasColumnType("timestamp with time zone") + .HasColumnName("last_logged_in"); b.Property("Timestamp") .IsConcurrencyToken() .ValueGeneratedOnAddOrUpdate() - .HasColumnType("rowversion"); + .HasColumnType("bytea") + .HasColumnName("timestamp"); - b.HasKey("UID"); + b.HasKey("UID") + .HasName("pk_users"); - b.HasIndex("CharacterIdentification"); + b.HasIndex("CharacterIdentification") + .HasDatabaseName("ix_users_character_identification"); - b.ToTable("Users", (string)null); + b.ToTable("users", (string)null); }); modelBuilder.Entity("MareSynchronosServer.Models.Auth", b => { b.HasOne("MareSynchronosServer.Models.User", "User") .WithMany() - .HasForeignKey("UserUID"); + .HasForeignKey("UserUID") + .HasConstraintName("fk_auth_users_user_temp_id"); b.Navigation("User"); }); @@ -174,13 +209,15 @@ namespace MareSynchronosServer.Migrations .WithMany() .HasForeignKey("OtherUserUID") .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .IsRequired() + .HasConstraintName("fk_client_pairs_users_other_user_temp_id1"); b.HasOne("MareSynchronosServer.Models.User", "User") .WithMany() .HasForeignKey("UserUID") .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .IsRequired() + .HasConstraintName("fk_client_pairs_users_user_temp_id2"); b.Navigation("OtherUser"); @@ -191,7 +228,8 @@ namespace MareSynchronosServer.Migrations { b.HasOne("MareSynchronosServer.Models.User", "Uploader") .WithMany() - .HasForeignKey("UploaderUID"); + .HasForeignKey("UploaderUID") + .HasConstraintName("fk_file_caches_users_uploader_uid"); b.Navigation("Uploader"); }); diff --git a/MareSynchronosServer/MareSynchronosServer/Program.cs b/MareSynchronosServer/MareSynchronosServer/Program.cs index c97897c..dae9fb5 100644 --- a/MareSynchronosServer/MareSynchronosServer/Program.cs +++ b/MareSynchronosServer/MareSynchronosServer/Program.cs @@ -47,7 +47,10 @@ namespace MareSynchronosServer MareMetrics.InitializeMetrics(context, services.GetRequiredService()); } - host.Run(); + if (args.Length == 0 || args[0] != "dry") + { + host.Run(); + } } public static IHostBuilder CreateHostBuilder(string[] args) => diff --git a/MareSynchronosServer/MareSynchronosServer/Startup.cs b/MareSynchronosServer/MareSynchronosServer/Startup.cs index 3838d91..c22c3bb 100644 --- a/MareSynchronosServer/MareSynchronosServer/Startup.cs +++ b/MareSynchronosServer/MareSynchronosServer/Startup.cs @@ -16,6 +16,7 @@ using Prometheus; using WebSocketOptions = Microsoft.AspNetCore.Builder.WebSocketOptions; using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Logging; +using Microsoft.EntityFrameworkCore.Migrations; namespace MareSynchronosServer { @@ -47,10 +48,11 @@ namespace MareSynchronosServer services.AddDbContextPool(options => { - options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"), builder => + options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection"), builder => { - }); - }, 32000); + builder.MigrationsHistoryTable("_efmigrationshistory", "public"); + }).UseSnakeCaseNamingConvention(); + }); services.AddHostedService(); services.AddHostedService(provider => provider.GetService()); diff --git a/MareSynchronosServer/MareSynchronosServer/appsettings.json b/MareSynchronosServer/MareSynchronosServer/appsettings.json index 28987c3..2015dd1 100644 --- a/MareSynchronosServer/MareSynchronosServer/appsettings.json +++ b/MareSynchronosServer/MareSynchronosServer/appsettings.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "DefaultConnection": "Server=(localdb)\\SQLEXPRESS;Database=mare;Trusted_Connection=True;MultipleActiveResultSets=true" + "DefaultConnection": "Host=localhost;Port=5432;Database=mare;Username=postgres" }, "Logging": { "LogLevel": {