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
|
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace HyperBooru.Migrations
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Objects",
columns: table => new
{
ObjectId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Guid = table.Column<Guid>(type: "TEXT", nullable: false),
ObjectType = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Objects", x => x.ObjectId);
});
migrationBuilder.CreateTable(
name: "Media",
columns: table => new
{
ObjectId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Checksum = table.Column<string>(type: "TEXT", nullable: false),
MimeType = table.Column<string>(type: "TEXT", nullable: false),
ShortDescription = table.Column<string>(type: "TEXT", nullable: true),
LongDescription = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Media", x => x.ObjectId);
table.ForeignKey(
name: "FK_Media_Objects_ObjectId",
column: x => x.ObjectId,
principalTable: "Objects",
principalColumn: "ObjectId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "TagDefinitions",
columns: table => new
{
ObjectId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Source = table.Column<int>(type: "INTEGER", nullable: false),
Namespace = table.Column<string>(type: "TEXT", nullable: true),
Name = table.Column<string>(type: "TEXT", nullable: false),
DbTagDefinitionObjectId = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_TagDefinitions", x => x.ObjectId);
table.ForeignKey(
name: "FK_TagDefinitions_Objects_ObjectId",
column: x => x.ObjectId,
principalTable: "Objects",
principalColumn: "ObjectId",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TagDefinitions_TagDefinitions_DbTagDefinitionObjectId",
column: x => x.DbTagDefinitionObjectId,
principalTable: "TagDefinitions",
principalColumn: "ObjectId");
});
migrationBuilder.CreateTable(
name: "UploadedFiles",
columns: table => new
{
UploadedFileId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
OriginalChecksum = table.Column<string>(type: "TEXT", nullable: false),
Filename = table.Column<string>(type: "TEXT", nullable: true),
UploadTime = table.Column<DateTime>(type: "TEXT", nullable: false),
LastAccessTime = table.Column<DateTime>(type: "TEXT", nullable: true),
LastWriteTime = table.Column<DateTime>(type: "TEXT", nullable: true),
CreateTime = table.Column<DateTime>(type: "TEXT", nullable: true),
MediaObjectId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UploadedFiles", x => x.UploadedFileId);
table.ForeignKey(
name: "FK_UploadedFiles_Media_MediaObjectId",
column: x => x.MediaObjectId,
principalTable: "Media",
principalColumn: "ObjectId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Tags",
columns: table => new
{
ObjectId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
TagDefinitionObjectId = table.Column<int>(type: "INTEGER", nullable: false),
CreateTime = table.Column<DateTime>(type: "TEXT", nullable: false),
TargetObjectId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Tags", x => x.ObjectId);
table.ForeignKey(
name: "FK_Tags_Objects_ObjectId",
column: x => x.ObjectId,
principalTable: "Objects",
principalColumn: "ObjectId",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Tags_Objects_TargetObjectId",
column: x => x.TargetObjectId,
principalTable: "Objects",
principalColumn: "ObjectId",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Tags_TagDefinitions_TagDefinitionObjectId",
column: x => x.TagDefinitionObjectId,
principalTable: "TagDefinitions",
principalColumn: "ObjectId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Objects_Guid",
table: "Objects",
column: "Guid");
migrationBuilder.CreateIndex(
name: "IX_TagDefinitions_DbTagDefinitionObjectId",
table: "TagDefinitions",
column: "DbTagDefinitionObjectId");
migrationBuilder.CreateIndex(
name: "IX_Tags_TagDefinitionObjectId",
table: "Tags",
column: "TagDefinitionObjectId");
migrationBuilder.CreateIndex(
name: "IX_Tags_TargetObjectId",
table: "Tags",
column: "TargetObjectId");
migrationBuilder.CreateIndex(
name: "IX_UploadedFiles_MediaObjectId",
table: "UploadedFiles",
column: "MediaObjectId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Tags");
migrationBuilder.DropTable(
name: "UploadedFiles");
migrationBuilder.DropTable(
name: "TagDefinitions");
migrationBuilder.DropTable(
name: "Media");
migrationBuilder.DropTable(
name: "Objects");
}
}
}
|