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.Postgres
{
/// <inheritdoc />
public partial class AddCustomerGitPoliciesAndCredentials : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "CustomerGitCredentialId",
table: "VaultSecrets",
type: "uuid",
nullable: true);
migrationBuilder.CreateTable(
name: "CustomerGitCredentials",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
CustomerId = table.Column<Guid>(type: "uuid", nullable: false),
TenantId = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
AuthType = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
Username = table.Column<string>(type: "character varying(300)", maxLength: 300, nullable: true),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", 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: "uuid", nullable: false),
CustomerId = table.Column<Guid>(type: "uuid", nullable: false),
UrlPattern = table.Column<string>(type: "character varying(2000)", maxLength: 2000, nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", 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.Postgres
{
/// <inheritdoc />
public partial class AddCustomerGitCredentialToGitRepository : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "CustomerGitCredentialId",
table: "GitRepositories",
type: "uuid",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_GitRepositories_CustomerGitCredentialId",
table: "GitRepositories",
column: "CustomerGitCredentialId");
migrationBuilder.AddForeignKey(
name: "FK_GitRepositories_CustomerGitCredentials_CustomerGitCredentia~",
table: "GitRepositories",
column: "CustomerGitCredentialId",
principalTable: "CustomerGitCredentials",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_GitRepositories_CustomerGitCredentials_CustomerGitCredentia~",
table: "GitRepositories");
migrationBuilder.DropIndex(
name: "IX_GitRepositories_CustomerGitCredentialId",
table: "GitRepositories");
migrationBuilder.DropColumn(
name: "CustomerGitCredentialId",
table: "GitRepositories");
}
}
}

View File

@@ -782,6 +782,70 @@ namespace EntKube.Web.Data.Migrations.Postgres
b.ToTable("CustomerAccesses");
});
modelBuilder.Entity("EntKube.Web.Data.CustomerGitCredential", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("AuthType")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("CustomerId")
.HasColumnType("uuid");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<Guid>("TenantId")
.HasColumnType("uuid");
b.Property<string>("Username")
.HasMaxLength(300)
.HasColumnType("character varying(300)");
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("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("CustomerId")
.HasColumnType("uuid");
b.Property<string>("UrlPattern")
.IsRequired()
.HasMaxLength(2000)
.HasColumnType("character varying(2000)");
b.HasKey("Id");
b.HasIndex("CustomerId", "UrlPattern")
.IsUnique();
b.ToTable("CustomerGitRepoPolicies");
});
modelBuilder.Entity("EntKube.Web.Data.DatabaseBinding", b =>
{
b.Property<Guid>("Id")
@@ -1213,6 +1277,9 @@ namespace EntKube.Web.Data.Migrations.Postgres
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid?>("CustomerGitCredentialId")
.HasColumnType("uuid");
b.Property<string>("DefaultBranch")
.IsRequired()
.ValueGeneratedOnAdd()
@@ -1239,6 +1306,8 @@ namespace EntKube.Web.Data.Migrations.Postgres
b.HasKey("Id");
b.HasIndex("CustomerGitCredentialId");
b.HasIndex("TenantId", "Name")
.IsUnique();
@@ -2550,6 +2619,9 @@ namespace EntKube.Web.Data.Migrations.Postgres
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid?>("CustomerGitCredentialId")
.HasColumnType("uuid");
b.Property<byte[]>("EncryptedValue")
.IsRequired()
.HasColumnType("bytea");
@@ -2620,6 +2692,8 @@ namespace EntKube.Web.Data.Migrations.Postgres
b.HasIndex("ComponentId");
b.HasIndex("CustomerGitCredentialId");
b.HasIndex("GitRepositoryId");
b.HasIndex("KubernetesClusterId");
@@ -3192,6 +3266,36 @@ namespace EntKube.Web.Data.Migrations.Postgres
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")
@@ -3339,12 +3443,19 @@ namespace EntKube.Web.Data.Migrations.Postgres
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");
});
@@ -3943,6 +4054,11 @@ namespace EntKube.Web.Data.Migrations.Postgres
.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")
@@ -4001,6 +4117,8 @@ namespace EntKube.Web.Data.Migrations.Postgres
b.Navigation("Component");
b.Navigation("CustomerGitCredential");
b.Navigation("GitRepository");
b.Navigation("KubernetesCluster");
@@ -4187,6 +4305,10 @@ namespace EntKube.Web.Data.Migrations.Postgres
modelBuilder.Entity("EntKube.Web.Data.Customer", b =>
{
b.Navigation("Apps");
b.Navigation("GitCredentials");
b.Navigation("GitRepoPolicies");
});
modelBuilder.Entity("EntKube.Web.Data.DeploymentResource", b =>

View File

@@ -0,0 +1,122 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntKube.Web.Data.Migrations.SqlServer
{
/// <inheritdoc />
public partial class AddCustomerGitPoliciesAndCredentials : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "CustomerGitCredentialId",
table: "VaultSecrets",
type: "uniqueidentifier",
nullable: true);
migrationBuilder.CreateTable(
name: "CustomerGitCredentials",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
CustomerId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
AuthType = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
Username = table.Column<string>(type: "nvarchar(300)", maxLength: 300, nullable: true),
CreatedAt = table.Column<DateTime>(type: "datetime2", 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: "uniqueidentifier", nullable: false),
CustomerId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UrlPattern = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: false),
CreatedAt = table.Column<DateTime>(type: "datetime2", 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.SqlServer
{
/// <inheritdoc />
public partial class AddCustomerGitCredentialToGitRepository : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "CustomerGitCredentialId",
table: "GitRepositories",
type: "uniqueidentifier",
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

@@ -783,6 +783,70 @@ namespace EntKube.Web.Data.Migrations.SqlServer
b.ToTable("CustomerAccesses");
});
modelBuilder.Entity("EntKube.Web.Data.CustomerGitCredential", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("AuthType")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("nvarchar(20)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<Guid>("CustomerId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<Guid>("TenantId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Username")
.HasMaxLength(300)
.HasColumnType("nvarchar(300)");
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("uniqueidentifier");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<Guid>("CustomerId")
.HasColumnType("uniqueidentifier");
b.Property<string>("UrlPattern")
.IsRequired()
.HasMaxLength(2000)
.HasColumnType("nvarchar(2000)");
b.HasKey("Id");
b.HasIndex("CustomerId", "UrlPattern")
.IsUnique();
b.ToTable("CustomerGitRepoPolicies");
});
modelBuilder.Entity("EntKube.Web.Data.DatabaseBinding", b =>
{
b.Property<Guid>("Id")
@@ -1214,6 +1278,9 @@ namespace EntKube.Web.Data.Migrations.SqlServer
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<Guid?>("CustomerGitCredentialId")
.HasColumnType("uniqueidentifier");
b.Property<string>("DefaultBranch")
.IsRequired()
.ValueGeneratedOnAdd()
@@ -1240,6 +1307,8 @@ namespace EntKube.Web.Data.Migrations.SqlServer
b.HasKey("Id");
b.HasIndex("CustomerGitCredentialId");
b.HasIndex("TenantId", "Name")
.IsUnique();
@@ -2551,6 +2620,9 @@ namespace EntKube.Web.Data.Migrations.SqlServer
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<Guid?>("CustomerGitCredentialId")
.HasColumnType("uniqueidentifier");
b.Property<byte[]>("EncryptedValue")
.IsRequired()
.HasColumnType("varbinary(max)");
@@ -2621,6 +2693,8 @@ namespace EntKube.Web.Data.Migrations.SqlServer
b.HasIndex("ComponentId");
b.HasIndex("CustomerGitCredentialId");
b.HasIndex("GitRepositoryId");
b.HasIndex("KubernetesClusterId");
@@ -3194,6 +3268,36 @@ namespace EntKube.Web.Data.Migrations.SqlServer
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")
@@ -3341,12 +3445,19 @@ namespace EntKube.Web.Data.Migrations.SqlServer
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");
});
@@ -3945,6 +4056,11 @@ namespace EntKube.Web.Data.Migrations.SqlServer
.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")
@@ -4003,6 +4119,8 @@ namespace EntKube.Web.Data.Migrations.SqlServer
b.Navigation("Component");
b.Navigation("CustomerGitCredential");
b.Navigation("GitRepository");
b.Navigation("KubernetesCluster");
@@ -4189,6 +4307,10 @@ namespace EntKube.Web.Data.Migrations.SqlServer
modelBuilder.Entity("EntKube.Web.Data.Customer", b =>
{
b.Navigation("Apps");
b.Navigation("GitCredentials");
b.Navigation("GitRepoPolicies");
});
modelBuilder.Entity("EntKube.Web.Data.DeploymentResource", b =>

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 =>