using System; using System.Text.Json; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Tiku.Infrastructure.Persistence.Migrations { /// public partial class AddPaymentSdkAndTenantSecretFoundation : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "tenant_secrets", columns: table => new { id = table.Column(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"), purpose = table.Column(type: "character varying(80)", maxLength: 80, nullable: false), provider = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), secret_key = table.Column(type: "character varying(120)", maxLength: 120, nullable: false), secret_ref = table.Column(type: "character varying(300)", maxLength: 300, nullable: false), status = table.Column(type: "character varying(32)", maxLength: 32, nullable: false), secret_payload = table.Column(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb"), rotated_at = table.Column(type: "timestamp with time zone", nullable: true), expires_at = table.Column(type: "timestamp with time zone", nullable: true), tenant_id = table.Column(type: "uuid", nullable: false), created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"), updated_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()") }, constraints: table => { table.PrimaryKey("pk_tenant_secrets", x => x.id); table.UniqueConstraint("ak_tenant_secrets_tenant_id_id", x => new { x.tenant_id, x.id }); table.ForeignKey( name: "fk_tenant_secrets_tenants_tenant_id", column: x => x.tenant_id, principalTable: "tenants", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "ix_tenant_secrets_tenant_id_purpose_provider_secret_key", table: "tenant_secrets", columns: new[] { "tenant_id", "purpose", "provider", "secret_key" }, unique: true); migrationBuilder.CreateIndex( name: "ix_tenant_secrets_tenant_id_purpose_provider_status", table: "tenant_secrets", columns: new[] { "tenant_id", "purpose", "provider", "status" }); migrationBuilder.CreateIndex( name: "ix_tenant_secrets_tenant_id_secret_ref", table: "tenant_secrets", columns: new[] { "tenant_id", "secret_ref" }, unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "tenant_secrets"); } } }