basic Db-Setup done
This commit is contained in:
@@ -8,6 +8,19 @@ public class AppDbContext : DbContext
|
||||
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
|
||||
|
||||
public DbSet<Container> Containers { get; set; }
|
||||
|
||||
public DbSet<Server> Servers { get; set; }
|
||||
|
||||
public DbSet<Image> Images { get; set; }
|
||||
|
||||
public DbSet<LogEvent> LogEvents { get; set; }
|
||||
|
||||
public DbSet<Metric> Metrics { get; set; }
|
||||
|
||||
public DbSet<Tag> Tags { get; set; }
|
||||
|
||||
public DbSet<User> Users { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
87
Watcher/Migrations/20250614153746_ServerModelAdded.Designer.cs
generated
Normal file
87
Watcher/Migrations/20250614153746_ServerModelAdded.Designer.cs
generated
Normal file
@@ -0,0 +1,87 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Watcher.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Watcher.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20250614153746_ServerModelAdded")]
|
||||
partial class ServerModelAdded
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.6")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Container", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Hostname")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Containers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Server", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Hostname")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Servers");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
45
Watcher/Migrations/20250614153746_ServerModelAdded.cs
Normal file
45
Watcher/Migrations/20250614153746_ServerModelAdded.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Watcher.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class ServerModelAdded : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Servers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
Name = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Status = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
Hostname = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Type = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Servers", x => x.Id);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Servers");
|
||||
}
|
||||
}
|
||||
}
|
87
Watcher/Migrations/20250614154943_InitialModelsAdded.Designer.cs
generated
Normal file
87
Watcher/Migrations/20250614154943_InitialModelsAdded.Designer.cs
generated
Normal file
@@ -0,0 +1,87 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Watcher.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Watcher.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20250614154943_InitialModelsAdded")]
|
||||
partial class InitialModelsAdded
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.6")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Container", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Hostname")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Containers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Server", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Hostname")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Servers");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
22
Watcher/Migrations/20250614154943_InitialModelsAdded.cs
Normal file
22
Watcher/Migrations/20250614154943_InitialModelsAdded.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Watcher.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialModelsAdded : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
271
Watcher/Migrations/20250614155203_InitialModelsAdded_1.Designer.cs
generated
Normal file
271
Watcher/Migrations/20250614155203_InitialModelsAdded_1.Designer.cs
generated
Normal file
@@ -0,0 +1,271 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Watcher.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Watcher.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20250614155203_InitialModelsAdded_1")]
|
||||
partial class InitialModelsAdded_1
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.6")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Container", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Hostname")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int?>("ImageId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int?>("TagId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ImageId");
|
||||
|
||||
b.HasIndex("TagId");
|
||||
|
||||
b.ToTable("Containers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Image", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Tag")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Images");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("ContainerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Level")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Message")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int?>("ServerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("Timestamp")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ContainerId");
|
||||
|
||||
b.HasIndex("ServerId");
|
||||
|
||||
b.ToTable("LogEvents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Metric", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("ContainerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("ServerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("Timestamp")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<double>("Value")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ContainerId");
|
||||
|
||||
b.HasIndex("ServerId");
|
||||
|
||||
b.ToTable("Metrics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Server", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Hostname")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int?>("TagId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("TagId");
|
||||
|
||||
b.ToTable("Servers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Tag", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Tags");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("PocketId")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Role")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Container", b =>
|
||||
{
|
||||
b.HasOne("Watcher.Models.Image", null)
|
||||
.WithMany("Containers")
|
||||
.HasForeignKey("ImageId");
|
||||
|
||||
b.HasOne("Watcher.Models.Tag", null)
|
||||
.WithMany("Containers")
|
||||
.HasForeignKey("TagId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
||||
{
|
||||
b.HasOne("Watcher.Models.Container", "Container")
|
||||
.WithMany()
|
||||
.HasForeignKey("ContainerId");
|
||||
|
||||
b.HasOne("Watcher.Models.Server", "Server")
|
||||
.WithMany()
|
||||
.HasForeignKey("ServerId");
|
||||
|
||||
b.Navigation("Container");
|
||||
|
||||
b.Navigation("Server");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Metric", b =>
|
||||
{
|
||||
b.HasOne("Watcher.Models.Container", "Container")
|
||||
.WithMany()
|
||||
.HasForeignKey("ContainerId");
|
||||
|
||||
b.HasOne("Watcher.Models.Server", "Server")
|
||||
.WithMany()
|
||||
.HasForeignKey("ServerId");
|
||||
|
||||
b.Navigation("Container");
|
||||
|
||||
b.Navigation("Server");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Server", b =>
|
||||
{
|
||||
b.HasOne("Watcher.Models.Tag", null)
|
||||
.WithMany("Servers")
|
||||
.HasForeignKey("TagId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Image", b =>
|
||||
{
|
||||
b.Navigation("Containers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Tag", b =>
|
||||
{
|
||||
b.Navigation("Containers");
|
||||
|
||||
b.Navigation("Servers");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
253
Watcher/Migrations/20250614155203_InitialModelsAdded_1.cs
Normal file
253
Watcher/Migrations/20250614155203_InitialModelsAdded_1.cs
Normal file
@@ -0,0 +1,253 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Watcher.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialModelsAdded_1 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "TagId",
|
||||
table: "Servers",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ImageId",
|
||||
table: "Containers",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "TagId",
|
||||
table: "Containers",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Images",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
Name = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Tag = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Images", x => x.Id);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "LogEvents",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
Timestamp = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
Message = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Level = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ServerId = table.Column<int>(type: "int", nullable: true),
|
||||
ContainerId = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_LogEvents", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_LogEvents_Containers_ContainerId",
|
||||
column: x => x.ContainerId,
|
||||
principalTable: "Containers",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_LogEvents_Servers_ServerId",
|
||||
column: x => x.ServerId,
|
||||
principalTable: "Servers",
|
||||
principalColumn: "Id");
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Metrics",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
Timestamp = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
Type = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Value = table.Column<double>(type: "double", nullable: false),
|
||||
ServerId = table.Column<int>(type: "int", nullable: true),
|
||||
ContainerId = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Metrics", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Metrics_Containers_ContainerId",
|
||||
column: x => x.ContainerId,
|
||||
principalTable: "Containers",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_Metrics_Servers_ServerId",
|
||||
column: x => x.ServerId,
|
||||
principalTable: "Servers",
|
||||
principalColumn: "Id");
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Tags",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
Name = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Tags", x => x.Id);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Users",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
PocketId = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Role = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Users", x => x.Id);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Servers_TagId",
|
||||
table: "Servers",
|
||||
column: "TagId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Containers_ImageId",
|
||||
table: "Containers",
|
||||
column: "ImageId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Containers_TagId",
|
||||
table: "Containers",
|
||||
column: "TagId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_LogEvents_ContainerId",
|
||||
table: "LogEvents",
|
||||
column: "ContainerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_LogEvents_ServerId",
|
||||
table: "LogEvents",
|
||||
column: "ServerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Metrics_ContainerId",
|
||||
table: "Metrics",
|
||||
column: "ContainerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Metrics_ServerId",
|
||||
table: "Metrics",
|
||||
column: "ServerId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Containers_Images_ImageId",
|
||||
table: "Containers",
|
||||
column: "ImageId",
|
||||
principalTable: "Images",
|
||||
principalColumn: "Id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Containers_Tags_TagId",
|
||||
table: "Containers",
|
||||
column: "TagId",
|
||||
principalTable: "Tags",
|
||||
principalColumn: "Id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Servers_Tags_TagId",
|
||||
table: "Servers",
|
||||
column: "TagId",
|
||||
principalTable: "Tags",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Containers_Images_ImageId",
|
||||
table: "Containers");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Containers_Tags_TagId",
|
||||
table: "Containers");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Servers_Tags_TagId",
|
||||
table: "Servers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Images");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "LogEvents");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Metrics");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Tags");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Users");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Servers_TagId",
|
||||
table: "Servers");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Containers_ImageId",
|
||||
table: "Containers");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Containers_TagId",
|
||||
table: "Containers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "TagId",
|
||||
table: "Servers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ImageId",
|
||||
table: "Containers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "TagId",
|
||||
table: "Containers");
|
||||
}
|
||||
}
|
||||
}
|
@@ -32,6 +32,9 @@ namespace Watcher.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int?>("ImageId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
@@ -40,14 +43,225 @@ namespace Watcher.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int?>("TagId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ImageId");
|
||||
|
||||
b.HasIndex("TagId");
|
||||
|
||||
b.ToTable("Containers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Image", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Tag")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Images");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("ContainerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Level")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Message")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int?>("ServerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("Timestamp")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ContainerId");
|
||||
|
||||
b.HasIndex("ServerId");
|
||||
|
||||
b.ToTable("LogEvents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Metric", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("ContainerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("ServerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("Timestamp")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<double>("Value")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ContainerId");
|
||||
|
||||
b.HasIndex("ServerId");
|
||||
|
||||
b.ToTable("Metrics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Server", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Hostname")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int?>("TagId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("TagId");
|
||||
|
||||
b.ToTable("Servers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Tag", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Tags");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("PocketId")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Role")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Container", b =>
|
||||
{
|
||||
b.HasOne("Watcher.Models.Image", null)
|
||||
.WithMany("Containers")
|
||||
.HasForeignKey("ImageId");
|
||||
|
||||
b.HasOne("Watcher.Models.Tag", null)
|
||||
.WithMany("Containers")
|
||||
.HasForeignKey("TagId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
||||
{
|
||||
b.HasOne("Watcher.Models.Container", "Container")
|
||||
.WithMany()
|
||||
.HasForeignKey("ContainerId");
|
||||
|
||||
b.HasOne("Watcher.Models.Server", "Server")
|
||||
.WithMany()
|
||||
.HasForeignKey("ServerId");
|
||||
|
||||
b.Navigation("Container");
|
||||
|
||||
b.Navigation("Server");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Metric", b =>
|
||||
{
|
||||
b.HasOne("Watcher.Models.Container", "Container")
|
||||
.WithMany()
|
||||
.HasForeignKey("ContainerId");
|
||||
|
||||
b.HasOne("Watcher.Models.Server", "Server")
|
||||
.WithMany()
|
||||
.HasForeignKey("ServerId");
|
||||
|
||||
b.Navigation("Container");
|
||||
|
||||
b.Navigation("Server");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Server", b =>
|
||||
{
|
||||
b.HasOne("Watcher.Models.Tag", null)
|
||||
.WithMany("Servers")
|
||||
.HasForeignKey("TagId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Image", b =>
|
||||
{
|
||||
b.Navigation("Containers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Tag", b =>
|
||||
{
|
||||
b.Navigation("Containers");
|
||||
|
||||
b.Navigation("Servers");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
10
Watcher/Models/Image.cs
Normal file
10
Watcher/Models/Image.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Watcher.Models;
|
||||
|
||||
public class Image
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Name { get; set; } // z.B. "nginx", "myapp"
|
||||
public string? Tag { get; set; } // z.B. "latest", "v1.2.3"
|
||||
|
||||
public List<Container> Containers { get; set; } = new();
|
||||
}
|
15
Watcher/Models/LogEvent.cs
Normal file
15
Watcher/Models/LogEvent.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace Watcher.Models;
|
||||
|
||||
public class LogEvent
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public DateTime Timestamp { get; set; }
|
||||
public string? Message { get; set; }
|
||||
public string? Level { get; set; } // Info, Warning, Error
|
||||
|
||||
public int? ServerId { get; set; }
|
||||
public Server? Server { get; set; }
|
||||
|
||||
public int? ContainerId { get; set; }
|
||||
public Container? Container { get; set; }
|
||||
}
|
16
Watcher/Models/Metric.cs
Normal file
16
Watcher/Models/Metric.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace Watcher.Models;
|
||||
|
||||
public class Metric
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public DateTime Timestamp { get; set; }
|
||||
|
||||
public string? Type { get; set; } // z.B. "CPU", "RAM", "Disk", "Network"
|
||||
public double Value { get; set; }
|
||||
|
||||
public int? ServerId { get; set; }
|
||||
public Server? Server { get; set; }
|
||||
|
||||
public int? ContainerId { get; set; }
|
||||
public Container? Container { get; set; }
|
||||
}
|
10
Watcher/Models/Tag.cs
Normal file
10
Watcher/Models/Tag.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Watcher.Models;
|
||||
|
||||
public class Tag
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
|
||||
public List<Server>? Servers { get; set; }
|
||||
public List<Container>? Containers { get; set; }
|
||||
}
|
8
Watcher/Models/User.cs
Normal file
8
Watcher/Models/User.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Watcher.Models;
|
||||
|
||||
public class User
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? PocketId { get; set; } // z.B. externe ID vom PocketID-Login
|
||||
public string Role { get; set; } = "User"; // "Admin", "Viewer", etc.
|
||||
}
|
Reference in New Issue
Block a user