From 5bae9328d93c0641e080ea1cca0295793ded62b6 Mon Sep 17 00:00:00 2001 From: triggermeelmo Date: Thu, 8 Jan 2026 12:29:03 +0100 Subject: [PATCH] Added Containers to Database --- watcher-monitoring/Data/WatcherDbContext.cs | 2 + .../20260108112653_containers-new.Designer.cs | 114 ++++++++++++++++++ .../20260108112653_containers-new.cs | 34 ++++++ .../WatcherDbContextModelSnapshot.cs | 16 +++ watcher-monitoring/Models/Container.cs | 16 +++ 5 files changed, 182 insertions(+) create mode 100644 watcher-monitoring/Migrations/20260108112653_containers-new.Designer.cs create mode 100644 watcher-monitoring/Migrations/20260108112653_containers-new.cs create mode 100644 watcher-monitoring/Models/Container.cs diff --git a/watcher-monitoring/Data/WatcherDbContext.cs b/watcher-monitoring/Data/WatcherDbContext.cs index 81785c9..beccd6b 100644 --- a/watcher-monitoring/Data/WatcherDbContext.cs +++ b/watcher-monitoring/Data/WatcherDbContext.cs @@ -19,4 +19,6 @@ public class WatcherDbContext : DbContext public DbSet Servers { get; set; } public DbSet Users { get; set; } + public DbSet Containers { get; set; } + } \ No newline at end of file diff --git a/watcher-monitoring/Migrations/20260108112653_containers-new.Designer.cs b/watcher-monitoring/Migrations/20260108112653_containers-new.Designer.cs new file mode 100644 index 0000000..f736ff1 --- /dev/null +++ b/watcher-monitoring/Migrations/20260108112653_containers-new.Designer.cs @@ -0,0 +1,114 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using watcher_monitoring.Data; + +#nullable disable + +namespace watcher_monitoring.Migrations +{ + [DbContext(typeof(WatcherDbContext))] + [Migration("20260108112653_containers-new")] + partial class containersnew + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.6"); + + modelBuilder.Entity("watcher_monitoring.Models.Container", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ContainerName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Containers"); + }); + + modelBuilder.Entity("watcher_monitoring.Models.Server", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CpuCores") + .HasColumnType("INTEGER"); + + b.Property("CpuType") + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("DiskSpace") + .HasColumnType("TEXT"); + + b.Property("GpuType") + .HasColumnType("TEXT"); + + b.Property("IPAddress") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("IsOnline") + .HasColumnType("INTEGER"); + + b.Property("IsVerified") + .HasColumnType("INTEGER"); + + b.Property("LastSeen") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("RamSize") + .HasColumnType("REAL"); + + b.HasKey("Id"); + + b.ToTable("Servers"); + }); + + modelBuilder.Entity("watcher_monitoring.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("LastLogin") + .HasColumnType("TEXT"); + + b.Property("Password") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/watcher-monitoring/Migrations/20260108112653_containers-new.cs b/watcher-monitoring/Migrations/20260108112653_containers-new.cs new file mode 100644 index 0000000..34a2c6c --- /dev/null +++ b/watcher-monitoring/Migrations/20260108112653_containers-new.cs @@ -0,0 +1,34 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace watcher_monitoring.Migrations +{ + /// + public partial class containersnew : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Containers", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + ContainerName = table.Column(type: "TEXT", maxLength: 50, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Containers", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Containers"); + } + } +} diff --git a/watcher-monitoring/Migrations/WatcherDbContextModelSnapshot.cs b/watcher-monitoring/Migrations/WatcherDbContextModelSnapshot.cs index ce0b993..a75b290 100644 --- a/watcher-monitoring/Migrations/WatcherDbContextModelSnapshot.cs +++ b/watcher-monitoring/Migrations/WatcherDbContextModelSnapshot.cs @@ -17,6 +17,22 @@ namespace watcher_monitoring.Migrations #pragma warning disable 612, 618 modelBuilder.HasAnnotation("ProductVersion", "8.0.6"); + modelBuilder.Entity("watcher_monitoring.Models.Container", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ContainerName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Containers"); + }); + modelBuilder.Entity("watcher_monitoring.Models.Server", b => { b.Property("Id") diff --git a/watcher-monitoring/Models/Container.cs b/watcher-monitoring/Models/Container.cs new file mode 100644 index 0000000..031df47 --- /dev/null +++ b/watcher-monitoring/Models/Container.cs @@ -0,0 +1,16 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace watcher_monitoring.Models; + +public class Container +{ + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int Id { get; set; } + + [Required] + [StringLength(50)] + public required string ContainerName { get; set; } = null!; + +}