diff --git a/code/server/DataBase/Context/PongDbContext.cs b/code/server/DataBase/Context/PongDbContext.cs index 5829fd8..7bc4621 100644 --- a/code/server/DataBase/Context/PongDbContext.cs +++ b/code/server/DataBase/Context/PongDbContext.cs @@ -19,7 +19,7 @@ namespace DataBase.Context if (!optionsBuilder.IsConfigured) { - optionsBuilder.UseSqlite($"Data Source=C:\\Users\\noanr\\source\\repos\\leap-hit-server\\code\\server\\DataBase\\PongDB.db"); + optionsBuilder.UseSqlite("Data Source=../DataBase/PongDB.db"); } } } diff --git a/code/server/DataBase/Migrations/20230228121953_Migrations.Designer.cs b/code/server/DataBase/Migrations/20230316092529_mymigrations.Designer.cs similarity index 84% rename from code/server/DataBase/Migrations/20230228121953_Migrations.Designer.cs rename to code/server/DataBase/Migrations/20230316092529_mymigrations.Designer.cs index a256488..081b26f 100644 --- a/code/server/DataBase/Migrations/20230228121953_Migrations.Designer.cs +++ b/code/server/DataBase/Migrations/20230316092529_mymigrations.Designer.cs @@ -11,8 +11,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace DataBase.Migrations { [DbContext(typeof(PongDbContextWithStub))] - [Migration("20230228121953_Migrations")] - partial class Migrations + [Migration("20230316092529_mymigrations")] + partial class mymigrations { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -26,11 +26,13 @@ namespace DataBase.Migrations .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); - b.Property("player1") - .HasColumnType("INTEGER"); + b.Property("player1") + .IsRequired() + .HasColumnType("TEXT"); - b.Property("player2") - .HasColumnType("INTEGER"); + b.Property("player2") + .IsRequired() + .HasColumnType("TEXT"); b.HasKey("chatId"); @@ -44,8 +46,8 @@ namespace DataBase.Migrations new { chatId = 1, - player1 = 1, - player2 = 2 + player1 = "test", + player2 = "test2" }); }); @@ -58,8 +60,9 @@ namespace DataBase.Migrations b.Property("durationGame") .HasColumnType("INTEGER"); - b.Property("loser") - .HasColumnType("INTEGER"); + b.Property("loser") + .IsRequired() + .HasColumnType("TEXT"); b.Property("nbMaxEchanges") .HasColumnType("INTEGER"); @@ -70,8 +73,9 @@ namespace DataBase.Migrations b.Property("scoreWinner") .HasColumnType("INTEGER"); - b.Property("winner") - .HasColumnType("INTEGER"); + b.Property("winner") + .IsRequired() + .HasColumnType("TEXT"); b.HasKey("gameId"); @@ -86,11 +90,11 @@ namespace DataBase.Migrations { gameId = 1, durationGame = 65, - loser = 2, + loser = "test2", nbMaxEchanges = 5, scoreLoser = 2, scoreWinner = 6, - winner = 1 + winner = "test" }); }); @@ -107,8 +111,9 @@ namespace DataBase.Migrations .IsRequired() .HasColumnType("TEXT"); - b.Property("player") - .HasColumnType("INTEGER"); + b.Property("player") + .IsRequired() + .HasColumnType("TEXT"); b.Property("timestamp") .HasColumnType("TEXT"); @@ -127,7 +132,7 @@ namespace DataBase.Migrations messageId = 1, chat = 1, message = "Salut mon gars !", - player = 1, + player = "test", timestamp = new DateTime(2023, 2, 16, 17, 5, 12, 0, DateTimeKind.Unspecified) }, new @@ -135,16 +140,15 @@ namespace DataBase.Migrations messageId = 2, chat = 1, message = "Comment tu vas ?", - player = 2, + player = "test2", timestamp = new DateTime(2023, 2, 16, 17, 12, 35, 0, DateTimeKind.Unspecified) }); }); modelBuilder.Entity("DataBase.Entity.Player", b => { - b.Property("playerId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + b.Property("playerId") + .HasColumnType("TEXT"); b.Property("name") .IsRequired() @@ -163,14 +167,14 @@ namespace DataBase.Migrations b.HasData( new { - playerId = 1, + playerId = "test", name = "Rami", nbBallTouchTotal = 20, timePlayed = 120 }, new { - playerId = 2, + playerId = "test2", name = "Hugo", nbBallTouchTotal = 90, timePlayed = 250 diff --git a/code/server/DataBase/Migrations/20230228121953_Migrations.cs b/code/server/DataBase/Migrations/20230316092529_mymigrations.cs similarity index 87% rename from code/server/DataBase/Migrations/20230228121953_Migrations.cs rename to code/server/DataBase/Migrations/20230316092529_mymigrations.cs index cf2b11d..698e944 100644 --- a/code/server/DataBase/Migrations/20230228121953_Migrations.cs +++ b/code/server/DataBase/Migrations/20230316092529_mymigrations.cs @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace DataBase.Migrations { /// - public partial class Migrations : Migration + public partial class mymigrations : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -17,8 +17,7 @@ namespace DataBase.Migrations name: "Players", columns: table => new { - playerId = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), + playerId = table.Column(type: "TEXT", nullable: false), name = table.Column(type: "TEXT", nullable: false), nbBallTouchTotal = table.Column(type: "INTEGER", nullable: false), timePlayed = table.Column(type: "INTEGER", nullable: false) @@ -34,8 +33,8 @@ namespace DataBase.Migrations { chatId = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), - player1 = table.Column(type: "INTEGER", nullable: false), - player2 = table.Column(type: "INTEGER", nullable: false) + player1 = table.Column(type: "TEXT", nullable: false), + player2 = table.Column(type: "TEXT", nullable: false) }, constraints: table => { @@ -62,8 +61,8 @@ namespace DataBase.Migrations .Annotation("Sqlite:Autoincrement", true), durationGame = table.Column(type: "INTEGER", nullable: false), nbMaxEchanges = table.Column(type: "INTEGER", nullable: false), - winner = table.Column(type: "INTEGER", nullable: false), - loser = table.Column(type: "INTEGER", nullable: false), + winner = table.Column(type: "TEXT", nullable: false), + loser = table.Column(type: "TEXT", nullable: false), scoreWinner = table.Column(type: "INTEGER", nullable: false), scoreLoser = table.Column(type: "INTEGER", nullable: false) }, @@ -92,7 +91,7 @@ namespace DataBase.Migrations .Annotation("Sqlite:Autoincrement", true), message = table.Column(type: "TEXT", nullable: false), timestamp = table.Column(type: "TEXT", nullable: false), - player = table.Column(type: "INTEGER", nullable: false), + player = table.Column(type: "TEXT", nullable: false), chat = table.Column(type: "INTEGER", nullable: false) }, constraints: table => @@ -117,27 +116,27 @@ namespace DataBase.Migrations columns: new[] { "playerId", "name", "nbBallTouchTotal", "timePlayed" }, values: new object[,] { - { 1, "Rami", 20, 120 }, - { 2, "Hugo", 90, 250 } + { "test", "Rami", 20, 120 }, + { "test2", "Hugo", 90, 250 } }); migrationBuilder.InsertData( table: "Chats", columns: new[] { "chatId", "player1", "player2" }, - values: new object[] { 1, 1, 2 }); + values: new object[] { 1, "test", "test2" }); migrationBuilder.InsertData( table: "Games", columns: new[] { "gameId", "durationGame", "loser", "nbMaxEchanges", "scoreLoser", "scoreWinner", "winner" }, - values: new object[] { 1, 65, 2, 5, 2, 6, 1 }); + values: new object[] { 1, 65, "test2", 5, 2, 6, "test" }); migrationBuilder.InsertData( table: "Messages", columns: new[] { "messageId", "chat", "message", "player", "timestamp" }, values: new object[,] { - { 1, 1, "Salut mon gars !", 1, new DateTime(2023, 2, 16, 17, 5, 12, 0, DateTimeKind.Unspecified) }, - { 2, 1, "Comment tu vas ?", 2, new DateTime(2023, 2, 16, 17, 12, 35, 0, DateTimeKind.Unspecified) } + { 1, 1, "Salut mon gars !", "test", new DateTime(2023, 2, 16, 17, 5, 12, 0, DateTimeKind.Unspecified) }, + { 2, 1, "Comment tu vas ?", "test2", new DateTime(2023, 2, 16, 17, 12, 35, 0, DateTimeKind.Unspecified) } }); migrationBuilder.CreateIndex( diff --git a/code/server/DataBase/Migrations/PongDbContextWithStubModelSnapshot.cs b/code/server/DataBase/Migrations/PongDbContextWithStubModelSnapshot.cs index e144450..7d94251 100644 --- a/code/server/DataBase/Migrations/PongDbContextWithStubModelSnapshot.cs +++ b/code/server/DataBase/Migrations/PongDbContextWithStubModelSnapshot.cs @@ -23,11 +23,13 @@ namespace DataBase.Migrations .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); - b.Property("player1") - .HasColumnType("INTEGER"); + b.Property("player1") + .IsRequired() + .HasColumnType("TEXT"); - b.Property("player2") - .HasColumnType("INTEGER"); + b.Property("player2") + .IsRequired() + .HasColumnType("TEXT"); b.HasKey("chatId"); @@ -41,8 +43,8 @@ namespace DataBase.Migrations new { chatId = 1, - player1 = 1, - player2 = 2 + player1 = "test", + player2 = "test2" }); }); @@ -55,8 +57,9 @@ namespace DataBase.Migrations b.Property("durationGame") .HasColumnType("INTEGER"); - b.Property("loser") - .HasColumnType("INTEGER"); + b.Property("loser") + .IsRequired() + .HasColumnType("TEXT"); b.Property("nbMaxEchanges") .HasColumnType("INTEGER"); @@ -67,8 +70,9 @@ namespace DataBase.Migrations b.Property("scoreWinner") .HasColumnType("INTEGER"); - b.Property("winner") - .HasColumnType("INTEGER"); + b.Property("winner") + .IsRequired() + .HasColumnType("TEXT"); b.HasKey("gameId"); @@ -83,11 +87,11 @@ namespace DataBase.Migrations { gameId = 1, durationGame = 65, - loser = 2, + loser = "test2", nbMaxEchanges = 5, scoreLoser = 2, scoreWinner = 6, - winner = 1 + winner = "test" }); }); @@ -104,8 +108,9 @@ namespace DataBase.Migrations .IsRequired() .HasColumnType("TEXT"); - b.Property("player") - .HasColumnType("INTEGER"); + b.Property("player") + .IsRequired() + .HasColumnType("TEXT"); b.Property("timestamp") .HasColumnType("TEXT"); @@ -124,7 +129,7 @@ namespace DataBase.Migrations messageId = 1, chat = 1, message = "Salut mon gars !", - player = 1, + player = "test", timestamp = new DateTime(2023, 2, 16, 17, 5, 12, 0, DateTimeKind.Unspecified) }, new @@ -132,16 +137,15 @@ namespace DataBase.Migrations messageId = 2, chat = 1, message = "Comment tu vas ?", - player = 2, + player = "test2", timestamp = new DateTime(2023, 2, 16, 17, 12, 35, 0, DateTimeKind.Unspecified) }); }); modelBuilder.Entity("DataBase.Entity.Player", b => { - b.Property("playerId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + b.Property("playerId") + .HasColumnType("TEXT"); b.Property("name") .IsRequired() @@ -160,14 +164,14 @@ namespace DataBase.Migrations b.HasData( new { - playerId = 1, + playerId = "test", name = "Rami", nbBallTouchTotal = 20, timePlayed = 120 }, new { - playerId = 2, + playerId = "test2", name = "Hugo", nbBallTouchTotal = 90, timePlayed = 250 diff --git a/code/server/DataBase/PongDB.db b/code/server/DataBase/PongDB.db index 07e0a8c..76ba767 100644 Binary files a/code/server/DataBase/PongDB.db and b/code/server/DataBase/PongDB.db differ diff --git a/code/server/DataBase/PongDB.db-shm b/code/server/DataBase/PongDB.db-shm deleted file mode 100644 index fe9ac28..0000000 Binary files a/code/server/DataBase/PongDB.db-shm and /dev/null differ diff --git a/code/server/DataBase/PongDB.db-wal b/code/server/DataBase/PongDB.db-wal deleted file mode 100644 index e69de29..0000000