sunpengfei
2025-08-28 4ab0bcef19b78f9ae0339d4b78de68a7297f7683
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
using System;
using Microsoft.EntityFrameworkCore.Migrations;
 
#nullable disable
 
namespace FlexJobApi.Database.Migrations.Migrations.LogDb
{
    /// <inheritdoc />
    public partial class Init : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "ConsoleLog",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Access = table.Column<int>(type: "int", nullable: false, comment: "通道"),
                    Level = table.Column<int>(type: "int", nullable: false, comment: "级别"),
                    Content = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "内容"),
                    StackTrace = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "堆栈跟踪"),
                    Url = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "链接地址"),
                    ClientIpAddress = table.Column<string>(type: "nvarchar(32)", maxLength: 32, nullable: true, comment: "客户IP地址"),
                    CreatedTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
                    UpdatedTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
                    Sort = table.Column<int>(type: "int", nullable: false, comment: "排序"),
                    TraceId = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "跟踪Id"),
                    CreatedUserInfoId = table.Column<Guid>(type: "uniqueidentifier", nullable: true, comment: "创建操作人"),
                    UpdateUserInfoId = table.Column<Guid>(type: "uniqueidentifier", nullable: true, comment: "最后更新操作人"),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false, comment: "是否删除")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ConsoleLog", x => x.Id);
                },
                comment: "控制台日志");
 
            migrationBuilder.CreateTable(
                name: "DbAuditLog",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    TableName = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false, comment: "表名"),
                    PrimaryKey = table.Column<Guid>(type: "uniqueidentifier", nullable: false, comment: "主键"),
                    Operate = table.Column<int>(type: "int", nullable: false, comment: "操作"),
                    OldValues = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "旧值"),
                    NewValues = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "新值"),
                    CreatedTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
                    UpdatedTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
                    Sort = table.Column<int>(type: "int", nullable: false, comment: "排序"),
                    TraceId = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "跟踪Id"),
                    CreatedUserInfoId = table.Column<Guid>(type: "uniqueidentifier", nullable: true, comment: "创建操作人"),
                    UpdateUserInfoId = table.Column<Guid>(type: "uniqueidentifier", nullable: true, comment: "最后更新操作人"),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false, comment: "是否删除")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_DbAuditLog", x => x.Id);
                },
                comment: "数据库审计日志");
 
            migrationBuilder.CreateTable(
                name: "ExceptionLog",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Type = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true, comment: "类型"),
                    Code = table.Column<string>(type: "nvarchar(32)", maxLength: 32, nullable: true, comment: "代码"),
                    Message = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "消息"),
                    StackTrace = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "堆栈跟踪"),
                    CreatedTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
                    UpdatedTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
                    Sort = table.Column<int>(type: "int", nullable: false, comment: "排序"),
                    TraceId = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "跟踪Id"),
                    CreatedUserInfoId = table.Column<Guid>(type: "uniqueidentifier", nullable: true, comment: "创建操作人"),
                    UpdateUserInfoId = table.Column<Guid>(type: "uniqueidentifier", nullable: true, comment: "最后更新操作人"),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false, comment: "是否删除")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ExceptionLog", x => x.Id);
                },
                comment: "异常日志");
 
            migrationBuilder.CreateTable(
                name: "QueueLog",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Access = table.Column<int>(type: "int", nullable: false, comment: "通道"),
                    EventId = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false, comment: "事件Id"),
                    Data = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "数据"),
                    IsConsumOnce = table.Column<bool>(type: "bit", nullable: false, comment: "消息是否只消费一次"),
                    ElapsedMilliseconds = table.Column<long>(type: "bigint", nullable: false, comment: "耗时毫秒数"),
                    CreatedTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
                    UpdatedTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
                    Sort = table.Column<int>(type: "int", nullable: false, comment: "排序"),
                    TraceId = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "跟踪Id"),
                    CreatedUserInfoId = table.Column<Guid>(type: "uniqueidentifier", nullable: true, comment: "创建操作人"),
                    UpdateUserInfoId = table.Column<Guid>(type: "uniqueidentifier", nullable: true, comment: "最后更新操作人"),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false, comment: "是否删除")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_QueueLog", x => x.Id);
                },
                comment: "消息队列日志");
 
            migrationBuilder.CreateTable(
                name: "ResourceLog",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Url = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Method = table.Column<string>(type: "nvarchar(6)", maxLength: 6, nullable: false),
                    Headers = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Request = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Callback = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    IsSuccess = table.Column<bool>(type: "bit", nullable: false),
                    ClientIpAddress = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    ElapsedMilliseconds = table.Column<long>(type: "bigint", nullable: false),
                    CreatedTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
                    UpdatedTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
                    Sort = table.Column<int>(type: "int", nullable: false, comment: "排序"),
                    TraceId = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "跟踪Id"),
                    CreatedUserInfoId = table.Column<Guid>(type: "uniqueidentifier", nullable: true, comment: "创建操作人"),
                    UpdateUserInfoId = table.Column<Guid>(type: "uniqueidentifier", nullable: true, comment: "最后更新操作人"),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false, comment: "是否删除")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ResourceLog", x => x.Id);
                });
 
            migrationBuilder.CreateTable(
                name: "SmsLog",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Access = table.Column<int>(type: "int", nullable: false, comment: "通道"),
                    PhoneNumber = table.Column<string>(type: "nvarchar(11)", maxLength: 11, nullable: false, comment: "手机号码"),
                    TemplateCode = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false, comment: "模板代码"),
                    TemplateParam = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "模板参数"),
                    Expiry = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "有效期"),
                    IsUsed = table.Column<bool>(type: "bit", nullable: false, comment: "是否使用"),
                    CreatedTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
                    UpdatedTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
                    Sort = table.Column<int>(type: "int", nullable: false, comment: "排序"),
                    TraceId = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "跟踪Id"),
                    CreatedUserInfoId = table.Column<Guid>(type: "uniqueidentifier", nullable: true, comment: "创建操作人"),
                    UpdateUserInfoId = table.Column<Guid>(type: "uniqueidentifier", nullable: true, comment: "最后更新操作人"),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false, comment: "是否删除")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SmsLog", x => x.Id);
                },
                comment: "短信日志");
        }
 
        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "ConsoleLog");
 
            migrationBuilder.DropTable(
                name: "DbAuditLog");
 
            migrationBuilder.DropTable(
                name: "ExceptionLog");
 
            migrationBuilder.DropTable(
                name: "QueueLog");
 
            migrationBuilder.DropTable(
                name: "ResourceLog");
 
            migrationBuilder.DropTable(
                name: "SmsLog");
        }
    }
}