From 4f5a5fa724eb4fbcdd34bda05b0d5bf8a76bab78 Mon Sep 17 00:00:00 2001 From: CyberL1 Date: Mon, 13 May 2024 13:56:31 +0200 Subject: [PATCH] refactor: clean the code --- .../Controllers/ConfigurationController.cs | 25 -- MyMcRealms/Controllers/InvitesController.cs | 178 ---------- MyMcRealms/Controllers/McoController.cs | 12 +- MyMcRealms/Controllers/OpsController.cs | 76 ---- .../Controllers/SubscriptionsController.cs | 37 -- MyMcRealms/Controllers/TrialController.cs | 10 +- MyMcRealms/Controllers/WorldsController.cs | 38 +- MyMcRealms/Data/DataContext.cs | 16 - MyMcRealms/Entities/Backup.cs | 14 - MyMcRealms/Entities/Configuration.cs | 13 - MyMcRealms/Entities/Connection.cs | 10 - MyMcRealms/Entities/Invite.cs | 11 - MyMcRealms/Entities/Player.cs | 14 - MyMcRealms/Entities/Slot.cs | 8 - MyMcRealms/Entities/Subscription.cs | 11 - MyMcRealms/Entities/World.cs | 24 -- MyMcRealms/Helpers/Database.cs | 52 --- .../20240202175209_Initial.Designer.cs | 101 ------ .../Migrations/20240202175209_Initial.cs | 52 --- .../20240203132410_Subscriptions.Designer.cs | 130 ------- .../20240203132410_Subscriptions.cs | 56 --- .../20240211135246_Slots.Designer.cs | 131 ------- MyMcRealms/Migrations/20240211135246_Slots.cs | 23 -- .../20240213104200_Connections.Designer.cs | 159 --------- .../Migrations/20240213104200_Connections.cs | 44 --- ...20240213121346_Subscription_v2.Designer.cs | 168 --------- .../20240213121346_Subscription_v2.cs | 60 ---- .../20240214154708_Backups.Designer.cs | 211 ------------ .../Migrations/20240214154708_Backups.cs | 51 --- .../20240218160304_Connections_Id.Designer.cs | 219 ------------ .../20240218160304_Connections_Id.cs | 40 --- .../20240220092334_Invites.Designer.cs | 259 -------------- .../Migrations/20240220092334_Invites.cs | 50 --- .../20240221131108_Players.Designer.cs | 310 ----------------- .../Migrations/20240221131108_Players.cs | 63 ---- .../20240301214442_Configuration.Designer.cs | 324 ------------------ .../20240301214442_Configuration.cs | 33 -- ...tions_StartDate_Readable_Field.Designer.cs | 323 ----------------- ..._Subscriptions_StartDate_Readable_Field.cs | 22 -- ...0329_Worlds_Subscription_field.Designer.cs | 313 ----------------- ...0240317120329_Worlds_Subscription_field.cs | 81 ----- ...40414062222_Configuration_Json.Designer.cs | 313 ----------------- .../20240414062222_Configuration_Json.cs | 22 -- .../Migrations/DataContextModelSnapshot.cs | 310 ----------------- .../MyMcAPI/Responses/AllServersResponse.cs | 20 +- MyMcRealms/Program.cs | 22 -- MyMcRealms/Responses/BackupsResponse.cs | 9 - MyMcRealms/Responses/InviteList.cs | 16 - MyMcRealms/Responses/MinecraftPlayerInfo.cs | 9 - MyMcRealms/Responses/OpsResponse.cs | 7 - MyMcRealms/Responses/SubscriptionResponse.cs | 9 - MyMcRealms/Responses/WorldResponse.cs | 22 +- 52 files changed, 42 insertions(+), 4489 deletions(-) delete mode 100644 MyMcRealms/Controllers/ConfigurationController.cs delete mode 100644 MyMcRealms/Controllers/InvitesController.cs delete mode 100644 MyMcRealms/Controllers/OpsController.cs delete mode 100644 MyMcRealms/Controllers/SubscriptionsController.cs delete mode 100644 MyMcRealms/Data/DataContext.cs delete mode 100644 MyMcRealms/Entities/Backup.cs delete mode 100644 MyMcRealms/Entities/Configuration.cs delete mode 100644 MyMcRealms/Entities/Connection.cs delete mode 100644 MyMcRealms/Entities/Invite.cs delete mode 100644 MyMcRealms/Entities/Player.cs delete mode 100644 MyMcRealms/Entities/Slot.cs delete mode 100644 MyMcRealms/Entities/Subscription.cs delete mode 100644 MyMcRealms/Entities/World.cs delete mode 100644 MyMcRealms/Helpers/Database.cs delete mode 100644 MyMcRealms/Migrations/20240202175209_Initial.Designer.cs delete mode 100644 MyMcRealms/Migrations/20240202175209_Initial.cs delete mode 100644 MyMcRealms/Migrations/20240203132410_Subscriptions.Designer.cs delete mode 100644 MyMcRealms/Migrations/20240203132410_Subscriptions.cs delete mode 100644 MyMcRealms/Migrations/20240211135246_Slots.Designer.cs delete mode 100644 MyMcRealms/Migrations/20240211135246_Slots.cs delete mode 100644 MyMcRealms/Migrations/20240213104200_Connections.Designer.cs delete mode 100644 MyMcRealms/Migrations/20240213104200_Connections.cs delete mode 100644 MyMcRealms/Migrations/20240213121346_Subscription_v2.Designer.cs delete mode 100644 MyMcRealms/Migrations/20240213121346_Subscription_v2.cs delete mode 100644 MyMcRealms/Migrations/20240214154708_Backups.Designer.cs delete mode 100644 MyMcRealms/Migrations/20240214154708_Backups.cs delete mode 100644 MyMcRealms/Migrations/20240218160304_Connections_Id.Designer.cs delete mode 100644 MyMcRealms/Migrations/20240218160304_Connections_Id.cs delete mode 100644 MyMcRealms/Migrations/20240220092334_Invites.Designer.cs delete mode 100644 MyMcRealms/Migrations/20240220092334_Invites.cs delete mode 100644 MyMcRealms/Migrations/20240221131108_Players.Designer.cs delete mode 100644 MyMcRealms/Migrations/20240221131108_Players.cs delete mode 100644 MyMcRealms/Migrations/20240301214442_Configuration.Designer.cs delete mode 100644 MyMcRealms/Migrations/20240301214442_Configuration.cs delete mode 100644 MyMcRealms/Migrations/20240315231009_Subscriptions_StartDate_Readable_Field.Designer.cs delete mode 100644 MyMcRealms/Migrations/20240315231009_Subscriptions_StartDate_Readable_Field.cs delete mode 100644 MyMcRealms/Migrations/20240317120329_Worlds_Subscription_field.Designer.cs delete mode 100644 MyMcRealms/Migrations/20240317120329_Worlds_Subscription_field.cs delete mode 100644 MyMcRealms/Migrations/20240414062222_Configuration_Json.Designer.cs delete mode 100644 MyMcRealms/Migrations/20240414062222_Configuration_Json.cs delete mode 100644 MyMcRealms/Migrations/DataContextModelSnapshot.cs delete mode 100644 MyMcRealms/Responses/BackupsResponse.cs delete mode 100644 MyMcRealms/Responses/InviteList.cs delete mode 100644 MyMcRealms/Responses/MinecraftPlayerInfo.cs delete mode 100644 MyMcRealms/Responses/OpsResponse.cs delete mode 100644 MyMcRealms/Responses/SubscriptionResponse.cs diff --git a/MyMcRealms/Controllers/ConfigurationController.cs b/MyMcRealms/Controllers/ConfigurationController.cs deleted file mode 100644 index 0ac915f..0000000 --- a/MyMcRealms/Controllers/ConfigurationController.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using MyMcRealms.Data; -using MyMcRealms.Entities; - -namespace MyMcRealms.Controllers -{ - [Route("[controller]")] - [ApiController] - public class ConfigurationController : ControllerBase - { - private readonly DataContext _context; - - public ConfigurationController(DataContext context) - { - _context = context; - } - - [HttpGet] - public ActionResult GetConfigurationAsync() - { - var configuration = _context.Configuration; - return Ok(configuration); - } - } -} \ No newline at end of file diff --git a/MyMcRealms/Controllers/InvitesController.cs b/MyMcRealms/Controllers/InvitesController.cs deleted file mode 100644 index 9d45ffa..0000000 --- a/MyMcRealms/Controllers/InvitesController.cs +++ /dev/null @@ -1,178 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; -using MyMcRealms.Attributes; -using MyMcRealms.Data; -using MyMcRealms.Entities; -using MyMcRealms.Requests; -using MyMcRealms.Responses; - -namespace MyMcRealms.Controllers -{ - [Route("[controller]")] - [ApiController] - [RequireMinecraftCookie] - public class InvitesController : ControllerBase - { - private readonly DataContext _context; - - public InvitesController(DataContext context) - { - _context = context; - } - - [HttpGet("pending")] - public async Task> GetInvites() - { - string cookie = Request.Headers.Cookie; - string playerUUID = cookie.Split(";")[0].Split(":")[2]; - - var invites = await _context.Invites.Where(i => i.RecipeintUUID == playerUUID).Include(i => i.World).ToListAsync(); - - List invitesList = []; - - foreach (var invite in invites) - { - InviteResponse inv = new() - { - InvitationId = invite.InvitationId, - WorldName = invite.World.Name, - WorldOwnerName = invite.World.Owner, - WorldOwnerUuid = invite.World.OwnerUUID, - Date = ((DateTimeOffset) invite.Date).ToUnixTimeMilliseconds(), - }; - - invitesList.Add(inv); - } - - InviteList inviteListRespone = new() - { - Invites = invitesList - }; - - return Ok(inviteListRespone); - } - [HttpPut("accept/{id}")] - public ActionResult AcceptInvite(string id) - { - string cookie = Request.Headers.Cookie; - string playerUUID = cookie.Split(";")[0].Split(":")[2]; - - var invite = _context.Invites.Include(i => i.World).FirstOrDefault(i => i.InvitationId == id); - - if (invite == null) return NotFound("Invite not found"); - - var player = _context.Players.Where(p => p.World.Id == invite.World.Id).FirstOrDefault(p => p.Uuid == playerUUID); - - player.Accepted = true; - - _context.Invites.Remove(invite); - - _context.SaveChanges(); - - return Ok(true); - } - - [HttpPut("reject/{id}")] - public ActionResult RejectInvite(string id) - { - var invite = _context.Invites.Include(i => i.World).FirstOrDefault(i => i.InvitationId == id); - - if (invite == null) return NotFound("Invite not found"); - - _context.Invites.Remove(invite); - - string cookie = Request.Headers.Cookie; - string playerUUID = cookie.Split(";")[0].Split(":")[2]; - - var player = _context.Players.Where(p => p.World.Id == invite.World.Id).FirstOrDefault(p => p.Uuid == playerUUID); - - _context.Players.Remove(player); - - _context.SaveChanges(); - - return Ok(true); - } - - [HttpPost("{wId}")] - public async Task> InvitePlayer(int wId, PlayerRequest body) - { - string cookie = Request.Headers.Cookie; - string playerName = cookie.Split(";")[1].Split("=")[1]; - - if (body.Name == playerName) return Forbid("You cannot invite yourself"); - - var world = await _context.Worlds.Include(w => w.Players).FirstOrDefaultAsync(w => w.Id == wId); - - if (world == null) return NotFound("World not found"); - - // Get player UUID - var playerInfo = await new HttpClient().GetFromJsonAsync($"https://api.mojang.com/users/profiles/minecraft/{body.Name}"); - - var playerInDB = await _context.Players.Where(p => p.World.Id == wId).FirstOrDefaultAsync(p => p.Uuid == playerInfo.Id); - - if (playerInDB?.Uuid == playerInfo.Id) return BadRequest("Player already invited"); - - Player player = new() - { - Name = body.Name, - Uuid = playerInfo.Id, - World = world - }; - - _context.Players.Add(player); - - Invite invite = new() - { - InvitationId = Guid.NewGuid().ToString(), - World = world, - RecipeintUUID = playerInfo.Id, - Date = DateTime.UtcNow, - }; - - _context.Invites.Add(invite); - - _context.SaveChanges(); - - return Ok(world); - } - - [HttpDelete("{wId}/invite/{uuid}")] - public async Task> DeleteInvite(int wId, string uuid) - { - var world = await _context.Worlds.FirstOrDefaultAsync(w => w.Id == wId); - - if (world == null) return NotFound("World not found"); - - var player = _context.Players.Where(p => p.World.Id == wId).FirstOrDefault(p => p.Uuid == uuid); - - _context.Players.Remove(player); - - var invite = await _context.Invites.FirstOrDefaultAsync(i => i.RecipeintUUID == uuid); - - if (invite != null) _context.Invites.Remove(invite); - - _context.SaveChanges(); - - return Ok(true); - } - - [HttpDelete("{wId}")] - public async Task> LeaveWorld(int wId) - { - string cookie = Request.Headers.Cookie; - string playerUUID = cookie.Split(";")[0].Split(":")[2]; - - var world = await _context.Worlds.FirstOrDefaultAsync(w => w.Id == wId); - - if (world == null) return NotFound("World not found"); - - var player = _context.Players.Where(p => p.World.Id == wId).FirstOrDefault(p => p.Uuid == playerUUID); - - _context.Players.Remove(player); - - _context.SaveChanges(); - - return Ok(true); - } - } -} diff --git a/MyMcRealms/Controllers/McoController.cs b/MyMcRealms/Controllers/McoController.cs index f70226f..541961e 100644 --- a/MyMcRealms/Controllers/McoController.cs +++ b/MyMcRealms/Controllers/McoController.cs @@ -1,6 +1,5 @@ using Microsoft.AspNetCore.Mvc; using MyMcRealms.Attributes; -using MyMcRealms.Data; using MyMcRealms.Responses; using Newtonsoft.Json; @@ -11,13 +10,6 @@ namespace MyMcRealms.Controllers [RequireMinecraftCookie] public class McoController : ControllerBase { - private readonly DataContext _context; - - public McoController(DataContext context) - { - _context = context; - } - [HttpGet("available")] public bool GetAvailable() { @@ -33,11 +25,9 @@ namespace MyMcRealms.Controllers [HttpGet("v1/news")] public NewsResponse GetNews() { - var newsLink = _context.Configuration.FirstOrDefault(s => s.Key == "newsLink"); - var news = new NewsResponse { - NewsLink = JsonConvert.DeserializeObject(newsLink.Value), + NewsLink = "https://github.com/CyberL1/Minecraft-Realms-Emulator", }; return news; diff --git a/MyMcRealms/Controllers/OpsController.cs b/MyMcRealms/Controllers/OpsController.cs deleted file mode 100644 index 99037f5..0000000 --- a/MyMcRealms/Controllers/OpsController.cs +++ /dev/null @@ -1,76 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using MyMcRealms.Attributes; -using MyMcRealms.Data; -using MyMcRealms.Responses; - -namespace MyMcRealms.Controllers -{ - [Route("[controller]")] - [ApiController] - [RequireMinecraftCookie] - public class OpsController : ControllerBase - { - private readonly DataContext _context; - - public OpsController(DataContext context) - { - _context = context; - } - - [HttpPost("{wId}/{uuid}")] - public ActionResult OpPlayer(int wId, string uuid) - { - var ops = _context.Players.Where(p => p.World.Id == wId && p.Operator == true).ToList(); - var player = _context.Players.Where(p => p.World.Id == wId).FirstOrDefault(p => p.Uuid == uuid); - - List opNames = []; - - foreach (var op in ops) - { - opNames.Add(op.Name); - } - - player.Permission = "OPERATOR"; - player.Operator = true; - - _context.SaveChanges(); - - opNames.Add(player.Name); - - var opsResponse = new OpsResponse - { - Ops = opNames - }; - - return Ok(opsResponse); - } - - [HttpDelete("{wId}/{uuid}")] - public ActionResult DeopPlayer(int wId, string uuid) - { - var ops = _context.Players.Where(p => p.World.Id == wId && p.Operator == true).ToList(); - var player = _context.Players.Where(p => p.World.Id == wId).FirstOrDefault(p => p.Uuid == uuid); - - List opNames = []; - - foreach (var op in ops) - { - opNames.Add(op.Name); - } - - player.Permission = "MEMBER"; - player.Operator = false; - - _context.SaveChanges(); - - opNames.Remove(player.Name); - - var opsResponse = new OpsResponse - { - Ops = opNames - }; - - return Ok(opsResponse); - } - } -} diff --git a/MyMcRealms/Controllers/SubscriptionsController.cs b/MyMcRealms/Controllers/SubscriptionsController.cs deleted file mode 100644 index 1598b0f..0000000 --- a/MyMcRealms/Controllers/SubscriptionsController.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; -using MyMcRealms.Attributes; -using MyMcRealms.Data; -using MyMcRealms.Responses; - -namespace MyMcRealms.Controllers -{ - [Route("[controller]")] - [ApiController] - [RequireMinecraftCookie] - public class SubscriptionsController : ControllerBase - { - private readonly DataContext _context; - - public SubscriptionsController(DataContext context) - { - _context = context; - } - [HttpGet("{id}")] - public async Task> Get(int id) - { - var world = await _context.Worlds.Include(w => w.Subscription).FirstOrDefaultAsync(w => w.Id == id); - - if (world?.Subscription == null) return NotFound("Subscription not found"); - - var sub = new SubscriptionResponse - { - StartDate = ((DateTimeOffset)world.Subscription.StartDate).ToUnixTimeMilliseconds(), - DaysLeft = ((DateTimeOffset)world.Subscription.StartDate.AddDays(30) - DateTime.Today).Days, - SubscriptionType = world.Subscription.SubscriptionType - }; - - return Ok(sub); - } - } -} diff --git a/MyMcRealms/Controllers/TrialController.cs b/MyMcRealms/Controllers/TrialController.cs index 0d36a9b..972f4f9 100644 --- a/MyMcRealms/Controllers/TrialController.cs +++ b/MyMcRealms/Controllers/TrialController.cs @@ -1,6 +1,5 @@ using Microsoft.AspNetCore.Mvc; using MyMcRealms.Attributes; -using MyMcRealms.Data; namespace MyMcRealms.Controllers { @@ -9,16 +8,9 @@ namespace MyMcRealms.Controllers [RequireMinecraftCookie] public class TrialController : ControllerBase { - private readonly DataContext _context; - - public TrialController(DataContext context) - { - _context = context; - } - [HttpGet(Name = "GetTrial")] public bool Get() { - return bool.Parse(_context.Configuration.FirstOrDefault(x => x.Key == "trialMode").Value); + return false; } } } diff --git a/MyMcRealms/Controllers/WorldsController.cs b/MyMcRealms/Controllers/WorldsController.cs index 717d72d..9b44065 100644 --- a/MyMcRealms/Controllers/WorldsController.cs +++ b/MyMcRealms/Controllers/WorldsController.cs @@ -1,7 +1,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using MyMcRealms.Attributes; -using MyMcRealms.Data; using MyMcRealms.Entities; using MyMcRealms.MyMcAPI.Responses; using MyMcRealms.Responses; @@ -14,13 +13,6 @@ namespace MyMcRealms.Controllers [RequireMinecraftCookie] public class WorldsController : ControllerBase { - private readonly DataContext _context; - - public WorldsController(DataContext context) - { - _context = context; - } - [HttpGet] public async Task> GetWorlds() { @@ -57,7 +49,6 @@ namespace MyMcRealms.Controllers MinigameImage = null, ActiveSlot = 1, Member = false, - Players = [], DaysLeft = 7, Expired = false, ExpiredTrial = false, @@ -80,36 +71,11 @@ namespace MyMcRealms.Controllers [HttpGet("{id}")] public async Task> GetWorldById(int id) { - var world = await _context.Worlds.Include(w => w.Players).Include(w => w.Subscription).FirstOrDefaultAsync(w => w.Id == id); - - if (world?.Subscription == null) return NotFound("World not found"); - - WorldResponse response = new() - { - Id = world.Id, - Owner = world.Owner, - OwnerUUID = world.OwnerUUID, - Name = world.Name, - Motd = world.Motd, - State = world.State, - WorldType = world.WorldType, - MaxPlayers = world.MaxPlayers, - MinigameId = world.MinigameId, - MinigameName = world.MinigameName, - MinigameImage = world.MinigameImage, - ActiveSlot = world.ActiveSlot, - Member = world.Member, - Players = world.Players, - DaysLeft = ((DateTimeOffset)world.Subscription.StartDate.AddDays(30) - DateTime.Today).Days, - Expired = ((DateTimeOffset)world.Subscription.StartDate.AddDays(30) - DateTime.Today).Days < 0, - ExpiredTrial = false - }; - - return response; + return NotFound("World not found"); } [HttpGet("v1/{wId}/join/pc")] - public async Task> Join(int wId) + public async Task> Join(int wId) { AllServersResponse AllServers = await new MyMcAPI.MyMcAPI(Environment.GetEnvironmentVariable("MYMC_API_KEY")).GetAllServers(); diff --git a/MyMcRealms/Data/DataContext.cs b/MyMcRealms/Data/DataContext.cs deleted file mode 100644 index 8e2c8a1..0000000 --- a/MyMcRealms/Data/DataContext.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using MyMcRealms.Entities; - -namespace MyMcRealms.Data -{ - public class DataContext(DbContextOptions options) : DbContext(options) - { - public DbSet Worlds { get; set; } - public DbSet Subscriptions { get; set; } - public DbSet Connections { get; set; } - public DbSet Backups { get; set; } - public DbSet Invites { get; set; } - public DbSet Players { get; set; } - public DbSet Configuration { get; set; } - } -} diff --git a/MyMcRealms/Entities/Backup.cs b/MyMcRealms/Entities/Backup.cs deleted file mode 100644 index af4d5e9..0000000 --- a/MyMcRealms/Entities/Backup.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Text.Json; - -namespace MyMcRealms.Entities -{ - public class Backup - { - public int Id { get; set; } - public World World { get; set; } - public string BackupId { get; set; } - public long LastModifiedDate { get; set; } - public int Size { get; set; } - public JsonDocument Metadata { get; set; } - } -} diff --git a/MyMcRealms/Entities/Configuration.cs b/MyMcRealms/Entities/Configuration.cs deleted file mode 100644 index c8e10fa..0000000 --- a/MyMcRealms/Entities/Configuration.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using System.ComponentModel.DataAnnotations.Schema; - -namespace MyMcRealms.Entities -{ - [PrimaryKey(nameof(Key))] - public class Configuration - { - public string Key { get; set; } = string.Empty; - [Column(TypeName = "jsonb")] - public dynamic Value { get; set; } = string.Empty; - } -} diff --git a/MyMcRealms/Entities/Connection.cs b/MyMcRealms/Entities/Connection.cs deleted file mode 100644 index 9f9c322..0000000 --- a/MyMcRealms/Entities/Connection.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MyMcRealms.Entities -{ - public class Connection - { - public int Id { get; set; } - public World World { get; set; } - public string Address { get; set; } = string.Empty; - public bool PendingUpdate { get; set; } - } -} diff --git a/MyMcRealms/Entities/Invite.cs b/MyMcRealms/Entities/Invite.cs deleted file mode 100644 index bd8a34b..0000000 --- a/MyMcRealms/Entities/Invite.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace MyMcRealms.Entities -{ - public class Invite - { - public int Id { get; set; } - public string InvitationId { get; set; }= string.Empty; - public string RecipeintUUID { get; set; } = string.Empty; - public World World { get; set; } - public DateTime Date { get; set; } - } -} diff --git a/MyMcRealms/Entities/Player.cs b/MyMcRealms/Entities/Player.cs deleted file mode 100644 index f6f34df..0000000 --- a/MyMcRealms/Entities/Player.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace MyMcRealms.Entities -{ - public class Player - { - public int Id { get; set; } - public string Name { get; set; } = string.Empty; - public string Uuid { get; set; } = string.Empty; - public bool Operator { get; set; } - public bool Accepted { get; set; } - public bool Online { get; set; } - public string Permission { get; set; } = "MEMBER"; - public World World { get; set; } - } -} diff --git a/MyMcRealms/Entities/Slot.cs b/MyMcRealms/Entities/Slot.cs deleted file mode 100644 index f54f641..0000000 --- a/MyMcRealms/Entities/Slot.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace MyMcRealms.Entities -{ - public class Slot - { - public int SlotId { get; set; } - public string Options { get; set; } = "{}"; - } -} diff --git a/MyMcRealms/Entities/Subscription.cs b/MyMcRealms/Entities/Subscription.cs deleted file mode 100644 index 5138bfd..0000000 --- a/MyMcRealms/Entities/Subscription.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace MyMcRealms.Entities -{ - public class Subscription - { - public int Id { get; set; } - public int WorldId { get; set; } - public World World { get; set; } = null!; - public DateTime StartDate { get; set; } = DateTime.Now; - public string SubscriptionType { get; set; } = "NORMAL"; - } -} \ No newline at end of file diff --git a/MyMcRealms/Entities/World.cs b/MyMcRealms/Entities/World.cs deleted file mode 100644 index d3956b5..0000000 --- a/MyMcRealms/Entities/World.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Text.Json; - -namespace MyMcRealms.Entities -{ - public class World - { - public int Id { get; set; } - public Subscription? Subscription { get; set; } - public string? Owner { get; set; } - public string? OwnerUUID { get; set; } - public string? Name { get; set; } - public string? Motd { get; set; } - public string State { get; set; } = "OPEN"; - public string WorldType { get; set; } = "NORMAL"; - public List Players { get; set; } = []; - public int MaxPlayers { get; set; } = 10; - public string? MinigameName { get; set; } - public int? MinigameId { get; set; } - public string? MinigameImage { get; set; } - public int ActiveSlot { get; set; } = 1; - public JsonDocument[] Slots { get; set; } = []; - public bool Member { get; set; } = false; - } -} \ No newline at end of file diff --git a/MyMcRealms/Helpers/Database.cs b/MyMcRealms/Helpers/Database.cs deleted file mode 100644 index 0121d40..0000000 --- a/MyMcRealms/Helpers/Database.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using MyMcRealms.Data; -using MyMcRealms.Entities; - -namespace MyMcRealms.Helpers -{ - public class Database - { - public static void Initialize(WebApplication app) - { - var scope = app.Services.CreateScope(); - var db = scope.ServiceProvider.GetRequiredService(); - - db.Database.Migrate(); - - if (db.Configuration.FirstOrDefault(s => s.Key == "newsLink") == null) - { - var newsLink = new Configuration - { - Key = "newsLink", - Value = "\"https://github.com/CyberL1/Minecraft-Realms-Emulator\"" - }; - - db.Configuration.Add(newsLink); - } - - if (db.Configuration.FirstOrDefault(s => s.Key == "defaultServerAddress") == null) - { - var defaultServerAddress = new Configuration - { - Key = "defaultServerAddress", - Value = "\"127.0.0.1\"" - }; - - db.Configuration.Add(defaultServerAddress); - } - - if (db.Configuration.FirstOrDefault(x => x.Key == "trialMode") == null) - { - var trialMode = new Configuration - { - Key = "trialMode", - Value = true - }; - - db.Configuration.Add(trialMode); - } - - db.SaveChanges(); - } - } -} diff --git a/MyMcRealms/Migrations/20240202175209_Initial.Designer.cs b/MyMcRealms/Migrations/20240202175209_Initial.Designer.cs deleted file mode 100644 index bf10a62..0000000 --- a/MyMcRealms/Migrations/20240202175209_Initial.Designer.cs +++ /dev/null @@ -1,101 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using MyMcRealms.Data; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20240202175209_Initial")] - partial class Initial - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("MyMcRealms.Entities.World", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveSlot") - .HasColumnType("integer"); - - b.Property("DaysLeft") - .HasColumnType("integer"); - - b.Property("Expired") - .HasColumnType("boolean"); - - b.Property("ExpiredTrial") - .HasColumnType("boolean"); - - b.Property("MaxPlayers") - .HasColumnType("integer"); - - b.Property("Member") - .HasColumnType("boolean"); - - b.Property("MinigameId") - .HasColumnType("integer"); - - b.Property("MinigameImage") - .HasColumnType("text"); - - b.Property("MinigameName") - .HasColumnType("text"); - - b.Property("Motd") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Owner") - .HasColumnType("text"); - - b.Property("OwnerUUID") - .HasColumnType("text"); - - b.Property("Players") - .IsRequired() - .HasColumnType("text[]"); - - b.Property("RemoteSubscriptionId") - .HasColumnType("text"); - - b.Property("Slots") - .IsRequired() - .HasColumnType("text[]"); - - b.Property("State") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldType") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Worlds"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MyMcRealms/Migrations/20240202175209_Initial.cs b/MyMcRealms/Migrations/20240202175209_Initial.cs deleted file mode 100644 index 3561cb3..0000000 --- a/MyMcRealms/Migrations/20240202175209_Initial.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - /// - public partial class Initial : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Worlds", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - RemoteSubscriptionId = table.Column(type: "text", nullable: true), - Owner = table.Column(type: "text", nullable: true), - OwnerUUID = table.Column(type: "text", nullable: true), - Name = table.Column(type: "text", nullable: true), - Motd = table.Column(type: "text", nullable: true), - State = table.Column(type: "text", nullable: false), - DaysLeft = table.Column(type: "integer", nullable: false), - Expired = table.Column(type: "boolean", nullable: false), - ExpiredTrial = table.Column(type: "boolean", nullable: false), - WorldType = table.Column(type: "text", nullable: false), - Players = table.Column(type: "text[]", nullable: false), - MaxPlayers = table.Column(type: "integer", nullable: false), - MinigameName = table.Column(type: "text", nullable: true), - MinigameId = table.Column(type: "integer", nullable: true), - MinigameImage = table.Column(type: "text", nullable: true), - ActiveSlot = table.Column(type: "integer", nullable: false), - Slots = table.Column(type: "text[]", nullable: false), - Member = table.Column(type: "boolean", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Worlds", x => x.Id); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Worlds"); - } - } -} diff --git a/MyMcRealms/Migrations/20240203132410_Subscriptions.Designer.cs b/MyMcRealms/Migrations/20240203132410_Subscriptions.Designer.cs deleted file mode 100644 index 52cb5c6..0000000 --- a/MyMcRealms/Migrations/20240203132410_Subscriptions.Designer.cs +++ /dev/null @@ -1,130 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using MyMcRealms.Data; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20240203132410_Subscriptions")] - partial class Subscriptions - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("DaysLeft") - .HasColumnType("integer"); - - b.Property("RemoteId") - .IsRequired() - .HasColumnType("text"); - - b.Property("StartDate") - .IsRequired() - .HasColumnType("text"); - - b.Property("SubscriptionType") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.World", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveSlot") - .HasColumnType("integer"); - - b.Property("DaysLeft") - .HasColumnType("integer"); - - b.Property("Expired") - .HasColumnType("boolean"); - - b.Property("ExpiredTrial") - .HasColumnType("boolean"); - - b.Property("MaxPlayers") - .HasColumnType("integer"); - - b.Property("Member") - .HasColumnType("boolean"); - - b.Property("MinigameId") - .HasColumnType("integer"); - - b.Property("MinigameImage") - .HasColumnType("text"); - - b.Property("MinigameName") - .HasColumnType("text"); - - b.Property("Motd") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Owner") - .HasColumnType("text"); - - b.Property("OwnerUUID") - .HasColumnType("text"); - - b.Property("Players") - .IsRequired() - .HasColumnType("text[]"); - - b.Property("RemoteSubscriptionId") - .IsRequired() - .HasColumnType("text"); - - b.Property("Slots") - .IsRequired() - .HasColumnType("text[]"); - - b.Property("State") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldType") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Worlds"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MyMcRealms/Migrations/20240203132410_Subscriptions.cs b/MyMcRealms/Migrations/20240203132410_Subscriptions.cs deleted file mode 100644 index 2969e6f..0000000 --- a/MyMcRealms/Migrations/20240203132410_Subscriptions.cs +++ /dev/null @@ -1,56 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - /// - public partial class Subscriptions : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "RemoteSubscriptionId", - table: "Worlds", - type: "text", - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - - migrationBuilder.CreateTable( - name: "Subscriptions", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - RemoteId = table.Column(type: "text", nullable: false), - StartDate = table.Column(type: "text", nullable: false), - DaysLeft = table.Column(type: "integer", nullable: false), - SubscriptionType = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Subscriptions", x => x.Id); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Subscriptions"); - - migrationBuilder.AlterColumn( - name: "RemoteSubscriptionId", - table: "Worlds", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "text"); - } - } -} diff --git a/MyMcRealms/Migrations/20240211135246_Slots.Designer.cs b/MyMcRealms/Migrations/20240211135246_Slots.Designer.cs deleted file mode 100644 index a67d742..0000000 --- a/MyMcRealms/Migrations/20240211135246_Slots.Designer.cs +++ /dev/null @@ -1,131 +0,0 @@ -// -using System; -using System.Text.Json; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using MyMcRealms.Data; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20240211135246_Slots")] - partial class Slots - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("DaysLeft") - .HasColumnType("integer"); - - b.Property("RemoteId") - .IsRequired() - .HasColumnType("text"); - - b.Property("StartDate") - .IsRequired() - .HasColumnType("text"); - - b.Property("SubscriptionType") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.World", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveSlot") - .HasColumnType("integer"); - - b.Property("DaysLeft") - .HasColumnType("integer"); - - b.Property("Expired") - .HasColumnType("boolean"); - - b.Property("ExpiredTrial") - .HasColumnType("boolean"); - - b.Property("MaxPlayers") - .HasColumnType("integer"); - - b.Property("Member") - .HasColumnType("boolean"); - - b.Property("MinigameId") - .HasColumnType("integer"); - - b.Property("MinigameImage") - .HasColumnType("text"); - - b.Property("MinigameName") - .HasColumnType("text"); - - b.Property("Motd") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Owner") - .HasColumnType("text"); - - b.Property("OwnerUUID") - .HasColumnType("text"); - - b.Property("Players") - .IsRequired() - .HasColumnType("text[]"); - - b.Property("RemoteSubscriptionId") - .IsRequired() - .HasColumnType("text"); - - b.Property("Slots") - .IsRequired() - .HasColumnType("jsonb[]"); - - b.Property("State") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldType") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Worlds"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MyMcRealms/Migrations/20240211135246_Slots.cs b/MyMcRealms/Migrations/20240211135246_Slots.cs deleted file mode 100644 index 9f0f3e0..0000000 --- a/MyMcRealms/Migrations/20240211135246_Slots.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Text.Json; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - /// - public partial class Slots : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.Sql("ALTER TABLE \"Worlds\" ALTER COLUMN \"Slots\" TYPE jsonb[] USING \"Slots\"::jsonb[]"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.Sql("ALTER TABLE \"Worlds\" ALTER COLUMN \"Slots\" TYPE text[] USING \"Slots\"::text[]"); - } - } -} diff --git a/MyMcRealms/Migrations/20240213104200_Connections.Designer.cs b/MyMcRealms/Migrations/20240213104200_Connections.Designer.cs deleted file mode 100644 index b43f7f1..0000000 --- a/MyMcRealms/Migrations/20240213104200_Connections.Designer.cs +++ /dev/null @@ -1,159 +0,0 @@ -// -using System; -using System.Text.Json; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using MyMcRealms.Data; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20240213104200_Connections")] - partial class Connections - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("MyMcRealms.Entities.Connection", b => - { - b.Property("Address") - .IsRequired() - .HasColumnType("text"); - - b.Property("PendingUpdate") - .HasColumnType("boolean"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasIndex("WorldId"); - - b.ToTable("Connections"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("DaysLeft") - .HasColumnType("integer"); - - b.Property("RemoteId") - .IsRequired() - .HasColumnType("text"); - - b.Property("StartDate") - .IsRequired() - .HasColumnType("text"); - - b.Property("SubscriptionType") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.World", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveSlot") - .HasColumnType("integer"); - - b.Property("DaysLeft") - .HasColumnType("integer"); - - b.Property("Expired") - .HasColumnType("boolean"); - - b.Property("ExpiredTrial") - .HasColumnType("boolean"); - - b.Property("MaxPlayers") - .HasColumnType("integer"); - - b.Property("Member") - .HasColumnType("boolean"); - - b.Property("MinigameId") - .HasColumnType("integer"); - - b.Property("MinigameImage") - .HasColumnType("text"); - - b.Property("MinigameName") - .HasColumnType("text"); - - b.Property("Motd") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Owner") - .HasColumnType("text"); - - b.Property("OwnerUUID") - .HasColumnType("text"); - - b.Property("Players") - .IsRequired() - .HasColumnType("text[]"); - - b.Property("RemoteSubscriptionId") - .IsRequired() - .HasColumnType("text"); - - b.Property("Slots") - .IsRequired() - .HasColumnType("jsonb[]"); - - b.Property("State") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldType") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Worlds"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Connection", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MyMcRealms/Migrations/20240213104200_Connections.cs b/MyMcRealms/Migrations/20240213104200_Connections.cs deleted file mode 100644 index 9772696..0000000 --- a/MyMcRealms/Migrations/20240213104200_Connections.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - /// - public partial class Connections : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Connections", - columns: table => new - { - WorldId = table.Column(type: "integer", nullable: false), - Address = table.Column(type: "text", nullable: false), - PendingUpdate = table.Column(type: "boolean", nullable: false) - }, - constraints: table => - { - table.ForeignKey( - name: "FK_Connections_Worlds_WorldId", - column: x => x.WorldId, - principalTable: "Worlds", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_Connections_WorldId", - table: "Connections", - column: "WorldId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Connections"); - } - } -} diff --git a/MyMcRealms/Migrations/20240213121346_Subscription_v2.Designer.cs b/MyMcRealms/Migrations/20240213121346_Subscription_v2.Designer.cs deleted file mode 100644 index ff1aabb..0000000 --- a/MyMcRealms/Migrations/20240213121346_Subscription_v2.Designer.cs +++ /dev/null @@ -1,168 +0,0 @@ -// -using System; -using System.Text.Json; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using MyMcRealms.Data; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20240213121346_Subscription_v2")] - partial class Subscription_v2 - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("MyMcRealms.Entities.Connection", b => - { - b.Property("Address") - .IsRequired() - .HasColumnType("text"); - - b.Property("PendingUpdate") - .HasColumnType("boolean"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasIndex("WorldId"); - - b.ToTable("Connections"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("StartDate") - .IsRequired() - .HasColumnType("text"); - - b.Property("SubscriptionType") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.World", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveSlot") - .HasColumnType("integer"); - - b.Property("DaysLeft") - .HasColumnType("integer"); - - b.Property("Expired") - .HasColumnType("boolean"); - - b.Property("ExpiredTrial") - .HasColumnType("boolean"); - - b.Property("MaxPlayers") - .HasColumnType("integer"); - - b.Property("Member") - .HasColumnType("boolean"); - - b.Property("MinigameId") - .HasColumnType("integer"); - - b.Property("MinigameImage") - .HasColumnType("text"); - - b.Property("MinigameName") - .HasColumnType("text"); - - b.Property("Motd") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Owner") - .HasColumnType("text"); - - b.Property("OwnerUUID") - .HasColumnType("text"); - - b.Property("Players") - .IsRequired() - .HasColumnType("text[]"); - - b.Property("RemoteSubscriptionId") - .IsRequired() - .HasColumnType("text"); - - b.Property("Slots") - .IsRequired() - .HasColumnType("jsonb[]"); - - b.Property("State") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldType") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Worlds"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Connection", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MyMcRealms/Migrations/20240213121346_Subscription_v2.cs b/MyMcRealms/Migrations/20240213121346_Subscription_v2.cs deleted file mode 100644 index b9d3da0..0000000 --- a/MyMcRealms/Migrations/20240213121346_Subscription_v2.cs +++ /dev/null @@ -1,60 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - /// - public partial class Subscription_v2 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "RemoteId", - table: "Subscriptions"); - - migrationBuilder.RenameColumn( - name: "DaysLeft", - table: "Subscriptions", - newName: "WorldId"); - - migrationBuilder.CreateIndex( - name: "IX_Subscriptions_WorldId", - table: "Subscriptions", - column: "WorldId"); - - migrationBuilder.AddForeignKey( - name: "FK_Subscriptions_Worlds_WorldId", - table: "Subscriptions", - column: "WorldId", - principalTable: "Worlds", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Subscriptions_Worlds_WorldId", - table: "Subscriptions"); - - migrationBuilder.DropIndex( - name: "IX_Subscriptions_WorldId", - table: "Subscriptions"); - - migrationBuilder.RenameColumn( - name: "WorldId", - table: "Subscriptions", - newName: "DaysLeft"); - - migrationBuilder.AddColumn( - name: "RemoteId", - table: "Subscriptions", - type: "text", - nullable: false, - defaultValue: ""); - } - } -} diff --git a/MyMcRealms/Migrations/20240214154708_Backups.Designer.cs b/MyMcRealms/Migrations/20240214154708_Backups.Designer.cs deleted file mode 100644 index 7a9c3d9..0000000 --- a/MyMcRealms/Migrations/20240214154708_Backups.Designer.cs +++ /dev/null @@ -1,211 +0,0 @@ -// -using System; -using System.Text.Json; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using MyMcRealms.Data; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20240214154708_Backups")] - partial class Backups - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("MyMcRealms.Entities.Backup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BackupId") - .IsRequired() - .HasColumnType("text"); - - b.Property("LastModifiedDate") - .HasColumnType("bigint"); - - b.Property("Metadata") - .IsRequired() - .HasColumnType("jsonb"); - - b.Property("Size") - .HasColumnType("integer"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Backups"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Connection", b => - { - b.Property("Address") - .IsRequired() - .HasColumnType("text"); - - b.Property("PendingUpdate") - .HasColumnType("boolean"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasIndex("WorldId"); - - b.ToTable("Connections"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("StartDate") - .IsRequired() - .HasColumnType("text"); - - b.Property("SubscriptionType") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.World", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveSlot") - .HasColumnType("integer"); - - b.Property("DaysLeft") - .HasColumnType("integer"); - - b.Property("Expired") - .HasColumnType("boolean"); - - b.Property("ExpiredTrial") - .HasColumnType("boolean"); - - b.Property("MaxPlayers") - .HasColumnType("integer"); - - b.Property("Member") - .HasColumnType("boolean"); - - b.Property("MinigameId") - .HasColumnType("integer"); - - b.Property("MinigameImage") - .HasColumnType("text"); - - b.Property("MinigameName") - .HasColumnType("text"); - - b.Property("Motd") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Owner") - .HasColumnType("text"); - - b.Property("OwnerUUID") - .HasColumnType("text"); - - b.Property("Players") - .IsRequired() - .HasColumnType("text[]"); - - b.Property("RemoteSubscriptionId") - .IsRequired() - .HasColumnType("text"); - - b.Property("Slots") - .IsRequired() - .HasColumnType("jsonb[]"); - - b.Property("State") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldType") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Worlds"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Backup", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Connection", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MyMcRealms/Migrations/20240214154708_Backups.cs b/MyMcRealms/Migrations/20240214154708_Backups.cs deleted file mode 100644 index a3bea53..0000000 --- a/MyMcRealms/Migrations/20240214154708_Backups.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Text.Json; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - /// - public partial class Backups : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Backups", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - WorldId = table.Column(type: "integer", nullable: false), - BackupId = table.Column(type: "text", nullable: false), - LastModifiedDate = table.Column(type: "bigint", nullable: false), - Size = table.Column(type: "integer", nullable: false), - Metadata = table.Column(type: "jsonb", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Backups", x => x.Id); - table.ForeignKey( - name: "FK_Backups_Worlds_WorldId", - column: x => x.WorldId, - principalTable: "Worlds", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_Backups_WorldId", - table: "Backups", - column: "WorldId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Backups"); - } - } -} diff --git a/MyMcRealms/Migrations/20240218160304_Connections_Id.Designer.cs b/MyMcRealms/Migrations/20240218160304_Connections_Id.Designer.cs deleted file mode 100644 index aa5bd37..0000000 --- a/MyMcRealms/Migrations/20240218160304_Connections_Id.Designer.cs +++ /dev/null @@ -1,219 +0,0 @@ -// -using System; -using System.Text.Json; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using MyMcRealms.Data; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20240218160304_Connections_Id")] - partial class Connections_Id - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("MyMcRealms.Entities.Backup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BackupId") - .IsRequired() - .HasColumnType("text"); - - b.Property("LastModifiedDate") - .HasColumnType("bigint"); - - b.Property("Metadata") - .IsRequired() - .HasColumnType("jsonb"); - - b.Property("Size") - .HasColumnType("integer"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Backups"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Connection", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Address") - .IsRequired() - .HasColumnType("text"); - - b.Property("PendingUpdate") - .HasColumnType("boolean"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Connections"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("StartDate") - .IsRequired() - .HasColumnType("text"); - - b.Property("SubscriptionType") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.World", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveSlot") - .HasColumnType("integer"); - - b.Property("DaysLeft") - .HasColumnType("integer"); - - b.Property("Expired") - .HasColumnType("boolean"); - - b.Property("ExpiredTrial") - .HasColumnType("boolean"); - - b.Property("MaxPlayers") - .HasColumnType("integer"); - - b.Property("Member") - .HasColumnType("boolean"); - - b.Property("MinigameId") - .HasColumnType("integer"); - - b.Property("MinigameImage") - .HasColumnType("text"); - - b.Property("MinigameName") - .HasColumnType("text"); - - b.Property("Motd") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Owner") - .HasColumnType("text"); - - b.Property("OwnerUUID") - .HasColumnType("text"); - - b.Property("Players") - .IsRequired() - .HasColumnType("text[]"); - - b.Property("RemoteSubscriptionId") - .IsRequired() - .HasColumnType("text"); - - b.Property("Slots") - .IsRequired() - .HasColumnType("jsonb[]"); - - b.Property("State") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldType") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Worlds"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Backup", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Connection", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MyMcRealms/Migrations/20240218160304_Connections_Id.cs b/MyMcRealms/Migrations/20240218160304_Connections_Id.cs deleted file mode 100644 index 00b1128..0000000 --- a/MyMcRealms/Migrations/20240218160304_Connections_Id.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - /// - public partial class Connections_Id : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Id", - table: "Connections", - type: "integer", - nullable: false, - defaultValue: 0) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - migrationBuilder.AddPrimaryKey( - name: "PK_Connections", - table: "Connections", - column: "Id"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropPrimaryKey( - name: "PK_Connections", - table: "Connections"); - - migrationBuilder.DropColumn( - name: "Id", - table: "Connections"); - } - } -} diff --git a/MyMcRealms/Migrations/20240220092334_Invites.Designer.cs b/MyMcRealms/Migrations/20240220092334_Invites.Designer.cs deleted file mode 100644 index 56940b7..0000000 --- a/MyMcRealms/Migrations/20240220092334_Invites.Designer.cs +++ /dev/null @@ -1,259 +0,0 @@ -// -using System; -using System.Text.Json; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using MyMcRealms.Data; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20240220092334_Invites")] - partial class Invites - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("MyMcRealms.Entities.Backup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BackupId") - .IsRequired() - .HasColumnType("text"); - - b.Property("LastModifiedDate") - .HasColumnType("bigint"); - - b.Property("Metadata") - .IsRequired() - .HasColumnType("jsonb"); - - b.Property("Size") - .HasColumnType("integer"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Backups"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Connection", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Address") - .IsRequired() - .HasColumnType("text"); - - b.Property("PendingUpdate") - .HasColumnType("boolean"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Connections"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Invite", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Date") - .HasColumnType("timestamp with time zone"); - - b.Property("InvitationId") - .IsRequired() - .HasColumnType("text"); - - b.Property("RecipeintUUID") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Invites"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("StartDate") - .IsRequired() - .HasColumnType("text"); - - b.Property("SubscriptionType") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.World", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveSlot") - .HasColumnType("integer"); - - b.Property("DaysLeft") - .HasColumnType("integer"); - - b.Property("Expired") - .HasColumnType("boolean"); - - b.Property("ExpiredTrial") - .HasColumnType("boolean"); - - b.Property("MaxPlayers") - .HasColumnType("integer"); - - b.Property("Member") - .HasColumnType("boolean"); - - b.Property("MinigameId") - .HasColumnType("integer"); - - b.Property("MinigameImage") - .HasColumnType("text"); - - b.Property("MinigameName") - .HasColumnType("text"); - - b.Property("Motd") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Owner") - .HasColumnType("text"); - - b.Property("OwnerUUID") - .HasColumnType("text"); - - b.Property("Players") - .IsRequired() - .HasColumnType("text[]"); - - b.Property("RemoteSubscriptionId") - .IsRequired() - .HasColumnType("text"); - - b.Property("Slots") - .IsRequired() - .HasColumnType("jsonb[]"); - - b.Property("State") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldType") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Worlds"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Backup", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Connection", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Invite", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MyMcRealms/Migrations/20240220092334_Invites.cs b/MyMcRealms/Migrations/20240220092334_Invites.cs deleted file mode 100644 index cc93314..0000000 --- a/MyMcRealms/Migrations/20240220092334_Invites.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - /// - public partial class Invites : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Invites", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - InvitationId = table.Column(type: "text", nullable: false), - RecipeintUUID = table.Column(type: "text", nullable: false), - WorldId = table.Column(type: "integer", nullable: false), - Date = table.Column(type: "timestamp with time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Invites", x => x.Id); - table.ForeignKey( - name: "FK_Invites_Worlds_WorldId", - column: x => x.WorldId, - principalTable: "Worlds", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_Invites_WorldId", - table: "Invites", - column: "WorldId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Invites"); - } - } -} diff --git a/MyMcRealms/Migrations/20240221131108_Players.Designer.cs b/MyMcRealms/Migrations/20240221131108_Players.Designer.cs deleted file mode 100644 index 8d90c8a..0000000 --- a/MyMcRealms/Migrations/20240221131108_Players.Designer.cs +++ /dev/null @@ -1,310 +0,0 @@ -// -using System; -using System.Text.Json; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using MyMcRealms.Data; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20240221131108_Players")] - partial class Players - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("MyMcRealms.Entities.Backup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BackupId") - .IsRequired() - .HasColumnType("text"); - - b.Property("LastModifiedDate") - .HasColumnType("bigint"); - - b.Property("Metadata") - .IsRequired() - .HasColumnType("jsonb"); - - b.Property("Size") - .HasColumnType("integer"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Backups"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Connection", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Address") - .IsRequired() - .HasColumnType("text"); - - b.Property("PendingUpdate") - .HasColumnType("boolean"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Connections"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Invite", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Date") - .HasColumnType("timestamp with time zone"); - - b.Property("InvitationId") - .IsRequired() - .HasColumnType("text"); - - b.Property("RecipeintUUID") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Invites"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Player", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Accepted") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Online") - .HasColumnType("boolean"); - - b.Property("Operator") - .HasColumnType("boolean"); - - b.Property("Permission") - .IsRequired() - .HasColumnType("text"); - - b.Property("Uuid") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Players"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("StartDate") - .IsRequired() - .HasColumnType("text"); - - b.Property("SubscriptionType") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.World", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveSlot") - .HasColumnType("integer"); - - b.Property("DaysLeft") - .HasColumnType("integer"); - - b.Property("Expired") - .HasColumnType("boolean"); - - b.Property("ExpiredTrial") - .HasColumnType("boolean"); - - b.Property("MaxPlayers") - .HasColumnType("integer"); - - b.Property("Member") - .HasColumnType("boolean"); - - b.Property("MinigameId") - .HasColumnType("integer"); - - b.Property("MinigameImage") - .HasColumnType("text"); - - b.Property("MinigameName") - .HasColumnType("text"); - - b.Property("Motd") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Owner") - .HasColumnType("text"); - - b.Property("OwnerUUID") - .HasColumnType("text"); - - b.Property("RemoteSubscriptionId") - .IsRequired() - .HasColumnType("text"); - - b.Property("Slots") - .IsRequired() - .HasColumnType("jsonb[]"); - - b.Property("State") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldType") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Worlds"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Backup", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Connection", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Invite", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Player", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany("Players") - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.World", b => - { - b.Navigation("Players"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MyMcRealms/Migrations/20240221131108_Players.cs b/MyMcRealms/Migrations/20240221131108_Players.cs deleted file mode 100644 index f95db80..0000000 --- a/MyMcRealms/Migrations/20240221131108_Players.cs +++ /dev/null @@ -1,63 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - /// - public partial class Players : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Players", - table: "Worlds"); - - migrationBuilder.CreateTable( - name: "Players", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Name = table.Column(type: "text", nullable: false), - Uuid = table.Column(type: "text", nullable: false), - Operator = table.Column(type: "boolean", nullable: false), - Accepted = table.Column(type: "boolean", nullable: false), - Online = table.Column(type: "boolean", nullable: false), - Permission = table.Column(type: "text", nullable: false), - WorldId = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Players", x => x.Id); - table.ForeignKey( - name: "FK_Players_Worlds_WorldId", - column: x => x.WorldId, - principalTable: "Worlds", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_Players_WorldId", - table: "Players", - column: "WorldId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Players"); - - migrationBuilder.AddColumn( - name: "Players", - table: "Worlds", - type: "text[]", - nullable: false, - defaultValue: new string[0]); - } - } -} diff --git a/MyMcRealms/Migrations/20240301214442_Configuration.Designer.cs b/MyMcRealms/Migrations/20240301214442_Configuration.Designer.cs deleted file mode 100644 index e50d053..0000000 --- a/MyMcRealms/Migrations/20240301214442_Configuration.Designer.cs +++ /dev/null @@ -1,324 +0,0 @@ -// -using System; -using System.Text.Json; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using MyMcRealms.Data; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20240301214442_Configuration")] - partial class Configuration - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("MyMcRealms.Entities.Backup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BackupId") - .IsRequired() - .HasColumnType("text"); - - b.Property("LastModifiedDate") - .HasColumnType("bigint"); - - b.Property("Metadata") - .IsRequired() - .HasColumnType("jsonb"); - - b.Property("Size") - .HasColumnType("integer"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Backups"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Configuration", b => - { - b.Property("Key") - .HasColumnType("text"); - - b.Property("Value") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Key"); - - b.ToTable("Configuration"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Connection", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Address") - .IsRequired() - .HasColumnType("text"); - - b.Property("PendingUpdate") - .HasColumnType("boolean"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Connections"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Invite", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Date") - .HasColumnType("timestamp with time zone"); - - b.Property("InvitationId") - .IsRequired() - .HasColumnType("text"); - - b.Property("RecipeintUUID") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Invites"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Player", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Accepted") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Online") - .HasColumnType("boolean"); - - b.Property("Operator") - .HasColumnType("boolean"); - - b.Property("Permission") - .IsRequired() - .HasColumnType("text"); - - b.Property("Uuid") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Players"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("StartDate") - .IsRequired() - .HasColumnType("text"); - - b.Property("SubscriptionType") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.World", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveSlot") - .HasColumnType("integer"); - - b.Property("DaysLeft") - .HasColumnType("integer"); - - b.Property("Expired") - .HasColumnType("boolean"); - - b.Property("ExpiredTrial") - .HasColumnType("boolean"); - - b.Property("MaxPlayers") - .HasColumnType("integer"); - - b.Property("Member") - .HasColumnType("boolean"); - - b.Property("MinigameId") - .HasColumnType("integer"); - - b.Property("MinigameImage") - .HasColumnType("text"); - - b.Property("MinigameName") - .HasColumnType("text"); - - b.Property("Motd") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Owner") - .HasColumnType("text"); - - b.Property("OwnerUUID") - .HasColumnType("text"); - - b.Property("RemoteSubscriptionId") - .IsRequired() - .HasColumnType("text"); - - b.Property("Slots") - .IsRequired() - .HasColumnType("jsonb[]"); - - b.Property("State") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldType") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Worlds"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Backup", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Connection", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Invite", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Player", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany("Players") - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.World", b => - { - b.Navigation("Players"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MyMcRealms/Migrations/20240301214442_Configuration.cs b/MyMcRealms/Migrations/20240301214442_Configuration.cs deleted file mode 100644 index 5d33e02..0000000 --- a/MyMcRealms/Migrations/20240301214442_Configuration.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - /// - public partial class Configuration : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Configuration", - columns: table => new - { - Key = table.Column(type: "text", nullable: false), - Value = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Configuration", x => x.Key); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Configuration"); - } - } -} diff --git a/MyMcRealms/Migrations/20240315231009_Subscriptions_StartDate_Readable_Field.Designer.cs b/MyMcRealms/Migrations/20240315231009_Subscriptions_StartDate_Readable_Field.Designer.cs deleted file mode 100644 index ac3faf5..0000000 --- a/MyMcRealms/Migrations/20240315231009_Subscriptions_StartDate_Readable_Field.Designer.cs +++ /dev/null @@ -1,323 +0,0 @@ -// -using System; -using System.Text.Json; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using MyMcRealms.Data; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20240315231009_Subscriptions_StartDate_Readable_Field")] - partial class Subscriptions_StartDate_Readable_Field - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("MyMcRealms.Entities.Backup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BackupId") - .IsRequired() - .HasColumnType("text"); - - b.Property("LastModifiedDate") - .HasColumnType("bigint"); - - b.Property("Metadata") - .IsRequired() - .HasColumnType("jsonb"); - - b.Property("Size") - .HasColumnType("integer"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Backups"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Configuration", b => - { - b.Property("Key") - .HasColumnType("text"); - - b.Property("Value") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Key"); - - b.ToTable("Configuration"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Connection", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Address") - .IsRequired() - .HasColumnType("text"); - - b.Property("PendingUpdate") - .HasColumnType("boolean"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Connections"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Invite", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Date") - .HasColumnType("timestamp with time zone"); - - b.Property("InvitationId") - .IsRequired() - .HasColumnType("text"); - - b.Property("RecipeintUUID") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Invites"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Player", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Accepted") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Online") - .HasColumnType("boolean"); - - b.Property("Operator") - .HasColumnType("boolean"); - - b.Property("Permission") - .IsRequired() - .HasColumnType("text"); - - b.Property("Uuid") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Players"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("StartDate") - .HasColumnType("timestamp with time zone"); - - b.Property("SubscriptionType") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.World", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveSlot") - .HasColumnType("integer"); - - b.Property("DaysLeft") - .HasColumnType("integer"); - - b.Property("Expired") - .HasColumnType("boolean"); - - b.Property("ExpiredTrial") - .HasColumnType("boolean"); - - b.Property("MaxPlayers") - .HasColumnType("integer"); - - b.Property("Member") - .HasColumnType("boolean"); - - b.Property("MinigameId") - .HasColumnType("integer"); - - b.Property("MinigameImage") - .HasColumnType("text"); - - b.Property("MinigameName") - .HasColumnType("text"); - - b.Property("Motd") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Owner") - .HasColumnType("text"); - - b.Property("OwnerUUID") - .HasColumnType("text"); - - b.Property("RemoteSubscriptionId") - .IsRequired() - .HasColumnType("text"); - - b.Property("Slots") - .IsRequired() - .HasColumnType("jsonb[]"); - - b.Property("State") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldType") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Worlds"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Backup", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Connection", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Invite", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Player", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany("Players") - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.World", b => - { - b.Navigation("Players"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MyMcRealms/Migrations/20240315231009_Subscriptions_StartDate_Readable_Field.cs b/MyMcRealms/Migrations/20240315231009_Subscriptions_StartDate_Readable_Field.cs deleted file mode 100644 index ac0b70b..0000000 --- a/MyMcRealms/Migrations/20240315231009_Subscriptions_StartDate_Readable_Field.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - /// - public partial class Subscriptions_StartDate_Readable_Field : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.Sql("ALTER TABLE \"Subscriptions\" ALTER COLUMN \"StartDate\" TYPE timestamptz USING \"StartDate\"::timestamptz"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.Sql("ALTER TABLE \"Subscriptions\" ALTER COLUMN \"StartDate\" TYPE text USING \"StartDate\"::text"); - } - } -} diff --git a/MyMcRealms/Migrations/20240317120329_Worlds_Subscription_field.Designer.cs b/MyMcRealms/Migrations/20240317120329_Worlds_Subscription_field.Designer.cs deleted file mode 100644 index d47a832..0000000 --- a/MyMcRealms/Migrations/20240317120329_Worlds_Subscription_field.Designer.cs +++ /dev/null @@ -1,313 +0,0 @@ -// -using System; -using System.Text.Json; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using MyMcRealms.Data; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20240317120329_Worlds_Subscription_field")] - partial class Worlds_Subscription_field - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("MyMcRealms.Entities.Backup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BackupId") - .IsRequired() - .HasColumnType("text"); - - b.Property("LastModifiedDate") - .HasColumnType("bigint"); - - b.Property("Metadata") - .IsRequired() - .HasColumnType("jsonb"); - - b.Property("Size") - .HasColumnType("integer"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Backups"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Configuration", b => - { - b.Property("Key") - .HasColumnType("text"); - - b.Property("Value") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Key"); - - b.ToTable("Configuration"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Connection", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Address") - .IsRequired() - .HasColumnType("text"); - - b.Property("PendingUpdate") - .HasColumnType("boolean"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Connections"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Invite", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Date") - .HasColumnType("timestamp with time zone"); - - b.Property("InvitationId") - .IsRequired() - .HasColumnType("text"); - - b.Property("RecipeintUUID") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Invites"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Player", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Accepted") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Online") - .HasColumnType("boolean"); - - b.Property("Operator") - .HasColumnType("boolean"); - - b.Property("Permission") - .IsRequired() - .HasColumnType("text"); - - b.Property("Uuid") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Players"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("StartDate") - .HasColumnType("timestamp with time zone"); - - b.Property("SubscriptionType") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId") - .IsUnique(); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.World", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveSlot") - .HasColumnType("integer"); - - b.Property("MaxPlayers") - .HasColumnType("integer"); - - b.Property("Member") - .HasColumnType("boolean"); - - b.Property("MinigameId") - .HasColumnType("integer"); - - b.Property("MinigameImage") - .HasColumnType("text"); - - b.Property("MinigameName") - .HasColumnType("text"); - - b.Property("Motd") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Owner") - .HasColumnType("text"); - - b.Property("OwnerUUID") - .HasColumnType("text"); - - b.Property("Slots") - .IsRequired() - .HasColumnType("jsonb[]"); - - b.Property("State") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldType") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Worlds"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Backup", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Connection", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Invite", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Player", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany("Players") - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithOne("Subscription") - .HasForeignKey("MyMcRealms.Entities.Subscription", "WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.World", b => - { - b.Navigation("Players"); - - b.Navigation("Subscription"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MyMcRealms/Migrations/20240317120329_Worlds_Subscription_field.cs b/MyMcRealms/Migrations/20240317120329_Worlds_Subscription_field.cs deleted file mode 100644 index 823b109..0000000 --- a/MyMcRealms/Migrations/20240317120329_Worlds_Subscription_field.cs +++ /dev/null @@ -1,81 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - /// - public partial class Worlds_Subscription_field : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropIndex( - name: "IX_Subscriptions_WorldId", - table: "Subscriptions"); - - migrationBuilder.DropColumn( - name: "DaysLeft", - table: "Worlds"); - - migrationBuilder.DropColumn( - name: "Expired", - table: "Worlds"); - - migrationBuilder.DropColumn( - name: "ExpiredTrial", - table: "Worlds"); - - migrationBuilder.DropColumn( - name: "RemoteSubscriptionId", - table: "Worlds"); - - migrationBuilder.CreateIndex( - name: "IX_Subscriptions_WorldId", - table: "Subscriptions", - column: "WorldId", - unique: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropIndex( - name: "IX_Subscriptions_WorldId", - table: "Subscriptions"); - - migrationBuilder.AddColumn( - name: "DaysLeft", - table: "Worlds", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "Expired", - table: "Worlds", - type: "boolean", - nullable: false, - defaultValue: false); - - migrationBuilder.AddColumn( - name: "ExpiredTrial", - table: "Worlds", - type: "boolean", - nullable: false, - defaultValue: false); - - migrationBuilder.AddColumn( - name: "RemoteSubscriptionId", - table: "Worlds", - type: "text", - nullable: false, - defaultValue: ""); - - migrationBuilder.CreateIndex( - name: "IX_Subscriptions_WorldId", - table: "Subscriptions", - column: "WorldId"); - } - } -} diff --git a/MyMcRealms/Migrations/20240414062222_Configuration_Json.Designer.cs b/MyMcRealms/Migrations/20240414062222_Configuration_Json.Designer.cs deleted file mode 100644 index 9a7fd6d..0000000 --- a/MyMcRealms/Migrations/20240414062222_Configuration_Json.Designer.cs +++ /dev/null @@ -1,313 +0,0 @@ -// -using System; -using System.Text.Json; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using MyMcRealms.Data; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20240414062222_Configuration_Json")] - partial class Configuration_Json - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("MyMcRealms.Entities.Backup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BackupId") - .IsRequired() - .HasColumnType("text"); - - b.Property("LastModifiedDate") - .HasColumnType("bigint"); - - b.Property("Metadata") - .IsRequired() - .HasColumnType("jsonb"); - - b.Property("Size") - .HasColumnType("integer"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Backups"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Configuration", b => - { - b.Property("Key") - .HasColumnType("text"); - - b.Property("Value") - .IsRequired() - .HasColumnType("jsonb"); - - b.HasKey("Key"); - - b.ToTable("Configuration"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Connection", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Address") - .IsRequired() - .HasColumnType("text"); - - b.Property("PendingUpdate") - .HasColumnType("boolean"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Connections"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Invite", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Date") - .HasColumnType("timestamp with time zone"); - - b.Property("InvitationId") - .IsRequired() - .HasColumnType("text"); - - b.Property("RecipeintUUID") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Invites"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Player", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Accepted") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Online") - .HasColumnType("boolean"); - - b.Property("Operator") - .HasColumnType("boolean"); - - b.Property("Permission") - .IsRequired() - .HasColumnType("text"); - - b.Property("Uuid") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Players"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("StartDate") - .HasColumnType("timestamp with time zone"); - - b.Property("SubscriptionType") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId") - .IsUnique(); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.World", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveSlot") - .HasColumnType("integer"); - - b.Property("MaxPlayers") - .HasColumnType("integer"); - - b.Property("Member") - .HasColumnType("boolean"); - - b.Property("MinigameId") - .HasColumnType("integer"); - - b.Property("MinigameImage") - .HasColumnType("text"); - - b.Property("MinigameName") - .HasColumnType("text"); - - b.Property("Motd") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Owner") - .HasColumnType("text"); - - b.Property("OwnerUUID") - .HasColumnType("text"); - - b.Property("Slots") - .IsRequired() - .HasColumnType("jsonb[]"); - - b.Property("State") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldType") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Worlds"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Backup", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Connection", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Invite", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Player", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany("Players") - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithOne("Subscription") - .HasForeignKey("MyMcRealms.Entities.Subscription", "WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.World", b => - { - b.Navigation("Players"); - - b.Navigation("Subscription"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MyMcRealms/Migrations/20240414062222_Configuration_Json.cs b/MyMcRealms/Migrations/20240414062222_Configuration_Json.cs deleted file mode 100644 index 6f9b4fc..0000000 --- a/MyMcRealms/Migrations/20240414062222_Configuration_Json.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - /// - public partial class Configuration_Json : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.Sql("ALTER TABLE \"Configuration\" ALTER COLUMN \"Value\" TYPE jsonb USING \"Value\"::jsonb"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.Sql("ALTER TABLE \"Configuration\" ALTER COLUMN \"Value\" TYPE text USING \"Value\"::text"); - } - } -} diff --git a/MyMcRealms/Migrations/DataContextModelSnapshot.cs b/MyMcRealms/Migrations/DataContextModelSnapshot.cs deleted file mode 100644 index 0995620..0000000 --- a/MyMcRealms/Migrations/DataContextModelSnapshot.cs +++ /dev/null @@ -1,310 +0,0 @@ -// -using System; -using System.Text.Json; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using MyMcRealms.Data; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace MyMcRealms.Migrations -{ - [DbContext(typeof(DataContext))] - partial class DataContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("MyMcRealms.Entities.Backup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BackupId") - .IsRequired() - .HasColumnType("text"); - - b.Property("LastModifiedDate") - .HasColumnType("bigint"); - - b.Property("Metadata") - .IsRequired() - .HasColumnType("jsonb"); - - b.Property("Size") - .HasColumnType("integer"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Backups", (string)null); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Configuration", b => - { - b.Property("Key") - .HasColumnType("text"); - - b.Property("Value") - .IsRequired() - .HasColumnType("jsonb"); - - b.HasKey("Key"); - - b.ToTable("Configuration", (string)null); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Connection", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Address") - .IsRequired() - .HasColumnType("text"); - - b.Property("PendingUpdate") - .HasColumnType("boolean"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Connections", (string)null); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Invite", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Date") - .HasColumnType("timestamp with time zone"); - - b.Property("InvitationId") - .IsRequired() - .HasColumnType("text"); - - b.Property("RecipeintUUID") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Invites", (string)null); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Player", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Accepted") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Online") - .HasColumnType("boolean"); - - b.Property("Operator") - .HasColumnType("boolean"); - - b.Property("Permission") - .IsRequired() - .HasColumnType("text"); - - b.Property("Uuid") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId"); - - b.ToTable("Players", (string)null); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("StartDate") - .HasColumnType("timestamp with time zone"); - - b.Property("SubscriptionType") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("WorldId") - .IsUnique(); - - b.ToTable("Subscriptions", (string)null); - }); - - modelBuilder.Entity("MyMcRealms.Entities.World", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveSlot") - .HasColumnType("integer"); - - b.Property("MaxPlayers") - .HasColumnType("integer"); - - b.Property("Member") - .HasColumnType("boolean"); - - b.Property("MinigameId") - .HasColumnType("integer"); - - b.Property("MinigameImage") - .HasColumnType("text"); - - b.Property("MinigameName") - .HasColumnType("text"); - - b.Property("Motd") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Owner") - .HasColumnType("text"); - - b.Property("OwnerUUID") - .HasColumnType("text"); - - b.Property("Slots") - .IsRequired() - .HasColumnType("jsonb[]"); - - b.Property("State") - .IsRequired() - .HasColumnType("text"); - - b.Property("WorldType") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Worlds", (string)null); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Backup", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Connection", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Invite", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany() - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Player", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithMany("Players") - .HasForeignKey("WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => - { - b.HasOne("MyMcRealms.Entities.World", "World") - .WithOne("Subscription") - .HasForeignKey("MyMcRealms.Entities.Subscription", "WorldId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("World"); - }); - - modelBuilder.Entity("MyMcRealms.Entities.World", b => - { - b.Navigation("Players"); - - b.Navigation("Subscription"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MyMcRealms/MyMcAPI/Responses/AllServersResponse.cs b/MyMcRealms/MyMcAPI/Responses/AllServersResponse.cs index 2e47c18..b584bc2 100644 --- a/MyMcRealms/MyMcAPI/Responses/AllServersResponse.cs +++ b/MyMcRealms/MyMcAPI/Responses/AllServersResponse.cs @@ -1,5 +1,4 @@ - -namespace MyMcRealms.MyMcAPI.Responses +namespace MyMcRealms.MyMcAPI.Responses { public class AllServersResponse { @@ -14,5 +13,22 @@ namespace MyMcRealms.MyMcAPI.Responses public string GameVersion { get; set; } = string.Empty; public string Motd { get; set; } = string.Empty; public bool Online { get; set; } + public List UserCache { get; set; } = null!; + public List Ops { get; set; } = null!; + } + + public class UserCache + { + public string Name { get; set; } = null!; + public string Uuid { get; set; } = null!; + public string ExpiresOn { get; set; } = null!; + } + + public class Op + { + public string Uuid { get; set; } = null!; + public string Name { get; set; } = null!; + public int Level { get; set; } + public bool BypassesPlayerLimit { get; set; } } } diff --git a/MyMcRealms/Program.cs b/MyMcRealms/Program.cs index 80bfc5d..644c807 100644 --- a/MyMcRealms/Program.cs +++ b/MyMcRealms/Program.cs @@ -1,19 +1,9 @@ -using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.FileProviders; -using MyMcRealms.Data; -using MyMcRealms.Helpers; using MyMcRealms.Middlewares; -using Npgsql; var builder = WebApplication.CreateBuilder(args); DotNetEnv.Env.Load(); -if (Environment.GetEnvironmentVariable("CONNECTION_STRING") == null) -{ - Console.WriteLine("CONNECTION_STRING environment variable missing"); - return; -} - if (Environment.GetEnvironmentVariable("MYMC_API_KEY") == null) { Console.WriteLine("MYMC_API_KEY environment variable missing"); @@ -28,20 +18,8 @@ builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); builder.Services.AddDirectoryBrowser(); -var dataSourceBuilder = new NpgsqlDataSourceBuilder(Environment.GetEnvironmentVariable("CONNECTION_STRING")); -dataSourceBuilder.EnableDynamicJson(); -var dataSource = dataSourceBuilder.Build(); - -builder.Services.AddDbContext(options => -{ - options.UseNpgsql(dataSource); -}); - var app = builder.Build(); -// Initialize database -Database.Initialize(app); - // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { diff --git a/MyMcRealms/Responses/BackupsResponse.cs b/MyMcRealms/Responses/BackupsResponse.cs deleted file mode 100644 index 16300a3..0000000 --- a/MyMcRealms/Responses/BackupsResponse.cs +++ /dev/null @@ -1,9 +0,0 @@ -using MyMcRealms.Entities; - -namespace MyMcRealms.Responses -{ - public class BackupsResponse - { - public List Backups { get; set; } - } -} diff --git a/MyMcRealms/Responses/InviteList.cs b/MyMcRealms/Responses/InviteList.cs deleted file mode 100644 index b2aa183..0000000 --- a/MyMcRealms/Responses/InviteList.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace MyMcRealms.Responses -{ - public class InviteList - { - public List Invites { get; set; } - } - - public class InviteResponse - { - public string InvitationId { get; set; } = string.Empty; - public string WorldName { get; set; } = string.Empty; - public string WorldOwnerName { get; set; } = string.Empty; - public string WorldOwnerUuid { get; set; } = string.Empty; - public long Date { get; set; } - } -} diff --git a/MyMcRealms/Responses/MinecraftPlayerInfo.cs b/MyMcRealms/Responses/MinecraftPlayerInfo.cs deleted file mode 100644 index cddff99..0000000 --- a/MyMcRealms/Responses/MinecraftPlayerInfo.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace MyMcRealms.Responses -{ - public class MinecraftPlayerInfo - { - public string Id { get; set; } = string.Empty; - public string Name { get; set; } = string.Empty; - public object Result { get; set; } - } -} diff --git a/MyMcRealms/Responses/OpsResponse.cs b/MyMcRealms/Responses/OpsResponse.cs deleted file mode 100644 index ea6e8e1..0000000 --- a/MyMcRealms/Responses/OpsResponse.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace MyMcRealms.Responses -{ - public class OpsResponse - { - public List Ops { get; set; } - } -} diff --git a/MyMcRealms/Responses/SubscriptionResponse.cs b/MyMcRealms/Responses/SubscriptionResponse.cs deleted file mode 100644 index 8e09057..0000000 --- a/MyMcRealms/Responses/SubscriptionResponse.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace MyMcRealms.Responses -{ - public class SubscriptionResponse - { - public long StartDate { get; set; } - public int DaysLeft { get; set; } - public string SubscriptionType { get; set; } - } -} diff --git a/MyMcRealms/Responses/WorldResponse.cs b/MyMcRealms/Responses/WorldResponse.cs index fdcfc1c..f7fafa8 100644 --- a/MyMcRealms/Responses/WorldResponse.cs +++ b/MyMcRealms/Responses/WorldResponse.cs @@ -1,7 +1,25 @@ -namespace MyMcRealms.Entities +using System.Text.Json; + +namespace MyMcRealms.Entities { - public class WorldResponse : World + public class WorldResponse { + public int Id { get; set; } +// public Subscription? Subscription { get; set; } + public string? Owner { get; set; } + public string? OwnerUUID { get; set; } + public string? Name { get; set; } + public string? Motd { get; set; } + public string State { get; set; } = "OPEN"; + public string WorldType { get; set; } = "NORMAL"; + // public List Players { get; set; } = []; + public int MaxPlayers { get; set; } = 10; + public string? MinigameName { get; set; } + public int? MinigameId { get; set; } + public string? MinigameImage { get; set; } + public int ActiveSlot { get; set; } = 1; + public JsonDocument[] Slots { get; set; } = []; + public bool Member { get; set; } = false; public string RemoteSubscriptionId { get; set; } = Guid.NewGuid().ToString(); public int DaysLeft { get; set; } = 30; public bool Expired { get; set; } = false;