CSharp-Single-EFCore/Bunny.Common/Migrations/20240902054644_InitialCreat...

120 lines
5.6 KiB
C#
Raw Normal View History

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bunny.Common.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Blog",
columns: table => new
{
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
BlogUrl = table.Column<string>(type: "varchar(600)", nullable: false),
CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreateUserId = table.Column<long>(type: "bigint", nullable: false),
UpdateUserId = table.Column<long>(type: "bigint", nullable: false),
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Blog", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Products",
columns: table => new
{
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
CustomerId = table.Column<string>(type: "nvarchar(max)", nullable: true),
CustomerName = table.Column<string>(type: "nvarchar(max)", nullable: true),
PackageType = table.Column<string>(type: "nvarchar(max)", nullable: true),
CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreateUserId = table.Column<long>(type: "bigint", nullable: false),
UpdateUserId = table.Column<long>(type: "bigint", nullable: false),
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Products", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
UserName = table.Column<string>(type: "nvarchar(max)", nullable: true),
Password = table.Column<string>(type: "nvarchar(max)", nullable: true),
Email = table.Column<string>(type: "nvarchar(max)", nullable: true),
Phone = table.Column<string>(type: "nvarchar(max)", nullable: true),
QrCode = table.Column<string>(type: "nvarchar(max)", nullable: true),
CompanyCode = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeptCode = table.Column<string>(type: "nvarchar(max)", nullable: true),
CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreateUserId = table.Column<long>(type: "bigint", nullable: false),
UpdateUserId = table.Column<long>(type: "bigint", nullable: false),
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Posts",
columns: table => new
{
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
Title = table.Column<string>(type: "nvarchar(600)", maxLength: 600, nullable: true),
Content = table.Column<string>(type: "nvarchar(max)", nullable: true),
BlogId = table.Column<string>(type: "nvarchar(450)", nullable: true),
CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreateUserId = table.Column<long>(type: "bigint", nullable: false),
UpdateUserId = table.Column<long>(type: "bigint", nullable: false),
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Posts", x => x.Id);
table.ForeignKey(
name: "FK_Posts_Blog_BlogId",
column: x => x.BlogId,
principalTable: "Blog",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_Posts_BlogId",
table: "Posts",
column: "BlogId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Posts");
migrationBuilder.DropTable(
name: "Products");
migrationBuilder.DropTable(
name: "Users");
migrationBuilder.DropTable(
name: "Blog");
}
}
}