using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace TakeoutSaaS.Infrastructure.Migrations.IdentityDb { /// public partial class AddIdentityOutbox : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "OutboxMessage", columns: table => new { SequenceNumber = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), EnqueueTime = table.Column(type: "timestamp with time zone", nullable: true), SentTime = table.Column(type: "timestamp with time zone", nullable: false), Headers = table.Column(type: "text", nullable: true), Properties = table.Column(type: "text", nullable: true), InboxMessageId = table.Column(type: "uuid", nullable: true), InboxConsumerId = table.Column(type: "uuid", nullable: true), OutboxId = table.Column(type: "uuid", nullable: true), MessageId = table.Column(type: "uuid", nullable: false), ContentType = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), MessageType = table.Column(type: "text", nullable: false), Body = table.Column(type: "text", nullable: false), ConversationId = table.Column(type: "uuid", nullable: true), CorrelationId = table.Column(type: "uuid", nullable: true), InitiatorId = table.Column(type: "uuid", nullable: true), RequestId = table.Column(type: "uuid", nullable: true), SourceAddress = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), DestinationAddress = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), ResponseAddress = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), FaultAddress = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), ExpirationTime = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("PK_OutboxMessage", x => x.SequenceNumber); }); migrationBuilder.CreateTable( name: "OutboxState", columns: table => new { OutboxId = table.Column(type: "uuid", nullable: false), LockId = table.Column(type: "uuid", nullable: false), RowVersion = table.Column(type: "bytea", rowVersion: true, nullable: true), Created = table.Column(type: "timestamp with time zone", nullable: false), Delivered = table.Column(type: "timestamp with time zone", nullable: true), LastSequenceNumber = table.Column(type: "bigint", nullable: true) }, constraints: table => { table.PrimaryKey("PK_OutboxState", x => x.OutboxId); }); migrationBuilder.CreateIndex( name: "IX_OutboxMessage_EnqueueTime", table: "OutboxMessage", column: "EnqueueTime"); migrationBuilder.CreateIndex( name: "IX_OutboxMessage_ExpirationTime", table: "OutboxMessage", column: "ExpirationTime"); migrationBuilder.CreateIndex( name: "IX_OutboxMessage_InboxMessageId_InboxConsumerId_SequenceNumber", table: "OutboxMessage", columns: new[] { "InboxMessageId", "InboxConsumerId", "SequenceNumber" }, unique: true); migrationBuilder.CreateIndex( name: "IX_OutboxMessage_OutboxId_SequenceNumber", table: "OutboxMessage", columns: new[] { "OutboxId", "SequenceNumber" }, unique: true); migrationBuilder.CreateIndex( name: "IX_OutboxState_Created", table: "OutboxState", column: "Created"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "OutboxMessage"); migrationBuilder.DropTable( name: "OutboxState"); } } }