Revize caa28567
Přidáno uživatelem Vojtěch Bartička před asi 3 roky(ů)
Backend/Backend/Controllers/WeatherForecastController.cs | ||
---|---|---|
1 |
using Core.Contexts; |
|
1 | 2 |
using Microsoft.AspNetCore.Mvc; |
3 |
using Core.Entities; |
|
4 |
using Core.Enums; |
|
2 | 5 |
|
3 | 6 |
namespace Backend.Controllers |
4 | 7 |
{ |
8 |
|
|
5 | 9 |
[ApiController] |
6 | 10 |
[Route("[controller]")] |
7 | 11 |
public class WeatherForecastController : ControllerBase |
8 | 12 |
{ |
13 |
private readonly DatabaseContext _databaseContext; |
|
14 |
|
|
9 | 15 |
private static readonly string[] Summaries = new[] |
10 | 16 |
{ |
11 | 17 |
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" |
... | ... | |
13 | 19 |
|
14 | 20 |
private readonly ILogger<WeatherForecastController> _logger; |
15 | 21 |
|
16 |
public WeatherForecastController(ILogger<WeatherForecastController> logger) |
|
22 |
public WeatherForecastController(ILogger<WeatherForecastController> logger, DatabaseContext databaseContext)
|
|
17 | 23 |
{ |
18 | 24 |
_logger = logger; |
25 |
_databaseContext = databaseContext; |
|
19 | 26 |
} |
20 | 27 |
|
21 | 28 |
[HttpGet(Name = "GetWeatherForecast")] |
22 | 29 |
public IEnumerable<WeatherForecast> Get() |
23 | 30 |
{ |
31 |
DocumentContent content = new DocumentContent() { Content = "sample content" }; |
|
32 |
_databaseContext.DocumentContents.Add(content); |
|
33 |
|
|
34 |
User user = new User() { Username = "test", Name = "testname", Surname = "testsurname", Password = "password", Role = ERole.ANNOTATOR}; |
|
35 |
_databaseContext.Users.Add(user); |
|
36 |
|
|
37 |
Document document = new Document() { Content = content, Name = "test", DateAdded = DateTime.Now, Length = 10, RequiredAnnotations = 3, UserAdded = user }; |
|
38 |
_databaseContext.Documents.Add(document); |
|
39 |
_databaseContext.SaveChanges(); |
|
40 |
|
|
41 |
Annotation annotation = new Annotation() { DateAssigned = DateTime.Now, DateLastChanged = DateTime.Now, Document = document, Note = "", |
|
42 |
State = EState.NEW, User = user, UserAssigned = user}; |
|
43 |
_databaseContext.Annotations.Add(annotation); |
|
44 |
|
|
45 |
Class clss = new Class() { Color = "rgb", Description = "desc", Name = "class name" }; |
|
46 |
_databaseContext.Classes.Add(clss); |
|
47 |
|
|
48 |
annotation.Classes.Add(clss); |
|
49 |
|
|
50 |
TagCategory category = new TagCategory() { Name = "category", Color = "rgb", Description = "desc" }; |
|
51 |
_databaseContext.TagCategories.Add(category); |
|
52 |
|
|
53 |
Tag tag = new Tag() { Name = "testtag", Category = category, Description = "tag", Color = "color" }; |
|
54 |
_databaseContext.Tags.Add(tag); |
|
55 |
SubTag subTag = new SubTag() { Description = "test subtag", Name = "subtag", Tag = tag }; |
|
56 |
_databaseContext.SubTags.Add(subTag); |
|
57 |
|
|
58 |
AnnotationTag annotationTag = new AnnotationTag() { Annotation = annotation, Instance = 0, Length = 1, Position = 0, Tag = tag, SubTag = subTag, Note = "" }; |
|
59 |
_databaseContext.AnnotationTags.Add(annotationTag); |
|
60 |
|
|
61 |
_databaseContext.SaveChanges(); |
|
62 |
|
|
24 | 63 |
return Enumerable.Range(1, 5).Select(index => new WeatherForecast |
25 | 64 |
{ |
26 | 65 |
Date = DateTime.Now.AddDays(index), |
Backend/Backend/Migrations/20220330120554_v1.Designer.cs | ||
---|---|---|
1 |
// <auto-generated /> |
|
2 |
using System; |
|
3 |
using Core.Contexts; |
|
4 |
using Microsoft.EntityFrameworkCore; |
|
5 |
using Microsoft.EntityFrameworkCore.Infrastructure; |
|
6 |
using Microsoft.EntityFrameworkCore.Migrations; |
|
7 |
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
|
8 |
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; |
|
9 |
|
|
10 |
#nullable disable |
|
11 |
|
|
12 |
namespace RestAPI.Migrations |
|
13 |
{ |
|
14 |
[DbContext(typeof(DatabaseContext))] |
|
15 |
[Migration("20220330120554_v1")] |
|
16 |
partial class v1 |
|
17 |
{ |
|
18 |
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
|
19 |
{ |
|
20 |
#pragma warning disable 612, 618 |
|
21 |
modelBuilder |
|
22 |
.HasAnnotation("ProductVersion", "6.0.3") |
|
23 |
.HasAnnotation("Relational:MaxIdentifierLength", 63); |
|
24 |
|
|
25 |
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); |
|
26 |
|
|
27 |
modelBuilder.Entity("Core.Entities.Annotation", b => |
|
28 |
{ |
|
29 |
b.Property<int>("Id") |
|
30 |
.ValueGeneratedOnAdd() |
|
31 |
.HasColumnType("integer"); |
|
32 |
|
|
33 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
34 |
|
|
35 |
b.Property<DateTime>("DateAssigned") |
|
36 |
.HasColumnType("timestamp with time zone"); |
|
37 |
|
|
38 |
b.Property<DateTime>("DateLastChanged") |
|
39 |
.HasColumnType("timestamp with time zone"); |
|
40 |
|
|
41 |
b.Property<int>("DocumentId") |
|
42 |
.HasColumnType("integer"); |
|
43 |
|
|
44 |
b.Property<string>("Note") |
|
45 |
.IsRequired() |
|
46 |
.HasColumnType("text"); |
|
47 |
|
|
48 |
b.Property<int>("State") |
|
49 |
.HasColumnType("integer"); |
|
50 |
|
|
51 |
b.Property<int>("UserAssignedId") |
|
52 |
.HasColumnType("integer"); |
|
53 |
|
|
54 |
b.Property<int>("UserId") |
|
55 |
.HasColumnType("integer"); |
|
56 |
|
|
57 |
b.HasKey("Id"); |
|
58 |
|
|
59 |
b.HasIndex("DocumentId"); |
|
60 |
|
|
61 |
b.HasIndex("UserAssignedId"); |
|
62 |
|
|
63 |
b.HasIndex("UserId"); |
|
64 |
|
|
65 |
b.ToTable("Annotations"); |
|
66 |
}); |
|
67 |
|
|
68 |
modelBuilder.Entity("Core.Entities.AnnotationClass", b => |
|
69 |
{ |
|
70 |
b.Property<int>("Id") |
|
71 |
.ValueGeneratedOnAdd() |
|
72 |
.HasColumnType("integer"); |
|
73 |
|
|
74 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
75 |
|
|
76 |
b.Property<int>("AnnotationId") |
|
77 |
.HasColumnType("integer"); |
|
78 |
|
|
79 |
b.Property<int>("ClassId") |
|
80 |
.HasColumnType("integer"); |
|
81 |
|
|
82 |
b.HasKey("Id"); |
|
83 |
|
|
84 |
b.HasIndex("AnnotationId"); |
|
85 |
|
|
86 |
b.HasIndex("ClassId"); |
|
87 |
|
|
88 |
b.ToTable("AnnotationsClasses"); |
|
89 |
}); |
|
90 |
|
|
91 |
modelBuilder.Entity("Core.Entities.AnnotationTag", b => |
|
92 |
{ |
|
93 |
b.Property<int>("Id") |
|
94 |
.ValueGeneratedOnAdd() |
|
95 |
.HasColumnType("integer"); |
|
96 |
|
|
97 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
98 |
|
|
99 |
b.Property<int>("AnnotationId") |
|
100 |
.HasColumnType("integer"); |
|
101 |
|
|
102 |
b.Property<int>("Instance") |
|
103 |
.HasColumnType("integer"); |
|
104 |
|
|
105 |
b.Property<int>("Length") |
|
106 |
.HasColumnType("integer"); |
|
107 |
|
|
108 |
b.Property<string>("Note") |
|
109 |
.IsRequired() |
|
110 |
.HasColumnType("text"); |
|
111 |
|
|
112 |
b.Property<int>("Position") |
|
113 |
.HasColumnType("integer"); |
|
114 |
|
|
115 |
b.Property<int>("SubTagId") |
|
116 |
.HasColumnType("integer"); |
|
117 |
|
|
118 |
b.Property<int>("TagId") |
|
119 |
.HasColumnType("integer"); |
|
120 |
|
|
121 |
b.HasKey("Id"); |
|
122 |
|
|
123 |
b.HasIndex("AnnotationId"); |
|
124 |
|
|
125 |
b.HasIndex("SubTagId"); |
|
126 |
|
|
127 |
b.HasIndex("TagId"); |
|
128 |
|
|
129 |
b.ToTable("AnnotationTags"); |
|
130 |
}); |
|
131 |
|
|
132 |
modelBuilder.Entity("Core.Entities.Class", b => |
|
133 |
{ |
|
134 |
b.Property<int>("Id") |
|
135 |
.ValueGeneratedOnAdd() |
|
136 |
.HasColumnType("integer"); |
|
137 |
|
|
138 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
139 |
|
|
140 |
b.Property<string>("Color") |
|
141 |
.IsRequired() |
|
142 |
.HasColumnType("text"); |
|
143 |
|
|
144 |
b.Property<string>("Description") |
|
145 |
.IsRequired() |
|
146 |
.HasColumnType("text"); |
|
147 |
|
|
148 |
b.Property<string>("Name") |
|
149 |
.IsRequired() |
|
150 |
.HasColumnType("text"); |
|
151 |
|
|
152 |
b.HasKey("Id"); |
|
153 |
|
|
154 |
b.ToTable("Classes"); |
|
155 |
}); |
|
156 |
|
|
157 |
modelBuilder.Entity("Core.Entities.Document", b => |
|
158 |
{ |
|
159 |
b.Property<int>("Id") |
|
160 |
.ValueGeneratedOnAdd() |
|
161 |
.HasColumnType("integer"); |
|
162 |
|
|
163 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
164 |
|
|
165 |
b.Property<int>("ContentId") |
|
166 |
.HasColumnType("integer"); |
|
167 |
|
|
168 |
b.Property<DateTime>("DateAdded") |
|
169 |
.HasColumnType("timestamp with time zone"); |
|
170 |
|
|
171 |
b.Property<int>("Length") |
|
172 |
.HasColumnType("integer"); |
|
173 |
|
|
174 |
b.Property<string>("Name") |
|
175 |
.IsRequired() |
|
176 |
.HasColumnType("text"); |
|
177 |
|
|
178 |
b.Property<int>("RequiredAnnotations") |
|
179 |
.HasColumnType("integer"); |
|
180 |
|
|
181 |
b.Property<int>("UserAddedId") |
|
182 |
.HasColumnType("integer"); |
|
183 |
|
|
184 |
b.HasKey("Id"); |
|
185 |
|
|
186 |
b.HasIndex("ContentId"); |
|
187 |
|
|
188 |
b.HasIndex("UserAddedId"); |
|
189 |
|
|
190 |
b.ToTable("Documents"); |
|
191 |
}); |
|
192 |
|
|
193 |
modelBuilder.Entity("Core.Entities.DocumentContent", b => |
|
194 |
{ |
|
195 |
b.Property<int>("Id") |
|
196 |
.ValueGeneratedOnAdd() |
|
197 |
.HasColumnType("integer"); |
|
198 |
|
|
199 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
200 |
|
|
201 |
b.Property<string>("Content") |
|
202 |
.IsRequired() |
|
203 |
.HasColumnType("text"); |
|
204 |
|
|
205 |
b.HasKey("Id"); |
|
206 |
|
|
207 |
b.ToTable("DocumentContents"); |
|
208 |
}); |
|
209 |
|
|
210 |
modelBuilder.Entity("Core.Entities.SubTag", b => |
|
211 |
{ |
|
212 |
b.Property<int>("Id") |
|
213 |
.ValueGeneratedOnAdd() |
|
214 |
.HasColumnType("integer"); |
|
215 |
|
|
216 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
217 |
|
|
218 |
b.Property<string>("Description") |
|
219 |
.IsRequired() |
|
220 |
.HasColumnType("text"); |
|
221 |
|
|
222 |
b.Property<string>("Name") |
|
223 |
.IsRequired() |
|
224 |
.HasColumnType("text"); |
|
225 |
|
|
226 |
b.Property<int>("TagId") |
|
227 |
.HasColumnType("integer"); |
|
228 |
|
|
229 |
b.HasKey("Id"); |
|
230 |
|
|
231 |
b.HasIndex("TagId"); |
|
232 |
|
|
233 |
b.ToTable("SubTags"); |
|
234 |
}); |
|
235 |
|
|
236 |
modelBuilder.Entity("Core.Entities.Tag", b => |
|
237 |
{ |
|
238 |
b.Property<int>("Id") |
|
239 |
.ValueGeneratedOnAdd() |
|
240 |
.HasColumnType("integer"); |
|
241 |
|
|
242 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
243 |
|
|
244 |
b.Property<int>("CategoryId") |
|
245 |
.HasColumnType("integer"); |
|
246 |
|
|
247 |
b.Property<string>("Color") |
|
248 |
.IsRequired() |
|
249 |
.HasColumnType("text"); |
|
250 |
|
|
251 |
b.Property<string>("Description") |
|
252 |
.IsRequired() |
|
253 |
.HasColumnType("text"); |
|
254 |
|
|
255 |
b.Property<string>("Name") |
|
256 |
.IsRequired() |
|
257 |
.HasColumnType("text"); |
|
258 |
|
|
259 |
b.HasKey("Id"); |
|
260 |
|
|
261 |
b.HasIndex("CategoryId"); |
|
262 |
|
|
263 |
b.ToTable("Tags"); |
|
264 |
}); |
|
265 |
|
|
266 |
modelBuilder.Entity("Core.Entities.TagCategory", b => |
|
267 |
{ |
|
268 |
b.Property<int>("Id") |
|
269 |
.ValueGeneratedOnAdd() |
|
270 |
.HasColumnType("integer"); |
|
271 |
|
|
272 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
273 |
|
|
274 |
b.Property<string>("Color") |
|
275 |
.IsRequired() |
|
276 |
.HasColumnType("text"); |
|
277 |
|
|
278 |
b.Property<string>("Description") |
|
279 |
.IsRequired() |
|
280 |
.HasColumnType("text"); |
|
281 |
|
|
282 |
b.Property<string>("Name") |
|
283 |
.IsRequired() |
|
284 |
.HasColumnType("text"); |
|
285 |
|
|
286 |
b.HasKey("Id"); |
|
287 |
|
|
288 |
b.ToTable("TagCategories"); |
|
289 |
}); |
|
290 |
|
|
291 |
modelBuilder.Entity("Core.Entities.User", b => |
|
292 |
{ |
|
293 |
b.Property<int>("Id") |
|
294 |
.ValueGeneratedOnAdd() |
|
295 |
.HasColumnType("integer"); |
|
296 |
|
|
297 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
298 |
|
|
299 |
b.Property<string>("Name") |
|
300 |
.IsRequired() |
|
301 |
.HasColumnType("text"); |
|
302 |
|
|
303 |
b.Property<string>("Password") |
|
304 |
.IsRequired() |
|
305 |
.HasColumnType("text"); |
|
306 |
|
|
307 |
b.Property<int>("Role") |
|
308 |
.HasColumnType("integer"); |
|
309 |
|
|
310 |
b.Property<string>("Surname") |
|
311 |
.IsRequired() |
|
312 |
.HasColumnType("text"); |
|
313 |
|
|
314 |
b.Property<string>("Username") |
|
315 |
.IsRequired() |
|
316 |
.HasColumnType("text"); |
|
317 |
|
|
318 |
b.HasKey("Id"); |
|
319 |
|
|
320 |
b.ToTable("Users"); |
|
321 |
}); |
|
322 |
|
|
323 |
modelBuilder.Entity("Core.Entities.Annotation", b => |
|
324 |
{ |
|
325 |
b.HasOne("Core.Entities.Document", "Document") |
|
326 |
.WithMany() |
|
327 |
.HasForeignKey("DocumentId") |
|
328 |
.OnDelete(DeleteBehavior.Cascade) |
|
329 |
.IsRequired(); |
|
330 |
|
|
331 |
b.HasOne("Core.Entities.User", "UserAssigned") |
|
332 |
.WithMany() |
|
333 |
.HasForeignKey("UserAssignedId") |
|
334 |
.OnDelete(DeleteBehavior.Cascade) |
|
335 |
.IsRequired(); |
|
336 |
|
|
337 |
b.HasOne("Core.Entities.User", "User") |
|
338 |
.WithMany() |
|
339 |
.HasForeignKey("UserId") |
|
340 |
.OnDelete(DeleteBehavior.Cascade) |
|
341 |
.IsRequired(); |
|
342 |
|
|
343 |
b.Navigation("Document"); |
|
344 |
|
|
345 |
b.Navigation("User"); |
|
346 |
|
|
347 |
b.Navigation("UserAssigned"); |
|
348 |
}); |
|
349 |
|
|
350 |
modelBuilder.Entity("Core.Entities.AnnotationClass", b => |
|
351 |
{ |
|
352 |
b.HasOne("Core.Entities.Annotation", "Annotation") |
|
353 |
.WithMany("Classes") |
|
354 |
.HasForeignKey("AnnotationId") |
|
355 |
.OnDelete(DeleteBehavior.Cascade) |
|
356 |
.IsRequired(); |
|
357 |
|
|
358 |
b.HasOne("Core.Entities.Class", "Class") |
|
359 |
.WithMany("Annotations") |
|
360 |
.HasForeignKey("ClassId") |
|
361 |
.OnDelete(DeleteBehavior.Cascade) |
|
362 |
.IsRequired(); |
|
363 |
|
|
364 |
b.Navigation("Annotation"); |
|
365 |
|
|
366 |
b.Navigation("Class"); |
|
367 |
}); |
|
368 |
|
|
369 |
modelBuilder.Entity("Core.Entities.AnnotationTag", b => |
|
370 |
{ |
|
371 |
b.HasOne("Core.Entities.Annotation", "Annotation") |
|
372 |
.WithMany() |
|
373 |
.HasForeignKey("AnnotationId") |
|
374 |
.OnDelete(DeleteBehavior.Cascade) |
|
375 |
.IsRequired(); |
|
376 |
|
|
377 |
b.HasOne("Core.Entities.SubTag", "SubTag") |
|
378 |
.WithMany() |
|
379 |
.HasForeignKey("SubTagId") |
|
380 |
.OnDelete(DeleteBehavior.Cascade) |
|
381 |
.IsRequired(); |
|
382 |
|
|
383 |
b.HasOne("Core.Entities.Tag", "Tag") |
|
384 |
.WithMany() |
|
385 |
.HasForeignKey("TagId") |
|
386 |
.OnDelete(DeleteBehavior.Cascade) |
|
387 |
.IsRequired(); |
|
388 |
|
|
389 |
b.Navigation("Annotation"); |
|
390 |
|
|
391 |
b.Navigation("SubTag"); |
|
392 |
|
|
393 |
b.Navigation("Tag"); |
|
394 |
}); |
|
395 |
|
|
396 |
modelBuilder.Entity("Core.Entities.Document", b => |
|
397 |
{ |
|
398 |
b.HasOne("Core.Entities.DocumentContent", "Content") |
|
399 |
.WithMany() |
|
400 |
.HasForeignKey("ContentId") |
|
401 |
.OnDelete(DeleteBehavior.Cascade) |
|
402 |
.IsRequired(); |
|
403 |
|
|
404 |
b.HasOne("Core.Entities.User", "UserAdded") |
|
405 |
.WithMany() |
|
406 |
.HasForeignKey("UserAddedId") |
|
407 |
.OnDelete(DeleteBehavior.Cascade) |
|
408 |
.IsRequired(); |
|
409 |
|
|
410 |
b.Navigation("Content"); |
|
411 |
|
|
412 |
b.Navigation("UserAdded"); |
|
413 |
}); |
|
414 |
|
|
415 |
modelBuilder.Entity("Core.Entities.SubTag", b => |
|
416 |
{ |
|
417 |
b.HasOne("Core.Entities.Tag", "Tag") |
|
418 |
.WithMany() |
|
419 |
.HasForeignKey("TagId") |
|
420 |
.OnDelete(DeleteBehavior.Cascade) |
|
421 |
.IsRequired(); |
|
422 |
|
|
423 |
b.Navigation("Tag"); |
|
424 |
}); |
|
425 |
|
|
426 |
modelBuilder.Entity("Core.Entities.Tag", b => |
|
427 |
{ |
|
428 |
b.HasOne("Core.Entities.TagCategory", "Category") |
|
429 |
.WithMany() |
|
430 |
.HasForeignKey("CategoryId") |
|
431 |
.OnDelete(DeleteBehavior.Cascade) |
|
432 |
.IsRequired(); |
|
433 |
|
|
434 |
b.Navigation("Category"); |
|
435 |
}); |
|
436 |
|
|
437 |
modelBuilder.Entity("Core.Entities.Annotation", b => |
|
438 |
{ |
|
439 |
b.Navigation("Classes"); |
|
440 |
}); |
|
441 |
|
|
442 |
modelBuilder.Entity("Core.Entities.Class", b => |
|
443 |
{ |
|
444 |
b.Navigation("Annotations"); |
|
445 |
}); |
|
446 |
#pragma warning restore 612, 618 |
|
447 |
} |
|
448 |
} |
|
449 |
} |
Backend/Backend/Migrations/20220330120554_v1.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using Microsoft.EntityFrameworkCore.Migrations; |
|
3 |
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; |
|
4 |
|
|
5 |
#nullable disable |
|
6 |
|
|
7 |
namespace RestAPI.Migrations |
|
8 |
{ |
|
9 |
public partial class v1 : Migration |
|
10 |
{ |
|
11 |
protected override void Up(MigrationBuilder migrationBuilder) |
|
12 |
{ |
|
13 |
migrationBuilder.CreateTable( |
|
14 |
name: "Classes", |
|
15 |
columns: table => new |
|
16 |
{ |
|
17 |
Id = table.Column<int>(type: "integer", nullable: false) |
|
18 |
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), |
|
19 |
Name = table.Column<string>(type: "text", nullable: false), |
|
20 |
Description = table.Column<string>(type: "text", nullable: false), |
|
21 |
Color = table.Column<string>(type: "text", nullable: false) |
|
22 |
}, |
|
23 |
constraints: table => |
|
24 |
{ |
|
25 |
table.PrimaryKey("PK_Classes", x => x.Id); |
|
26 |
}); |
|
27 |
|
|
28 |
migrationBuilder.CreateTable( |
|
29 |
name: "DocumentContents", |
|
30 |
columns: table => new |
|
31 |
{ |
|
32 |
Id = table.Column<int>(type: "integer", nullable: false) |
|
33 |
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), |
|
34 |
Content = table.Column<string>(type: "text", nullable: false) |
|
35 |
}, |
|
36 |
constraints: table => |
|
37 |
{ |
|
38 |
table.PrimaryKey("PK_DocumentContents", x => x.Id); |
|
39 |
}); |
|
40 |
|
|
41 |
migrationBuilder.CreateTable( |
|
42 |
name: "TagCategories", |
|
43 |
columns: table => new |
|
44 |
{ |
|
45 |
Id = table.Column<int>(type: "integer", nullable: false) |
|
46 |
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), |
|
47 |
Name = table.Column<string>(type: "text", nullable: false), |
|
48 |
Color = table.Column<string>(type: "text", nullable: false), |
|
49 |
Description = table.Column<string>(type: "text", nullable: false) |
|
50 |
}, |
|
51 |
constraints: table => |
|
52 |
{ |
|
53 |
table.PrimaryKey("PK_TagCategories", x => x.Id); |
|
54 |
}); |
|
55 |
|
|
56 |
migrationBuilder.CreateTable( |
|
57 |
name: "Users", |
|
58 |
columns: table => new |
|
59 |
{ |
|
60 |
Id = table.Column<int>(type: "integer", nullable: false) |
|
61 |
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), |
|
62 |
Username = table.Column<string>(type: "text", nullable: false), |
|
63 |
Password = table.Column<string>(type: "text", nullable: false), |
|
64 |
Name = table.Column<string>(type: "text", nullable: false), |
|
65 |
Surname = table.Column<string>(type: "text", nullable: false), |
|
66 |
Role = table.Column<int>(type: "integer", nullable: false) |
|
67 |
}, |
|
68 |
constraints: table => |
|
69 |
{ |
|
70 |
table.PrimaryKey("PK_Users", x => x.Id); |
|
71 |
}); |
|
72 |
|
|
73 |
migrationBuilder.CreateTable( |
|
74 |
name: "Tags", |
|
75 |
columns: table => new |
|
76 |
{ |
|
77 |
Id = table.Column<int>(type: "integer", nullable: false) |
|
78 |
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), |
|
79 |
CategoryId = table.Column<int>(type: "integer", nullable: false), |
|
80 |
Name = table.Column<string>(type: "text", nullable: false), |
|
81 |
Description = table.Column<string>(type: "text", nullable: false), |
|
82 |
Color = table.Column<string>(type: "text", nullable: false) |
|
83 |
}, |
|
84 |
constraints: table => |
|
85 |
{ |
|
86 |
table.PrimaryKey("PK_Tags", x => x.Id); |
|
87 |
table.ForeignKey( |
|
88 |
name: "FK_Tags_TagCategories_CategoryId", |
|
89 |
column: x => x.CategoryId, |
|
90 |
principalTable: "TagCategories", |
|
91 |
principalColumn: "Id", |
|
92 |
onDelete: ReferentialAction.Cascade); |
|
93 |
}); |
|
94 |
|
|
95 |
migrationBuilder.CreateTable( |
|
96 |
name: "Documents", |
|
97 |
columns: table => new |
|
98 |
{ |
|
99 |
Id = table.Column<int>(type: "integer", nullable: false) |
|
100 |
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), |
|
101 |
Name = table.Column<string>(type: "text", nullable: false), |
|
102 |
Length = table.Column<int>(type: "integer", nullable: false), |
|
103 |
ContentId = table.Column<int>(type: "integer", nullable: false), |
|
104 |
DateAdded = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|
105 |
UserAddedId = table.Column<int>(type: "integer", nullable: false), |
|
106 |
RequiredAnnotations = table.Column<int>(type: "integer", nullable: false) |
|
107 |
}, |
|
108 |
constraints: table => |
|
109 |
{ |
|
110 |
table.PrimaryKey("PK_Documents", x => x.Id); |
|
111 |
table.ForeignKey( |
|
112 |
name: "FK_Documents_DocumentContents_ContentId", |
|
113 |
column: x => x.ContentId, |
|
114 |
principalTable: "DocumentContents", |
|
115 |
principalColumn: "Id", |
|
116 |
onDelete: ReferentialAction.Cascade); |
|
117 |
table.ForeignKey( |
|
118 |
name: "FK_Documents_Users_UserAddedId", |
|
119 |
column: x => x.UserAddedId, |
|
120 |
principalTable: "Users", |
|
121 |
principalColumn: "Id", |
|
122 |
onDelete: ReferentialAction.Cascade); |
|
123 |
}); |
|
124 |
|
|
125 |
migrationBuilder.CreateTable( |
|
126 |
name: "SubTags", |
|
127 |
columns: table => new |
|
128 |
{ |
|
129 |
Id = table.Column<int>(type: "integer", nullable: false) |
|
130 |
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), |
|
131 |
Name = table.Column<string>(type: "text", nullable: false), |
|
132 |
Description = table.Column<string>(type: "text", nullable: false), |
|
133 |
TagId = table.Column<int>(type: "integer", nullable: false) |
|
134 |
}, |
|
135 |
constraints: table => |
|
136 |
{ |
|
137 |
table.PrimaryKey("PK_SubTags", x => x.Id); |
|
138 |
table.ForeignKey( |
|
139 |
name: "FK_SubTags_Tags_TagId", |
|
140 |
column: x => x.TagId, |
|
141 |
principalTable: "Tags", |
|
142 |
principalColumn: "Id", |
|
143 |
onDelete: ReferentialAction.Cascade); |
|
144 |
}); |
|
145 |
|
|
146 |
migrationBuilder.CreateTable( |
|
147 |
name: "Annotations", |
|
148 |
columns: table => new |
|
149 |
{ |
|
150 |
Id = table.Column<int>(type: "integer", nullable: false) |
|
151 |
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), |
|
152 |
DocumentId = table.Column<int>(type: "integer", nullable: false), |
|
153 |
UserId = table.Column<int>(type: "integer", nullable: false), |
|
154 |
UserAssignedId = table.Column<int>(type: "integer", nullable: false), |
|
155 |
DateAssigned = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|
156 |
State = table.Column<int>(type: "integer", nullable: false), |
|
157 |
DateLastChanged = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|
158 |
Note = table.Column<string>(type: "text", nullable: false) |
|
159 |
}, |
|
160 |
constraints: table => |
|
161 |
{ |
|
162 |
table.PrimaryKey("PK_Annotations", x => x.Id); |
|
163 |
table.ForeignKey( |
|
164 |
name: "FK_Annotations_Documents_DocumentId", |
|
165 |
column: x => x.DocumentId, |
|
166 |
principalTable: "Documents", |
|
167 |
principalColumn: "Id", |
|
168 |
onDelete: ReferentialAction.Cascade); |
|
169 |
table.ForeignKey( |
|
170 |
name: "FK_Annotations_Users_UserAssignedId", |
|
171 |
column: x => x.UserAssignedId, |
|
172 |
principalTable: "Users", |
|
173 |
principalColumn: "Id", |
|
174 |
onDelete: ReferentialAction.Cascade); |
|
175 |
table.ForeignKey( |
|
176 |
name: "FK_Annotations_Users_UserId", |
|
177 |
column: x => x.UserId, |
|
178 |
principalTable: "Users", |
|
179 |
principalColumn: "Id", |
|
180 |
onDelete: ReferentialAction.Cascade); |
|
181 |
}); |
|
182 |
|
|
183 |
migrationBuilder.CreateTable( |
|
184 |
name: "AnnotationsClasses", |
|
185 |
columns: table => new |
|
186 |
{ |
|
187 |
Id = table.Column<int>(type: "integer", nullable: false) |
|
188 |
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), |
|
189 |
ClassId = table.Column<int>(type: "integer", nullable: false), |
|
190 |
AnnotationId = table.Column<int>(type: "integer", nullable: false) |
|
191 |
}, |
|
192 |
constraints: table => |
|
193 |
{ |
|
194 |
table.PrimaryKey("PK_AnnotationsClasses", x => x.Id); |
|
195 |
table.ForeignKey( |
|
196 |
name: "FK_AnnotationsClasses_Annotations_AnnotationId", |
|
197 |
column: x => x.AnnotationId, |
|
198 |
principalTable: "Annotations", |
|
199 |
principalColumn: "Id", |
|
200 |
onDelete: ReferentialAction.Cascade); |
|
201 |
table.ForeignKey( |
|
202 |
name: "FK_AnnotationsClasses_Classes_ClassId", |
|
203 |
column: x => x.ClassId, |
|
204 |
principalTable: "Classes", |
|
205 |
principalColumn: "Id", |
|
206 |
onDelete: ReferentialAction.Cascade); |
|
207 |
}); |
|
208 |
|
|
209 |
migrationBuilder.CreateTable( |
|
210 |
name: "AnnotationTags", |
|
211 |
columns: table => new |
|
212 |
{ |
|
213 |
Id = table.Column<int>(type: "integer", nullable: false) |
|
214 |
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), |
|
215 |
AnnotationId = table.Column<int>(type: "integer", nullable: false), |
|
216 |
TagId = table.Column<int>(type: "integer", nullable: false), |
|
217 |
SubTagId = table.Column<int>(type: "integer", nullable: false), |
|
218 |
Instance = table.Column<int>(type: "integer", nullable: false), |
|
219 |
Note = table.Column<string>(type: "text", nullable: false), |
|
220 |
Position = table.Column<int>(type: "integer", nullable: false), |
|
221 |
Length = table.Column<int>(type: "integer", nullable: false) |
|
222 |
}, |
|
223 |
constraints: table => |
|
224 |
{ |
|
225 |
table.PrimaryKey("PK_AnnotationTags", x => x.Id); |
|
226 |
table.ForeignKey( |
|
227 |
name: "FK_AnnotationTags_Annotations_AnnotationId", |
|
228 |
column: x => x.AnnotationId, |
|
229 |
principalTable: "Annotations", |
|
230 |
principalColumn: "Id", |
|
231 |
onDelete: ReferentialAction.Cascade); |
|
232 |
table.ForeignKey( |
|
233 |
name: "FK_AnnotationTags_SubTags_SubTagId", |
|
234 |
column: x => x.SubTagId, |
|
235 |
principalTable: "SubTags", |
|
236 |
principalColumn: "Id", |
|
237 |
onDelete: ReferentialAction.Cascade); |
|
238 |
table.ForeignKey( |
|
239 |
name: "FK_AnnotationTags_Tags_TagId", |
|
240 |
column: x => x.TagId, |
|
241 |
principalTable: "Tags", |
|
242 |
principalColumn: "Id", |
|
243 |
onDelete: ReferentialAction.Cascade); |
|
244 |
}); |
|
245 |
|
|
246 |
migrationBuilder.CreateIndex( |
|
247 |
name: "IX_Annotations_DocumentId", |
|
248 |
table: "Annotations", |
|
249 |
column: "DocumentId"); |
|
250 |
|
|
251 |
migrationBuilder.CreateIndex( |
|
252 |
name: "IX_Annotations_UserAssignedId", |
|
253 |
table: "Annotations", |
|
254 |
column: "UserAssignedId"); |
|
255 |
|
|
256 |
migrationBuilder.CreateIndex( |
|
257 |
name: "IX_Annotations_UserId", |
|
258 |
table: "Annotations", |
|
259 |
column: "UserId"); |
|
260 |
|
|
261 |
migrationBuilder.CreateIndex( |
|
262 |
name: "IX_AnnotationsClasses_AnnotationId", |
|
263 |
table: "AnnotationsClasses", |
|
264 |
column: "AnnotationId"); |
|
265 |
|
|
266 |
migrationBuilder.CreateIndex( |
|
267 |
name: "IX_AnnotationsClasses_ClassId", |
|
268 |
table: "AnnotationsClasses", |
|
269 |
column: "ClassId"); |
|
270 |
|
|
271 |
migrationBuilder.CreateIndex( |
|
272 |
name: "IX_AnnotationTags_AnnotationId", |
|
273 |
table: "AnnotationTags", |
|
274 |
column: "AnnotationId"); |
|
275 |
|
|
276 |
migrationBuilder.CreateIndex( |
|
277 |
name: "IX_AnnotationTags_SubTagId", |
|
278 |
table: "AnnotationTags", |
|
279 |
column: "SubTagId"); |
|
280 |
|
|
281 |
migrationBuilder.CreateIndex( |
|
282 |
name: "IX_AnnotationTags_TagId", |
|
283 |
table: "AnnotationTags", |
|
284 |
column: "TagId"); |
|
285 |
|
|
286 |
migrationBuilder.CreateIndex( |
|
287 |
name: "IX_Documents_ContentId", |
|
288 |
table: "Documents", |
|
289 |
column: "ContentId"); |
|
290 |
|
|
291 |
migrationBuilder.CreateIndex( |
|
292 |
name: "IX_Documents_UserAddedId", |
|
293 |
table: "Documents", |
|
294 |
column: "UserAddedId"); |
|
295 |
|
|
296 |
migrationBuilder.CreateIndex( |
|
297 |
name: "IX_SubTags_TagId", |
|
298 |
table: "SubTags", |
|
299 |
column: "TagId"); |
|
300 |
|
|
301 |
migrationBuilder.CreateIndex( |
|
302 |
name: "IX_Tags_CategoryId", |
|
303 |
table: "Tags", |
|
304 |
column: "CategoryId"); |
|
305 |
} |
|
306 |
|
|
307 |
protected override void Down(MigrationBuilder migrationBuilder) |
|
308 |
{ |
|
309 |
migrationBuilder.DropTable( |
|
310 |
name: "AnnotationsClasses"); |
|
311 |
|
|
312 |
migrationBuilder.DropTable( |
|
313 |
name: "AnnotationTags"); |
|
314 |
|
|
315 |
migrationBuilder.DropTable( |
|
316 |
name: "Classes"); |
|
317 |
|
|
318 |
migrationBuilder.DropTable( |
|
319 |
name: "Annotations"); |
|
320 |
|
|
321 |
migrationBuilder.DropTable( |
|
322 |
name: "SubTags"); |
|
323 |
|
|
324 |
migrationBuilder.DropTable( |
|
325 |
name: "Documents"); |
|
326 |
|
|
327 |
migrationBuilder.DropTable( |
|
328 |
name: "Tags"); |
|
329 |
|
|
330 |
migrationBuilder.DropTable( |
|
331 |
name: "DocumentContents"); |
|
332 |
|
|
333 |
migrationBuilder.DropTable( |
|
334 |
name: "Users"); |
|
335 |
|
|
336 |
migrationBuilder.DropTable( |
|
337 |
name: "TagCategories"); |
|
338 |
} |
|
339 |
} |
|
340 |
} |
Backend/Backend/Migrations/20220330133755_v2.Designer.cs | ||
---|---|---|
1 |
// <auto-generated /> |
|
2 |
using System; |
|
3 |
using Core.Contexts; |
|
4 |
using Microsoft.EntityFrameworkCore; |
|
5 |
using Microsoft.EntityFrameworkCore.Infrastructure; |
|
6 |
using Microsoft.EntityFrameworkCore.Migrations; |
|
7 |
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
|
8 |
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; |
|
9 |
|
|
10 |
#nullable disable |
|
11 |
|
|
12 |
namespace RestAPI.Migrations |
|
13 |
{ |
|
14 |
[DbContext(typeof(DatabaseContext))] |
|
15 |
[Migration("20220330133755_v2")] |
|
16 |
partial class v2 |
|
17 |
{ |
|
18 |
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
|
19 |
{ |
|
20 |
#pragma warning disable 612, 618 |
|
21 |
modelBuilder |
|
22 |
.HasAnnotation("ProductVersion", "6.0.3") |
|
23 |
.HasAnnotation("Relational:MaxIdentifierLength", 63); |
|
24 |
|
|
25 |
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); |
|
26 |
|
|
27 |
modelBuilder.Entity("Core.Entities.Annotation", b => |
|
28 |
{ |
|
29 |
b.Property<int>("Id") |
|
30 |
.ValueGeneratedOnAdd() |
|
31 |
.HasColumnType("integer"); |
|
32 |
|
|
33 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
34 |
|
|
35 |
b.Property<DateTime>("DateAssigned") |
|
36 |
.HasColumnType("timestamp with time zone"); |
|
37 |
|
|
38 |
b.Property<DateTime>("DateLastChanged") |
|
39 |
.HasColumnType("timestamp with time zone"); |
|
40 |
|
|
41 |
b.Property<int>("DocumentId") |
|
42 |
.HasColumnType("integer"); |
|
43 |
|
|
44 |
b.Property<string>("Note") |
|
45 |
.IsRequired() |
|
46 |
.HasColumnType("text"); |
|
47 |
|
|
48 |
b.Property<int>("State") |
|
49 |
.HasColumnType("integer"); |
|
50 |
|
|
51 |
b.Property<int>("UserAssignedId") |
|
52 |
.HasColumnType("integer"); |
|
53 |
|
|
54 |
b.Property<int>("UserId") |
|
55 |
.HasColumnType("integer"); |
|
56 |
|
|
57 |
b.HasKey("Id"); |
|
58 |
|
|
59 |
b.HasIndex("DocumentId"); |
|
60 |
|
|
61 |
b.HasIndex("UserAssignedId"); |
|
62 |
|
|
63 |
b.HasIndex("UserId"); |
|
64 |
|
|
65 |
b.ToTable("Annotations"); |
|
66 |
}); |
|
67 |
|
|
68 |
modelBuilder.Entity("Core.Entities.AnnotationClass", b => |
|
69 |
{ |
|
70 |
b.Property<int>("Id") |
|
71 |
.ValueGeneratedOnAdd() |
|
72 |
.HasColumnType("integer"); |
|
73 |
|
|
74 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
75 |
|
|
76 |
b.Property<int>("AnnotationId") |
|
77 |
.HasColumnType("integer"); |
|
78 |
|
|
79 |
b.Property<int>("ClassId") |
|
80 |
.HasColumnType("integer"); |
|
81 |
|
|
82 |
b.HasKey("Id"); |
|
83 |
|
|
84 |
b.HasIndex("AnnotationId"); |
|
85 |
|
|
86 |
b.HasIndex("ClassId"); |
|
87 |
|
|
88 |
b.ToTable("AnnotationsClasses"); |
|
89 |
}); |
|
90 |
|
|
91 |
modelBuilder.Entity("Core.Entities.AnnotationTag", b => |
|
92 |
{ |
|
93 |
b.Property<int>("Id") |
|
94 |
.ValueGeneratedOnAdd() |
|
95 |
.HasColumnType("integer"); |
|
96 |
|
|
97 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
98 |
|
|
99 |
b.Property<int>("AnnotationId") |
|
100 |
.HasColumnType("integer"); |
|
101 |
|
|
102 |
b.Property<int>("Instance") |
|
103 |
.HasColumnType("integer"); |
|
104 |
|
|
105 |
b.Property<int>("Length") |
|
106 |
.HasColumnType("integer"); |
|
107 |
|
|
108 |
b.Property<string>("Note") |
|
109 |
.IsRequired() |
|
110 |
.HasColumnType("text"); |
|
111 |
|
|
112 |
b.Property<int>("Position") |
|
113 |
.HasColumnType("integer"); |
|
114 |
|
|
115 |
b.Property<int>("SubTagId") |
|
116 |
.HasColumnType("integer"); |
|
117 |
|
|
118 |
b.Property<int>("TagId") |
|
119 |
.HasColumnType("integer"); |
|
120 |
|
|
121 |
b.HasKey("Id"); |
|
122 |
|
|
123 |
b.HasIndex("AnnotationId"); |
|
124 |
|
|
125 |
b.HasIndex("SubTagId"); |
|
126 |
|
|
127 |
b.HasIndex("TagId"); |
|
128 |
|
|
129 |
b.ToTable("AnnotationTags"); |
|
130 |
}); |
|
131 |
|
|
132 |
modelBuilder.Entity("Core.Entities.Class", b => |
|
133 |
{ |
|
134 |
b.Property<int>("Id") |
|
135 |
.ValueGeneratedOnAdd() |
|
136 |
.HasColumnType("integer"); |
|
137 |
|
|
138 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
139 |
|
|
140 |
b.Property<string>("Color") |
|
141 |
.IsRequired() |
|
142 |
.HasColumnType("text"); |
|
143 |
|
|
144 |
b.Property<string>("Description") |
|
145 |
.IsRequired() |
|
146 |
.HasColumnType("text"); |
|
147 |
|
|
148 |
b.Property<string>("Name") |
|
149 |
.IsRequired() |
|
150 |
.HasColumnType("text"); |
|
151 |
|
|
152 |
b.HasKey("Id"); |
|
153 |
|
|
154 |
b.ToTable("Classes"); |
|
155 |
}); |
|
156 |
|
|
157 |
modelBuilder.Entity("Core.Entities.Document", b => |
|
158 |
{ |
|
159 |
b.Property<int>("Id") |
|
160 |
.ValueGeneratedOnAdd() |
|
161 |
.HasColumnType("integer"); |
|
162 |
|
|
163 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
164 |
|
|
165 |
b.Property<int>("ContentId") |
|
166 |
.HasColumnType("integer"); |
|
167 |
|
|
168 |
b.Property<DateTime>("DateAdded") |
|
169 |
.HasColumnType("timestamp with time zone"); |
|
170 |
|
|
171 |
b.Property<int>("Length") |
|
172 |
.HasColumnType("integer"); |
|
173 |
|
|
174 |
b.Property<string>("Name") |
|
175 |
.IsRequired() |
|
176 |
.HasColumnType("text"); |
|
177 |
|
|
178 |
b.Property<int>("RequiredAnnotations") |
|
179 |
.HasColumnType("integer"); |
|
180 |
|
|
181 |
b.Property<int>("UserAddedId") |
|
182 |
.HasColumnType("integer"); |
|
183 |
|
|
184 |
b.HasKey("Id"); |
|
185 |
|
|
186 |
b.HasIndex("ContentId"); |
|
187 |
|
|
188 |
b.HasIndex("UserAddedId"); |
|
189 |
|
|
190 |
b.ToTable("Documents"); |
|
191 |
}); |
|
192 |
|
|
193 |
modelBuilder.Entity("Core.Entities.DocumentContent", b => |
|
194 |
{ |
|
195 |
b.Property<int>("Id") |
|
196 |
.ValueGeneratedOnAdd() |
|
197 |
.HasColumnType("integer"); |
|
198 |
|
|
199 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
200 |
|
|
201 |
b.Property<string>("Content") |
|
202 |
.IsRequired() |
|
203 |
.HasColumnType("text"); |
|
204 |
|
|
205 |
b.HasKey("Id"); |
|
206 |
|
|
207 |
b.ToTable("DocumentContents"); |
|
208 |
}); |
|
209 |
|
|
210 |
modelBuilder.Entity("Core.Entities.SubTag", b => |
|
211 |
{ |
|
212 |
b.Property<int>("Id") |
|
213 |
.ValueGeneratedOnAdd() |
|
214 |
.HasColumnType("integer"); |
|
215 |
|
|
216 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
217 |
|
|
218 |
b.Property<string>("Description") |
|
219 |
.IsRequired() |
|
220 |
.HasColumnType("text"); |
|
221 |
|
|
222 |
b.Property<string>("Name") |
|
223 |
.IsRequired() |
|
224 |
.HasColumnType("text"); |
|
225 |
|
|
226 |
b.Property<int>("TagId") |
|
227 |
.HasColumnType("integer"); |
|
228 |
|
|
229 |
b.HasKey("Id"); |
|
230 |
|
|
231 |
b.HasIndex("TagId"); |
|
232 |
|
|
233 |
b.ToTable("SubTags"); |
|
234 |
}); |
|
235 |
|
|
236 |
modelBuilder.Entity("Core.Entities.Tag", b => |
|
237 |
{ |
|
238 |
b.Property<int>("Id") |
|
239 |
.ValueGeneratedOnAdd() |
|
240 |
.HasColumnType("integer"); |
|
241 |
|
|
242 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
243 |
|
|
244 |
b.Property<int>("CategoryId") |
|
245 |
.HasColumnType("integer"); |
|
246 |
|
|
247 |
b.Property<string>("Color") |
|
248 |
.IsRequired() |
|
249 |
.HasColumnType("text"); |
|
250 |
|
|
251 |
b.Property<string>("Description") |
|
252 |
.IsRequired() |
|
253 |
.HasColumnType("text"); |
|
254 |
|
|
255 |
b.Property<string>("Name") |
|
256 |
.IsRequired() |
|
257 |
.HasColumnType("text"); |
|
258 |
|
|
259 |
b.HasKey("Id"); |
|
260 |
|
|
261 |
b.HasIndex("CategoryId"); |
|
262 |
|
|
263 |
b.ToTable("Tags"); |
|
264 |
}); |
|
265 |
|
|
266 |
modelBuilder.Entity("Core.Entities.TagCategory", b => |
|
267 |
{ |
|
268 |
b.Property<int>("Id") |
|
269 |
.ValueGeneratedOnAdd() |
|
270 |
.HasColumnType("integer"); |
|
271 |
|
|
272 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
273 |
|
|
274 |
b.Property<string>("Color") |
|
275 |
.IsRequired() |
|
276 |
.HasColumnType("text"); |
|
277 |
|
|
278 |
b.Property<string>("Description") |
|
279 |
.IsRequired() |
|
280 |
.HasColumnType("text"); |
|
281 |
|
|
282 |
b.Property<string>("Name") |
|
283 |
.IsRequired() |
|
284 |
.HasColumnType("text"); |
|
285 |
|
|
286 |
b.HasKey("Id"); |
|
287 |
|
|
288 |
b.ToTable("TagCategories"); |
|
289 |
}); |
|
290 |
|
|
291 |
modelBuilder.Entity("Core.Entities.User", b => |
|
292 |
{ |
|
293 |
b.Property<int>("Id") |
|
294 |
.ValueGeneratedOnAdd() |
|
295 |
.HasColumnType("integer"); |
|
296 |
|
|
297 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
298 |
|
|
299 |
b.Property<string>("Name") |
|
300 |
.IsRequired() |
|
301 |
.HasColumnType("text"); |
|
302 |
|
|
303 |
b.Property<string>("Password") |
|
304 |
.IsRequired() |
|
305 |
.HasColumnType("text"); |
|
306 |
|
|
307 |
b.Property<int>("Role") |
|
308 |
.HasColumnType("integer"); |
|
309 |
|
|
310 |
b.Property<string>("Surname") |
|
311 |
.IsRequired() |
|
312 |
.HasColumnType("text"); |
|
313 |
|
|
314 |
b.Property<string>("Username") |
|
315 |
.IsRequired() |
|
316 |
.HasColumnType("text"); |
|
317 |
|
|
318 |
b.HasKey("Id"); |
|
319 |
|
|
320 |
b.ToTable("Users"); |
|
321 |
}); |
|
322 |
|
|
323 |
modelBuilder.Entity("Core.Entities.Annotation", b => |
|
324 |
{ |
|
325 |
b.HasOne("Core.Entities.Document", "Document") |
|
326 |
.WithMany() |
|
327 |
.HasForeignKey("DocumentId") |
|
328 |
.OnDelete(DeleteBehavior.Cascade) |
|
329 |
.IsRequired(); |
|
330 |
|
|
331 |
b.HasOne("Core.Entities.User", "UserAssigned") |
|
332 |
.WithMany() |
|
333 |
.HasForeignKey("UserAssignedId") |
|
334 |
.OnDelete(DeleteBehavior.Cascade) |
|
335 |
.IsRequired(); |
|
336 |
|
|
337 |
b.HasOne("Core.Entities.User", "User") |
|
338 |
.WithMany() |
|
339 |
.HasForeignKey("UserId") |
|
340 |
.OnDelete(DeleteBehavior.Cascade) |
|
341 |
.IsRequired(); |
|
342 |
|
|
343 |
b.Navigation("Document"); |
|
344 |
|
|
345 |
b.Navigation("User"); |
|
346 |
|
|
347 |
b.Navigation("UserAssigned"); |
|
348 |
}); |
|
349 |
|
|
350 |
modelBuilder.Entity("Core.Entities.AnnotationClass", b => |
|
351 |
{ |
|
352 |
b.HasOne("Core.Entities.Annotation", "Annotation") |
|
353 |
.WithMany("Classes") |
|
354 |
.HasForeignKey("AnnotationId") |
|
355 |
.OnDelete(DeleteBehavior.Cascade) |
|
356 |
.IsRequired(); |
|
357 |
|
|
358 |
b.HasOne("Core.Entities.Class", "Class") |
|
359 |
.WithMany("Annotations") |
|
360 |
.HasForeignKey("ClassId") |
|
361 |
.OnDelete(DeleteBehavior.Cascade) |
|
362 |
.IsRequired(); |
|
363 |
|
|
364 |
b.Navigation("Annotation"); |
|
365 |
|
|
366 |
b.Navigation("Class"); |
|
367 |
}); |
|
368 |
|
|
369 |
modelBuilder.Entity("Core.Entities.AnnotationTag", b => |
|
370 |
{ |
|
371 |
b.HasOne("Core.Entities.Annotation", "Annotation") |
|
372 |
.WithMany() |
|
373 |
.HasForeignKey("AnnotationId") |
|
374 |
.OnDelete(DeleteBehavior.Cascade) |
|
375 |
.IsRequired(); |
|
376 |
|
|
377 |
b.HasOne("Core.Entities.SubTag", "SubTag") |
|
378 |
.WithMany() |
|
379 |
.HasForeignKey("SubTagId") |
|
380 |
.OnDelete(DeleteBehavior.Cascade) |
|
381 |
.IsRequired(); |
|
382 |
|
|
383 |
b.HasOne("Core.Entities.Tag", "Tag") |
|
384 |
.WithMany() |
|
385 |
.HasForeignKey("TagId") |
|
386 |
.OnDelete(DeleteBehavior.Cascade) |
|
387 |
.IsRequired(); |
|
388 |
|
|
389 |
b.Navigation("Annotation"); |
|
390 |
|
|
391 |
b.Navigation("SubTag"); |
|
392 |
|
|
393 |
b.Navigation("Tag"); |
|
394 |
}); |
|
395 |
|
|
396 |
modelBuilder.Entity("Core.Entities.Document", b => |
|
397 |
{ |
|
398 |
b.HasOne("Core.Entities.DocumentContent", "Content") |
|
399 |
.WithMany() |
|
400 |
.HasForeignKey("ContentId") |
|
401 |
.OnDelete(DeleteBehavior.Cascade) |
|
402 |
.IsRequired(); |
|
403 |
|
|
404 |
b.HasOne("Core.Entities.User", "UserAdded") |
|
405 |
.WithMany() |
|
406 |
.HasForeignKey("UserAddedId") |
|
407 |
.OnDelete(DeleteBehavior.Cascade) |
|
408 |
.IsRequired(); |
|
409 |
|
|
410 |
b.Navigation("Content"); |
|
411 |
|
|
412 |
b.Navigation("UserAdded"); |
|
413 |
}); |
|
414 |
|
|
415 |
modelBuilder.Entity("Core.Entities.SubTag", b => |
|
416 |
{ |
|
417 |
b.HasOne("Core.Entities.Tag", "Tag") |
|
418 |
.WithMany() |
|
419 |
.HasForeignKey("TagId") |
|
420 |
.OnDelete(DeleteBehavior.Cascade) |
|
421 |
.IsRequired(); |
|
422 |
|
|
423 |
b.Navigation("Tag"); |
|
424 |
}); |
|
425 |
|
|
426 |
modelBuilder.Entity("Core.Entities.Tag", b => |
|
427 |
{ |
|
428 |
b.HasOne("Core.Entities.TagCategory", "Category") |
|
429 |
.WithMany() |
|
430 |
.HasForeignKey("CategoryId") |
|
431 |
.OnDelete(DeleteBehavior.Cascade) |
|
432 |
.IsRequired(); |
|
433 |
|
|
434 |
b.Navigation("Category"); |
|
435 |
}); |
|
436 |
|
|
437 |
modelBuilder.Entity("Core.Entities.Annotation", b => |
|
438 |
{ |
|
439 |
b.Navigation("Classes"); |
|
440 |
}); |
|
441 |
|
|
442 |
modelBuilder.Entity("Core.Entities.Class", b => |
|
443 |
{ |
|
444 |
b.Navigation("Annotations"); |
|
445 |
}); |
|
446 |
#pragma warning restore 612, 618 |
|
447 |
} |
|
448 |
} |
|
449 |
} |
Backend/Backend/Migrations/20220330133755_v2.cs | ||
---|---|---|
1 |
using Microsoft.EntityFrameworkCore.Migrations; |
|
2 |
|
|
3 |
#nullable disable |
|
4 |
|
|
5 |
namespace RestAPI.Migrations |
|
6 |
{ |
|
7 |
public partial class v2 : Migration |
|
8 |
{ |
|
9 |
protected override void Up(MigrationBuilder migrationBuilder) |
|
10 |
{ |
|
11 |
|
|
12 |
} |
|
13 |
|
|
14 |
protected override void Down(MigrationBuilder migrationBuilder) |
|
15 |
{ |
|
16 |
|
|
17 |
} |
|
18 |
} |
|
19 |
} |
Backend/Backend/Migrations/20220330134820_v3.Designer.cs | ||
---|---|---|
1 |
// <auto-generated /> |
|
2 |
using System; |
|
3 |
using Core.Contexts; |
|
4 |
using Microsoft.EntityFrameworkCore; |
|
5 |
using Microsoft.EntityFrameworkCore.Infrastructure; |
|
6 |
using Microsoft.EntityFrameworkCore.Migrations; |
|
7 |
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
|
8 |
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; |
|
9 |
|
|
10 |
#nullable disable |
|
11 |
|
|
12 |
namespace RestAPI.Migrations |
|
13 |
{ |
|
14 |
[DbContext(typeof(DatabaseContext))] |
|
15 |
[Migration("20220330134820_v3")] |
|
16 |
partial class v3 |
|
17 |
{ |
|
18 |
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
|
19 |
{ |
|
20 |
#pragma warning disable 612, 618 |
|
21 |
modelBuilder |
|
22 |
.HasAnnotation("ProductVersion", "6.0.3") |
|
23 |
.HasAnnotation("Relational:MaxIdentifierLength", 63); |
|
24 |
|
|
25 |
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); |
|
26 |
|
|
27 |
modelBuilder.Entity("AnnotationClass", b => |
|
28 |
{ |
|
29 |
b.Property<int>("AnnotationsId") |
|
30 |
.HasColumnType("integer"); |
|
31 |
|
|
32 |
b.Property<int>("ClassesId") |
|
33 |
.HasColumnType("integer"); |
|
34 |
|
|
35 |
b.HasKey("AnnotationsId", "ClassesId"); |
|
36 |
|
|
37 |
b.HasIndex("ClassesId"); |
|
38 |
|
|
39 |
b.ToTable("AnnotationClass"); |
|
40 |
}); |
|
41 |
|
|
42 |
modelBuilder.Entity("Core.Entities.Annotation", b => |
|
43 |
{ |
|
44 |
b.Property<int>("Id") |
|
45 |
.ValueGeneratedOnAdd() |
|
46 |
.HasColumnType("integer"); |
|
47 |
|
|
48 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
49 |
|
|
50 |
b.Property<DateTime>("DateAssigned") |
|
51 |
.HasColumnType("timestamp with time zone"); |
|
52 |
|
|
53 |
b.Property<DateTime>("DateLastChanged") |
|
54 |
.HasColumnType("timestamp with time zone"); |
|
55 |
|
|
56 |
b.Property<int>("DocumentId") |
|
57 |
.HasColumnType("integer"); |
|
58 |
|
|
59 |
b.Property<string>("Note") |
|
60 |
.IsRequired() |
|
61 |
.HasColumnType("text"); |
|
62 |
|
|
63 |
b.Property<int>("State") |
|
64 |
.HasColumnType("integer"); |
|
65 |
|
|
66 |
b.Property<int>("UserAssignedId") |
|
67 |
.HasColumnType("integer"); |
|
68 |
|
|
69 |
b.Property<int>("UserId") |
|
70 |
.HasColumnType("integer"); |
|
71 |
|
|
72 |
b.HasKey("Id"); |
|
73 |
|
|
74 |
b.HasIndex("DocumentId"); |
|
75 |
|
|
76 |
b.HasIndex("UserAssignedId"); |
|
77 |
|
|
78 |
b.HasIndex("UserId"); |
|
79 |
|
|
80 |
b.ToTable("Annotations"); |
|
81 |
}); |
|
82 |
|
|
83 |
modelBuilder.Entity("Core.Entities.AnnotationTag", b => |
|
84 |
{ |
|
85 |
b.Property<int>("Id") |
|
86 |
.ValueGeneratedOnAdd() |
|
87 |
.HasColumnType("integer"); |
|
88 |
|
|
89 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
90 |
|
|
91 |
b.Property<int>("AnnotationId") |
|
92 |
.HasColumnType("integer"); |
|
93 |
|
|
94 |
b.Property<int>("Instance") |
|
95 |
.HasColumnType("integer"); |
|
96 |
|
|
97 |
b.Property<int>("Length") |
|
98 |
.HasColumnType("integer"); |
|
99 |
|
|
100 |
b.Property<string>("Note") |
|
101 |
.IsRequired() |
|
102 |
.HasColumnType("text"); |
|
103 |
|
|
104 |
b.Property<int>("Position") |
|
105 |
.HasColumnType("integer"); |
|
106 |
|
|
107 |
b.Property<int>("SubTagId") |
|
108 |
.HasColumnType("integer"); |
|
109 |
|
|
110 |
b.Property<int>("TagId") |
|
111 |
.HasColumnType("integer"); |
|
112 |
|
|
113 |
b.HasKey("Id"); |
|
114 |
|
|
115 |
b.HasIndex("AnnotationId"); |
|
116 |
|
|
117 |
b.HasIndex("SubTagId"); |
|
118 |
|
|
119 |
b.HasIndex("TagId"); |
|
120 |
|
|
121 |
b.ToTable("AnnotationTags"); |
|
122 |
}); |
|
123 |
|
|
124 |
modelBuilder.Entity("Core.Entities.Class", b => |
|
125 |
{ |
|
126 |
b.Property<int>("Id") |
|
127 |
.ValueGeneratedOnAdd() |
|
128 |
.HasColumnType("integer"); |
|
129 |
|
|
130 |
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|
131 |
|
|
132 |
b.Property<string>("Color") |
|
133 |
.IsRequired() |
|
134 |
.HasColumnType("text"); |
|
135 |
|
|
136 |
b.Property<string>("Description") |
|
137 |
.IsRequired() |
Také k dispozici: Unified diff
Version 1 working state of DB and EF with integer IDs