using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Messenger.Api.Data.Migrations { /// public partial class AddAttachments : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "attachments", columns: table => new { id = table.Column(type: "uuid", nullable: false), chat_id = table.Column(type: "uuid", nullable: false), owner_id = table.Column(type: "uuid", nullable: false), filename = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), object_key = table.Column(type: "text", nullable: false), content_type = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), size_bytes = table.Column(type: "bigint", nullable: false), checksum_sha256 = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), created_at = table.Column(type: "timestamp with time zone", nullable: false), uploaded_at = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("pk_attachments", x => x.id); table.ForeignKey( name: "fk_attachments_chats_chat_id", column: x => x.chat_id, principalTable: "chats", principalColumn: "id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "fk_attachments_users_owner_id", column: x => x.owner_id, principalTable: "users", principalColumn: "id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "ix_attachments_chat_id", table: "attachments", column: "chat_id"); migrationBuilder.CreateIndex( name: "ix_attachments_object_key", table: "attachments", column: "object_key", unique: true); migrationBuilder.CreateIndex( name: "ix_attachments_owner_id", table: "attachments", column: "owner_id"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "attachments"); } } }