using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace bitforum.Migrations.DefaultDb
{
///
public partial class AddMember : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn(
name: "Image",
table: "BannerItem",
type: "nvarchar(1024)",
maxLength: 1024,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(1024)",
oldMaxLength: 1024);
migrationBuilder.CreateTable(
name: "MemberApprove",
columns: table => new
{
ID = table.Column(type: "int", nullable: false, comment: "회원 ID")
.Annotation("SqlServer:Identity", "1, 1"),
IsReceiveSMS = table.Column(type: "bit", nullable: false, comment: "SMS 수신 여부"),
IsReceiveEmail = table.Column(type: "bit", nullable: false, comment: "E-MAIL 수신 여부"),
IsReceiveNote = table.Column(type: "bit", nullable: false, comment: "쪽지 수신 여부"),
IsDisclosureInvest = table.Column(type: "bit", nullable: false, comment: "투자 현황 공개 여부")
},
constraints: table =>
{
table.PrimaryKey("PK_MemberApprove", x => x.ID);
},
comment: "회원 동의 및 수신 여부");
migrationBuilder.CreateTable(
name: "MemberGrade",
columns: table => new
{
ID = table.Column(type: "int", nullable: false, comment: "PK")
.Annotation("SqlServer:Identity", "1, 1"),
KorName = table.Column(type: "nvarchar(120)", maxLength: 120, nullable: false, comment: "한글 명"),
EngName = table.Column(type: "nvarchar(120)", maxLength: 120, nullable: false, comment: "영문 명"),
Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true, comment: "설명"),
Order = table.Column(type: "smallint", nullable: false, comment: "순서"),
Image = table.Column(type: "nvarchar(max)", nullable: true, comment: "이미지"),
RequiredExp = table.Column(type: "int", nullable: false, comment: "최소 경험치(Exp)"),
RequiredCoin = table.Column(type: "int", nullable: false, comment: "최소 코인(Coin)"),
IsActive = table.Column(type: "bit", nullable: false, comment: "사용 여부"),
UpdatedAt = table.Column(type: "datetime2", nullable: true, comment: "수정 일시"),
CreatedAt = table.Column(type: "datetime2", nullable: false, comment: "등록 일시")
},
constraints: table =>
{
table.PrimaryKey("PK_MemberGrade", x => x.ID);
},
comment: "회원 등급");
migrationBuilder.CreateTable(
name: "Member",
columns: table => new
{
ID = table.Column(type: "int", nullable: false, comment: "PK"),
GradeID = table.Column(type: "int", nullable: true, comment: "회원등급 ID"),
SID = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: false, comment: "SID"),
Email = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false, comment: "이메일"),
Name = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true, comment: "별명"),
FullName = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true, comment: "본명"),
FirstName = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true, comment: "본명(성)"),
LastName = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true, comment: "본명(이름)"),
Password = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false, comment: "비밀번호"),
Intro = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true, comment: "자기소개"),
Summary = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true, comment: "한마디"),
Coin = table.Column(type: "bigint", nullable: false, comment: "코인"),
Exp = table.Column(type: "int", nullable: false, comment: "경험치"),
Phone = table.Column(type: "nvarchar(15)", maxLength: 15, nullable: true, comment: "연락처"),
Birthday = table.Column(type: "date", maxLength: 10, nullable: true, comment: "생년월일"),
Gender = table.Column(type: "int", maxLength: 6, nullable: true, comment: "성별"),
Photo = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true, comment: "사진"),
IsEmailVerified = table.Column(type: "bit", nullable: false, comment: "이메일 인증 여부"),
IsAuthCertified = table.Column(type: "bit", nullable: false, comment: "본인 인증 여부"),
IsDenied = table.Column(type: "bit", nullable: false, comment: "차단 여부"),
IsAdmin = table.Column(type: "bit", nullable: false, comment: "운영진 여부"),
IsWithdraw = table.Column(type: "bit", nullable: false, comment: "탈퇴 여부"),
Following = table.Column(type: "int", nullable: false, comment: "구독 중"),
Followed = table.Column(type: "int", nullable: false, comment: "구독자"),
DeviceInfo = table.Column(type: "nvarchar(400)", maxLength: 400, nullable: true, comment: "로그인 단말기 정보"),
SignupIP = table.Column(type: "nvarchar(15)", maxLength: 15, nullable: false, comment: "회원가입 시 IP"),
LastLoginIp = table.Column(type: "nvarchar(15)", maxLength: 15, nullable: true, comment: "마지막 로그인 IP"),
LastLoginAt = table.Column(type: "datetime2", nullable: true, comment: "마지막 로그인 일시"),
EmailVerifiedAt = table.Column(type: "datetime2", nullable: true, comment: "이메일 인증 일시"),
AuthCertifiedAt = table.Column(type: "datetime2", nullable: true, comment: "본인인증 일시"),
PasswordUpdatedAt = table.Column(type: "datetime2", nullable: false, comment: "비밀번호 변경 일시"),
CreatedAt = table.Column(type: "datetime2", nullable: false, comment: "가입 일시"),
UpdatedAt = table.Column(type: "datetime2", nullable: true, comment: "수정 일시"),
DeletedAt = table.Column(type: "datetime2", nullable: true, comment: "탈퇴 일시")
},
constraints: table =>
{
table.PrimaryKey("PK_Member", x => x.ID);
table.ForeignKey(
name: "FK_Member_MemberApprove_ID",
column: x => x.ID,
principalTable: "MemberApprove",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Member_MemberGrade_GradeID",
column: x => x.GradeID,
principalTable: "MemberGrade",
principalColumn: "ID");
},
comment: "회원 정보");
migrationBuilder.CreateIndex(
name: "IX_BannerPosition_IsActive",
table: "BannerPosition",
column: "IsActive");
migrationBuilder.CreateIndex(
name: "IX_Member_Email",
table: "Member",
column: "Email",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Member_GradeID",
table: "Member",
column: "GradeID");
migrationBuilder.CreateIndex(
name: "IX_Member_Name",
table: "Member",
column: "Name",
unique: true,
filter: "[Name] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_Member_SID",
table: "Member",
column: "SID",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_MemberGrade_EngName",
table: "MemberGrade",
column: "EngName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_MemberGrade_KorName",
table: "MemberGrade",
column: "KorName",
unique: true);
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Member");
migrationBuilder.DropTable(
name: "MemberApprove");
migrationBuilder.DropTable(
name: "MemberGrade");
migrationBuilder.DropIndex(
name: "IX_BannerPosition_IsActive",
table: "BannerPosition");
migrationBuilder.AlterColumn(
name: "Image",
table: "BannerItem",
type: "nvarchar(1024)",
maxLength: 1024,
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(1024)",
oldMaxLength: 1024,
oldNullable: true);
}
}
}