#7 adding database migration

This commit is contained in:
Hamid Reza Mohammadi 2020-09-13 21:15:05 +04:30
parent 00e83f6b5f
commit 627eb832bc
4 changed files with 1660 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,115 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace RMuseum.Migrations
{
public partial class UploadNarration : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "UploadSessions",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
SessionType = table.Column<int>(nullable: false),
UserId = table.Column<Guid>(nullable: true),
UseId = table.Column<Guid>(nullable: false),
UploadStartTime = table.Column<DateTime>(nullable: false),
UploadEndTime = table.Column<DateTime>(nullable: false),
ProcessStartTime = table.Column<DateTime>(nullable: false),
ProcessEndTime = table.Column<DateTime>(nullable: false),
ProcessProgress = table.Column<int>(nullable: false),
Status = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UploadSessions", x => x.Id);
table.ForeignKey(
name: "FK_UploadSessions_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "UserNarrationProfiles",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
UserId = table.Column<Guid>(nullable: false),
FileSuffixWithoutDash = table.Column<string>(nullable: true),
ArtistName = table.Column<string>(nullable: true),
ArtistUrl = table.Column<string>(nullable: true),
AudioSrc = table.Column<string>(nullable: true),
AudioSrcUrl = table.Column<string>(nullable: true),
IsDefault = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserNarrationProfiles", x => x.Id);
table.ForeignKey(
name: "FK_UserNarrationProfiles_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "UploadSessionFile",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
ContentDisposition = table.Column<string>(nullable: true),
ContentType = table.Column<string>(nullable: true),
FileName = table.Column<string>(nullable: true),
Length = table.Column<long>(nullable: false),
Name = table.Column<string>(nullable: true),
FilePath = table.Column<string>(nullable: true),
MP3FileCheckSum = table.Column<string>(nullable: true),
ProcessResult = table.Column<bool>(nullable: false),
ProcessResultMsg = table.Column<string>(nullable: true),
UploadSessionId = table.Column<Guid>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_UploadSessionFile", x => x.Id);
table.ForeignKey(
name: "FK_UploadSessionFile_UploadSessions_UploadSessionId",
column: x => x.UploadSessionId,
principalTable: "UploadSessions",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_UploadSessionFile_UploadSessionId",
table: "UploadSessionFile",
column: "UploadSessionId");
migrationBuilder.CreateIndex(
name: "IX_UploadSessions_UserId",
table: "UploadSessions",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_UserNarrationProfiles_UserId",
table: "UserNarrationProfiles",
column: "UserId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "UploadSessionFile");
migrationBuilder.DropTable(
name: "UserNarrationProfiles");
migrationBuilder.DropTable(
name: "UploadSessions");
}
}
}

View File

@ -412,6 +412,40 @@ namespace RMuseum.Migrations
b.ToTable("AudioFiles");
});
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.UserNarrationProfile", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("ArtistName")
.HasColumnType("nvarchar(max)");
b.Property<string>("ArtistUrl")
.HasColumnType("nvarchar(max)");
b.Property<string>("AudioSrc")
.HasColumnType("nvarchar(max)");
b.Property<string>("AudioSrcUrl")
.HasColumnType("nvarchar(max)");
b.Property<string>("FileSuffixWithoutDash")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDefault")
.HasColumnType("bit");
b.Property<Guid>("UserId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("UserNarrationProfiles");
});
modelBuilder.Entity("RMuseum.Models.GanjoorIntegration.GanjoorLink", b =>
{
b.Property<Guid>("Id")
@ -657,6 +691,89 @@ namespace RMuseum.Migrations
b.ToTable("Notifications");
});
modelBuilder.Entity("RMuseum.Models.UploadSession.UploadSession", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("ProcessEndTime")
.HasColumnType("datetime2");
b.Property<int>("ProcessProgress")
.HasColumnType("int");
b.Property<DateTime>("ProcessStartTime")
.HasColumnType("datetime2");
b.Property<int>("SessionType")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<DateTime>("UploadEndTime")
.HasColumnType("datetime2");
b.Property<DateTime>("UploadStartTime")
.HasColumnType("datetime2");
b.Property<Guid>("UseId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("UserId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("UploadSessions");
});
modelBuilder.Entity("RMuseum.Models.UploadSession.UploadSessionFile", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("ContentDisposition")
.HasColumnType("nvarchar(max)");
b.Property<string>("ContentType")
.HasColumnType("nvarchar(max)");
b.Property<string>("FileName")
.HasColumnType("nvarchar(max)");
b.Property<string>("FilePath")
.HasColumnType("nvarchar(max)");
b.Property<long>("Length")
.HasColumnType("bigint");
b.Property<string>("MP3FileCheckSum")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<bool>("ProcessResult")
.HasColumnType("bit");
b.Property<string>("ProcessResultMsg")
.HasColumnType("nvarchar(max)");
b.Property<Guid?>("UploadSessionId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("UploadSessionId");
b.ToTable("UploadSessionFile");
});
modelBuilder.Entity("RSecurityBackend.Models.Audit.Db.REvent", b =>
{
b.Property<Guid>("Id")
@ -1139,6 +1256,15 @@ namespace RMuseum.Migrations
.IsRequired();
});
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.UserNarrationProfile", b =>
{
b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("RMuseum.Models.GanjoorIntegration.GanjoorLink", b =>
{
b.HasOne("RMuseum.Models.Artifact.RArtifactMasterRecord", "Artifact")
@ -1218,6 +1344,20 @@ namespace RMuseum.Migrations
.IsRequired();
});
modelBuilder.Entity("RMuseum.Models.UploadSession.UploadSession", b =>
{
b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", "User")
.WithMany()
.HasForeignKey("UserId");
});
modelBuilder.Entity("RMuseum.Models.UploadSession.UploadSessionFile", b =>
{
b.HasOne("RMuseum.Models.UploadSession.UploadSession", null)
.WithMany("UploadedFiles")
.HasForeignKey("UploadSessionId");
});
modelBuilder.Entity("RSecurityBackend.Models.Auth.Db.RAppUser", b =>
{
b.HasOne("RSecurityBackend.Models.Image.RImage", "RImage")

View File

@ -299,7 +299,7 @@ namespace RMuseum.Services.Implementation
foreach (PoemAudio audio in PoemAudioListProcessor.Load(file.FilePath))
{
string soundFilesFolder = Configuration.GetSection("AudioUploadService")["StoragePath"];
string targetPathForAudioFiles = Path.Combine(Configuration.GetSection("LocalAudioRepositoryPath")["StoragePath"], Configuration.GetSection("AudioUploadService")["StoragePath"]);
string targetPathForAudioFiles = Path.Combine(Configuration.GetSection("AudioUploadService")["LocalAudioRepositoryPath"], Configuration.GetSection("AudioUploadService")["StoragePath"]);
if (!Directory.Exists(targetPathForAudioFiles))
{
Directory.CreateDirectory(targetPathForAudioFiles);