#272 adding db migration
This commit is contained in:
parent
1e5867eeee
commit
76a5214146
3671
RMuseum/Migrations/20220108165707_UserVisitsModel.Designer.cs
generated
Normal file
3671
RMuseum/Migrations/20220108165707_UserVisitsModel.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
54
RMuseum/Migrations/20220108165707_UserVisitsModel.cs
Normal file
54
RMuseum/Migrations/20220108165707_UserVisitsModel.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace RMuseum.Migrations
|
||||
{
|
||||
public partial class UserVisitsModel : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "GanjoorUserPoemVisits",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
PoemId = table.Column<int>(type: "int", nullable: false),
|
||||
DateTime = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_GanjoorUserPoemVisits", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_GanjoorUserPoemVisits_AspNetUsers_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "AspNetUsers",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_GanjoorUserPoemVisits_GanjoorPoems_PoemId",
|
||||
column: x => x.PoemId,
|
||||
principalTable: "GanjoorPoems",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_GanjoorUserPoemVisits_PoemId",
|
||||
table: "GanjoorUserPoemVisits",
|
||||
column: "PoemId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_GanjoorUserPoemVisits_UserId",
|
||||
table: "GanjoorUserPoemVisits",
|
||||
column: "UserId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "GanjoorUserPoemVisits");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17,7 +17,7 @@ namespace RMuseum.Migrations
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "6.0.0")
|
||||
.HasAnnotation("ProductVersion", "6.0.1")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
|
||||
@ -1237,6 +1237,30 @@ namespace RMuseum.Migrations
|
||||
b.ToTable("GanjoorUserBookmarks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorUserPoemVisit", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("DateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("PoemId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<Guid?>("UserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PoemId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("GanjoorUserPoemVisits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorVerse", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -3130,6 +3154,23 @@ namespace RMuseum.Migrations
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorUserPoemVisit", b =>
|
||||
{
|
||||
b.HasOne("RMuseum.Models.Ganjoor.GanjoorPoem", "Poem")
|
||||
.WithMany()
|
||||
.HasForeignKey("PoemId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId");
|
||||
|
||||
b.Navigation("Poem");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorVerse", b =>
|
||||
{
|
||||
b.HasOne("RMuseum.Models.Ganjoor.GanjoorPoem", "Poem")
|
||||
|
||||
@ -2410,6 +2410,11 @@
|
||||
probable metres
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.DbContext.RMuseumDbContext.GanjoorUserPoemVisits">
|
||||
<summary>
|
||||
ganjoor user history track items (stored by his or her choice)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.Accounting.DonationExpenditure">
|
||||
<summary>
|
||||
donation expenditures
|
||||
@ -6120,41 +6125,6 @@
|
||||
comments
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.Ganjoor.GanjoorPoemVisit">
|
||||
<summary>
|
||||
ganjoor user history track item (by his or her choice)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.GanjoorPoemVisit.Id">
|
||||
<summary>
|
||||
id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.GanjoorPoemVisit.UserId">
|
||||
<summary>
|
||||
user id (nullable to prevent a db cascade relation)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.GanjoorPoemVisit.User">
|
||||
<summary>
|
||||
user
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.GanjoorPoemVisit.PoemId">
|
||||
<summary>
|
||||
poem id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.GanjoorPoemVisit.Poem">
|
||||
<summary>
|
||||
poem
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.GanjoorPoemVisit.DateTime">
|
||||
<summary>
|
||||
date/time
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.Ganjoor.GanjoorPoet">
|
||||
<summary>
|
||||
Ganjoor Poet
|
||||
@ -6337,6 +6307,41 @@
|
||||
DateTime
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.Ganjoor.GanjoorUserPoemVisit">
|
||||
<summary>
|
||||
ganjoor user history track item (stored by his or her choice)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.GanjoorUserPoemVisit.Id">
|
||||
<summary>
|
||||
id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.GanjoorUserPoemVisit.UserId">
|
||||
<summary>
|
||||
user id (nullable to prevent a db cascade relation)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.GanjoorUserPoemVisit.User">
|
||||
<summary>
|
||||
user
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.GanjoorUserPoemVisit.PoemId">
|
||||
<summary>
|
||||
poem id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.GanjoorUserPoemVisit.Poem">
|
||||
<summary>
|
||||
poem
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.GanjoorUserPoemVisit.DateTime">
|
||||
<summary>
|
||||
date/time
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.Ganjoor.GanjoorVerse">
|
||||
<summary>
|
||||
Ganjoor Verse
|
||||
|
||||
@ -377,8 +377,10 @@ namespace RMuseum.Services.Implementation
|
||||
|
||||
await context.SaveChangesAsync();
|
||||
|
||||
|
||||
|
||||
var visits = await context.GanjoorUserPoemVisits.Where(v => v.UserId == userId).ToListAsync();
|
||||
context.RemoveRange(visits);
|
||||
await context.SaveChangesAsync();
|
||||
|
||||
var bookmarks = await context.UserBookmarks.Where(b => b.RAppUserId == userId).ToListAsync();
|
||||
context.RemoveRange(bookmarks);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user