66 lines
2.6 KiB
C#
66 lines
2.6 KiB
C#
using System;
|
|
using MemberCenter.Infrastructure.Persistence;
|
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace MemberCenter.Infrastructure.Persistence.Migrations
|
|
{
|
|
[DbContext(typeof(MemberCenterDbContext))]
|
|
[Migration("20260710110000_AddTenantManagers")]
|
|
public partial class AddTenantManagers : Migration
|
|
{
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "tenant_managers",
|
|
columns: table => new
|
|
{
|
|
TenantId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
UserId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CreatedBy = table.Column<Guid>(type: "uuid", nullable: true),
|
|
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_tenant_managers", x => new { x.TenantId, x.UserId });
|
|
table.ForeignKey(
|
|
name: "FK_tenant_managers_tenants_TenantId",
|
|
column: x => x.TenantId,
|
|
principalTable: "tenants",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_tenant_managers_users_CreatedBy",
|
|
column: x => x.CreatedBy,
|
|
principalTable: "users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
table.ForeignKey(
|
|
name: "FK_tenant_managers_users_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_tenant_managers_CreatedBy",
|
|
table: "tenant_managers",
|
|
column: "CreatedBy");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "idx_tenant_managers_user_id",
|
|
table: "tenant_managers",
|
|
column: "UserId");
|
|
}
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "tenant_managers");
|
|
}
|
|
}
|
|
}
|