78 lines
4.1 KiB
C#
78 lines
4.1 KiB
C#
![]() |
using System;
|
|||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
|
|||
|
#nullable disable
|
|||
|
|
|||
|
namespace VOL.Core.Migrations
|
|||
|
{
|
|||
|
public partial class _20250313v1 : Migration
|
|||
|
{
|
|||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Y_Stadium",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "int", nullable: false, comment: "Id")
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
StadiumCode = table.Column<string>(type: "nvarchar(100)", nullable: true, comment: "场馆编号"),
|
|||
|
StadiumName = table.Column<string>(type: "nvarchar(100)", nullable: true, comment: "场馆名称"),
|
|||
|
Province = table.Column<string>(type: "nvarchar(20)", nullable: true, comment: "所属省份"),
|
|||
|
City = table.Column<string>(type: "nvarchar(20)", nullable: true, comment: "所属城市"),
|
|||
|
Area = table.Column<string>(type: "nvarchar(20)", nullable: true, comment: "所属区域"),
|
|||
|
Address = table.Column<string>(type: "nvarchar(2000)", nullable: true, comment: "地址"),
|
|||
|
PhoneNo = table.Column<string>(type: "nvarchar(2000)", nullable: true, comment: "联系电话"),
|
|||
|
Latitude = table.Column<double>(type: "float", nullable: false, comment: "纬度"),
|
|||
|
Longitude = table.Column<double>(type: "float", nullable: false, comment: "经度"),
|
|||
|
Intro = table.Column<string>(type: "text", nullable: true, comment: "介绍"),
|
|||
|
CoverImage = table.Column<string>(type: "nvarchar(2000)", nullable: true, comment: "封面图"),
|
|||
|
Remarks = table.Column<string>(type: "text", nullable: true, comment: "备注"),
|
|||
|
Creator = table.Column<int>(type: "int", nullable: false, comment: "创建人"), // 修正了 `type` 语法错误
|
|||
|
CreateDate = table.Column<DateTime>(type: "datetime", nullable: false, comment: "创建时间"),
|
|||
|
Modifier = table.Column<int>(type: "int", nullable: false, comment: "修改人"), // 修正了 `type` 语法错误
|
|||
|
ModifyDate = table.Column<DateTime>(type: "datetime", nullable: true, comment: "修改时间")
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Y_Stadium", x => x.Id);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Y_StadiumResource",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "int", nullable: false, comment: "Id")
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
StadiumId = table.Column<int>(type: "int", nullable: false, comment: "场馆Id"), // 确保 StadiumId 不为空
|
|||
|
Type = table.Column<int>(type: "int", nullable: false, comment: "资源类型[1:图片/2:视频]"),
|
|||
|
Url = table.Column<string>(type: "nvarchar(2000)", nullable: true, comment: "资源地址")
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Y_StadiumResource", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Y_StadiumResource_Y_Stadium_StadiumId",
|
|||
|
column: x => x.StadiumId,
|
|||
|
principalTable: "Y_Stadium",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade); // 设定级联删除
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Y_StadiumResource_StadiumId",
|
|||
|
table: "Y_StadiumResource",
|
|||
|
column: "StadiumId");
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Y_StadiumResource");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Y_Stadium");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|