Files
mtusi2026lab5-fork/scr/Messenger.Api/Data/Migrations/20261113163634_AddAttachments.cs
T

72 lines
3.0 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Messenger.Api.Data.Migrations
{
/// <inheritdoc />
public partial class AddAttachments : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "attachments",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
chat_id = table.Column<Guid>(type: "uuid", nullable: false),
owner_id = table.Column<Guid>(type: "uuid", nullable: false),
filename = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
object_key = table.Column<string>(type: "text", nullable: false),
content_type = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
size_bytes = table.Column<long>(type: "bigint", nullable: false),
checksum_sha256 = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
status = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
uploaded_at = table.Column<DateTimeOffset>(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");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "attachments");
}
}
}