sunpengfei
2025-10-09 eeb1019e42abc3fc0e4b10b181b46c02b6e58843
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
using System;
using Microsoft.EntityFrameworkCore.Migrations;
 
#nullable disable
 
namespace ApiTools.Database.Migrations.Migrations
{
    /// <inheritdoc />
    public partial class CreateUser : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<Guid>(
                name: "ChannelId",
                table: "SmsSettingAccess",
                type: "uniqueidentifier",
                nullable: true);
 
            migrationBuilder.AddColumn<Guid>(
                name: "ChannelId",
                table: "SmsSetting",
                type: "uniqueidentifier",
                nullable: true);
 
            migrationBuilder.AddColumn<Guid>(
                name: "ChannelId",
                table: "SmsLog",
                type: "uniqueidentifier",
                nullable: true);
 
            migrationBuilder.AddColumn<bool>(
                name: "IsDisabled",
                table: "Channel",
                type: "bit",
                nullable: false,
                defaultValue: false);
 
            migrationBuilder.CreateTable(
                name: "User",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Type = table.Column<int>(type: "int", nullable: false),
                    ChannelId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    Avatar = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Name = table.Column<string>(type: "nvarchar(32)", maxLength: 32, nullable: true),
                    UserName = table.Column<string>(type: "nvarchar(32)", maxLength: 32, nullable: false),
                    PhoneNumber = table.Column<string>(type: "nvarchar(11)", maxLength: 11, nullable: true),
                    IsCheckPhoneNumber = table.Column<bool>(type: "bit", nullable: false),
                    Password = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Level = table.Column<int>(type: "int", nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Status = table.Column<int>(type: "int", nullable: false),
                    Sort = table.Column<int>(type: "int", nullable: false),
                    TraceId = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    CreatedTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
                    CreatedUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    CreatedChannelId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    UpdatedTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
                    UpdatedUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_User", x => x.Id);
                    table.ForeignKey(
                        name: "FK_User_Channel_ChannelId",
                        column: x => x.ChannelId,
                        principalTable: "Channel",
                        principalColumn: "Id");
                });
 
            migrationBuilder.InsertData(
                table: "User",
                columns: new[] { "Id", "Avatar", "ChannelId", "CreatedChannelId", "CreatedTime", "CreatedUserId", "IsCheckPhoneNumber", "IsDeleted", "Level", "Name", "Password", "PhoneNumber", "Remark", "Sort", "Status", "TraceId", "Type", "UpdatedTime", "UpdatedUserId", "UserName" },
                values: new object[] { new Guid("11111111-1111-1111-1111-111111111111"), null, null, null, new DateTimeOffset(new DateTime(2000, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 8, 0, 0, 0)), null, false, false, 999, "管理员", "iEYggKrMhQ3ASUGLobra1w==:fn/DsMJUbD9FGpvBvR3moMpMPptdxzZlourPVhU479I=", null, null, 0, 10, null, 100, null, null, "system" });
 
            migrationBuilder.CreateIndex(
                name: "IX_SmsSettingAccess_ChannelId",
                table: "SmsSettingAccess",
                column: "ChannelId");
 
            migrationBuilder.CreateIndex(
                name: "IX_SmsSetting_ChannelId",
                table: "SmsSetting",
                column: "ChannelId");
 
            migrationBuilder.CreateIndex(
                name: "IX_SmsLog_ChannelId",
                table: "SmsLog",
                column: "ChannelId");
 
            migrationBuilder.CreateIndex(
                name: "IX_User_ChannelId",
                table: "User",
                column: "ChannelId");
 
            migrationBuilder.AddForeignKey(
                name: "FK_SmsLog_Channel_ChannelId",
                table: "SmsLog",
                column: "ChannelId",
                principalTable: "Channel",
                principalColumn: "Id");
 
            migrationBuilder.AddForeignKey(
                name: "FK_SmsSetting_Channel_ChannelId",
                table: "SmsSetting",
                column: "ChannelId",
                principalTable: "Channel",
                principalColumn: "Id");
 
            migrationBuilder.AddForeignKey(
                name: "FK_SmsSettingAccess_Channel_ChannelId",
                table: "SmsSettingAccess",
                column: "ChannelId",
                principalTable: "Channel",
                principalColumn: "Id");
        }
 
        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_SmsLog_Channel_ChannelId",
                table: "SmsLog");
 
            migrationBuilder.DropForeignKey(
                name: "FK_SmsSetting_Channel_ChannelId",
                table: "SmsSetting");
 
            migrationBuilder.DropForeignKey(
                name: "FK_SmsSettingAccess_Channel_ChannelId",
                table: "SmsSettingAccess");
 
            migrationBuilder.DropTable(
                name: "User");
 
            migrationBuilder.DropIndex(
                name: "IX_SmsSettingAccess_ChannelId",
                table: "SmsSettingAccess");
 
            migrationBuilder.DropIndex(
                name: "IX_SmsSetting_ChannelId",
                table: "SmsSetting");
 
            migrationBuilder.DropIndex(
                name: "IX_SmsLog_ChannelId",
                table: "SmsLog");
 
            migrationBuilder.DropColumn(
                name: "ChannelId",
                table: "SmsSettingAccess");
 
            migrationBuilder.DropColumn(
                name: "ChannelId",
                table: "SmsSetting");
 
            migrationBuilder.DropColumn(
                name: "ChannelId",
                table: "SmsLog");
 
            migrationBuilder.DropColumn(
                name: "IsDisabled",
                table: "Channel");
        }
    }
}