Swarm/DysonNetwork.Sphere/Migrations/20250506164731_AddChatRealtimeCall.cs
2025-05-07 00:47:57 +08:00

97 lines
3.7 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
using NodaTime;
#nullable disable
namespace DysonNetwork.Sphere.Migrations
{
/// <inheritdoc />
public partial class AddChatRealtimeCall : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "content",
table: "chat_messages",
type: "character varying(4096)",
maxLength: 4096,
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(4096)",
oldMaxLength: 4096);
migrationBuilder.AddColumn<string>(
name: "type",
table: "chat_messages",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.CreateTable(
name: "chat_realtime_call",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
title = table.Column<string>(type: "text", nullable: true),
ended_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
sender_id = table.Column<Guid>(type: "uuid", nullable: false),
room_id = table.Column<long>(type: "bigint", nullable: false),
created_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
updated_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
deleted_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_chat_realtime_call", x => x.id);
table.ForeignKey(
name: "fk_chat_realtime_call_chat_members_sender_id",
column: x => x.sender_id,
principalTable: "chat_members",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_chat_realtime_call_chat_rooms_room_id",
column: x => x.room_id,
principalTable: "chat_rooms",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "ix_chat_realtime_call_room_id",
table: "chat_realtime_call",
column: "room_id");
migrationBuilder.CreateIndex(
name: "ix_chat_realtime_call_sender_id",
table: "chat_realtime_call",
column: "sender_id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "chat_realtime_call");
migrationBuilder.DropColumn(
name: "type",
table: "chat_messages");
migrationBuilder.AlterColumn<string>(
name: "content",
table: "chat_messages",
type: "character varying(4096)",
maxLength: 4096,
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "character varying(4096)",
oldMaxLength: 4096,
oldNullable: true);
}
}
}