database and gitsync issues fixed

This commit is contained in:
Nils Blomgren
2026-06-07 14:54:16 +02:00
parent 8dc46ef031
commit 76b7e55931
72 changed files with 31067 additions and 1508 deletions

View File

@@ -0,0 +1,122 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntKube.Web.Data.Migrations.Sqlite
{
/// <inheritdoc />
public partial class AddCustomerGitPoliciesAndCredentials : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "CustomerGitCredentialId",
table: "VaultSecrets",
type: "TEXT",
nullable: true);
migrationBuilder.CreateTable(
name: "CustomerGitCredentials",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
CustomerId = table.Column<Guid>(type: "TEXT", nullable: false),
TenantId = table.Column<Guid>(type: "TEXT", nullable: false),
Name = table.Column<string>(type: "TEXT", maxLength: 200, nullable: false),
AuthType = table.Column<string>(type: "TEXT", maxLength: 20, nullable: false),
Username = table.Column<string>(type: "TEXT", maxLength: 300, nullable: true),
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CustomerGitCredentials", x => x.Id);
table.ForeignKey(
name: "FK_CustomerGitCredentials_Customers_CustomerId",
column: x => x.CustomerId,
principalTable: "Customers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_CustomerGitCredentials_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "CustomerGitRepoPolicies",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
CustomerId = table.Column<Guid>(type: "TEXT", nullable: false),
UrlPattern = table.Column<string>(type: "TEXT", maxLength: 2000, nullable: false),
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CustomerGitRepoPolicies", x => x.Id);
table.ForeignKey(
name: "FK_CustomerGitRepoPolicies_Customers_CustomerId",
column: x => x.CustomerId,
principalTable: "Customers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_VaultSecrets_CustomerGitCredentialId",
table: "VaultSecrets",
column: "CustomerGitCredentialId");
migrationBuilder.CreateIndex(
name: "IX_CustomerGitCredentials_CustomerId_Name",
table: "CustomerGitCredentials",
columns: new[] { "CustomerId", "Name" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_CustomerGitCredentials_TenantId",
table: "CustomerGitCredentials",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_CustomerGitRepoPolicies_CustomerId_UrlPattern",
table: "CustomerGitRepoPolicies",
columns: new[] { "CustomerId", "UrlPattern" },
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_VaultSecrets_CustomerGitCredentials_CustomerGitCredentialId",
table: "VaultSecrets",
column: "CustomerGitCredentialId",
principalTable: "CustomerGitCredentials",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_VaultSecrets_CustomerGitCredentials_CustomerGitCredentialId",
table: "VaultSecrets");
migrationBuilder.DropTable(
name: "CustomerGitCredentials");
migrationBuilder.DropTable(
name: "CustomerGitRepoPolicies");
migrationBuilder.DropIndex(
name: "IX_VaultSecrets_CustomerGitCredentialId",
table: "VaultSecrets");
migrationBuilder.DropColumn(
name: "CustomerGitCredentialId",
table: "VaultSecrets");
}
}
}

View File

@@ -0,0 +1,50 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntKube.Web.Data.Migrations.Sqlite
{
/// <inheritdoc />
public partial class AddCustomerGitCredentialToGitRepository : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "CustomerGitCredentialId",
table: "GitRepositories",
type: "TEXT",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_GitRepositories_CustomerGitCredentialId",
table: "GitRepositories",
column: "CustomerGitCredentialId");
migrationBuilder.AddForeignKey(
name: "FK_GitRepositories_CustomerGitCredentials_CustomerGitCredentialId",
table: "GitRepositories",
column: "CustomerGitCredentialId",
principalTable: "CustomerGitCredentials",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_GitRepositories_CustomerGitCredentials_CustomerGitCredentialId",
table: "GitRepositories");
migrationBuilder.DropIndex(
name: "IX_GitRepositories_CustomerGitCredentialId",
table: "GitRepositories");
migrationBuilder.DropColumn(
name: "CustomerGitCredentialId",
table: "GitRepositories");
}
}
}

View File

@@ -777,6 +777,70 @@ namespace EntKube.Web.Data.Migrations.Sqlite
b.ToTable("CustomerAccesses");
});
modelBuilder.Entity("EntKube.Web.Data.CustomerGitCredential", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("AuthType")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedAt")
.HasColumnType("TEXT");
b.Property<Guid>("CustomerId")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("TEXT");
b.Property<Guid>("TenantId")
.HasColumnType("TEXT");
b.Property<string>("Username")
.HasMaxLength(300)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("TenantId");
b.HasIndex("CustomerId", "Name")
.IsUnique();
b.ToTable("CustomerGitCredentials");
});
modelBuilder.Entity("EntKube.Web.Data.CustomerGitRepoPolicy", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedAt")
.HasColumnType("TEXT");
b.Property<Guid>("CustomerId")
.HasColumnType("TEXT");
b.Property<string>("UrlPattern")
.IsRequired()
.HasMaxLength(2000)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("CustomerId", "UrlPattern")
.IsUnique();
b.ToTable("CustomerGitRepoPolicies");
});
modelBuilder.Entity("EntKube.Web.Data.DatabaseBinding", b =>
{
b.Property<Guid>("Id")
@@ -1208,6 +1272,9 @@ namespace EntKube.Web.Data.Migrations.Sqlite
b.Property<DateTime>("CreatedAt")
.HasColumnType("TEXT");
b.Property<Guid?>("CustomerGitCredentialId")
.HasColumnType("TEXT");
b.Property<string>("DefaultBranch")
.IsRequired()
.ValueGeneratedOnAdd()
@@ -1234,6 +1301,8 @@ namespace EntKube.Web.Data.Migrations.Sqlite
b.HasKey("Id");
b.HasIndex("CustomerGitCredentialId");
b.HasIndex("TenantId", "Name")
.IsUnique();
@@ -2545,6 +2614,9 @@ namespace EntKube.Web.Data.Migrations.Sqlite
b.Property<DateTime>("CreatedAt")
.HasColumnType("TEXT");
b.Property<Guid?>("CustomerGitCredentialId")
.HasColumnType("TEXT");
b.Property<byte[]>("EncryptedValue")
.IsRequired()
.HasColumnType("BLOB");
@@ -2615,6 +2687,8 @@ namespace EntKube.Web.Data.Migrations.Sqlite
b.HasIndex("ComponentId");
b.HasIndex("CustomerGitCredentialId");
b.HasIndex("GitRepositoryId");
b.HasIndex("KubernetesClusterId");
@@ -3183,6 +3257,36 @@ namespace EntKube.Web.Data.Migrations.Sqlite
b.Navigation("User");
});
modelBuilder.Entity("EntKube.Web.Data.CustomerGitCredential", b =>
{
b.HasOne("EntKube.Web.Data.Customer", "Customer")
.WithMany("GitCredentials")
.HasForeignKey("CustomerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EntKube.Web.Data.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Customer");
b.Navigation("Tenant");
});
modelBuilder.Entity("EntKube.Web.Data.CustomerGitRepoPolicy", b =>
{
b.HasOne("EntKube.Web.Data.Customer", "Customer")
.WithMany("GitRepoPolicies")
.HasForeignKey("CustomerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Customer");
});
modelBuilder.Entity("EntKube.Web.Data.DatabaseBinding", b =>
{
b.HasOne("EntKube.Web.Data.AppDeployment", "AppDeployment")
@@ -3330,12 +3434,19 @@ namespace EntKube.Web.Data.Migrations.Sqlite
modelBuilder.Entity("EntKube.Web.Data.GitRepository", b =>
{
b.HasOne("EntKube.Web.Data.CustomerGitCredential", "CustomerGitCredential")
.WithMany()
.HasForeignKey("CustomerGitCredentialId")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("EntKube.Web.Data.Tenant", "Tenant")
.WithMany("GitRepositories")
.HasForeignKey("TenantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CustomerGitCredential");
b.Navigation("Tenant");
});
@@ -3934,6 +4045,11 @@ namespace EntKube.Web.Data.Migrations.Sqlite
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("EntKube.Web.Data.CustomerGitCredential", "CustomerGitCredential")
.WithMany()
.HasForeignKey("CustomerGitCredentialId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("EntKube.Web.Data.GitRepository", "GitRepository")
.WithMany()
.HasForeignKey("GitRepositoryId")
@@ -3992,6 +4108,8 @@ namespace EntKube.Web.Data.Migrations.Sqlite
b.Navigation("Component");
b.Navigation("CustomerGitCredential");
b.Navigation("GitRepository");
b.Navigation("KubernetesCluster");
@@ -4178,6 +4296,10 @@ namespace EntKube.Web.Data.Migrations.Sqlite
modelBuilder.Entity("EntKube.Web.Data.Customer", b =>
{
b.Navigation("Apps");
b.Navigation("GitCredentials");
b.Navigation("GitRepoPolicies");
});
modelBuilder.Entity("EntKube.Web.Data.DeploymentResource", b =>