Add Surah/Ayah browse with Gharaati Tafsir Noor crawl.
build-and-deploy / deploy (push) Failing after 11m0s

Replace episode bookmarks with surah/ayah bookmarks and ayah favorites;
import ayah text, notes, messages, and official per-ayah audio from gharaati.ir.
This commit is contained in:
2026-10-10 00:24:02 +03:30
parent d8189fab9e
commit 9309a1e6de
25 changed files with 2340 additions and 363 deletions
@@ -0,0 +1,422 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TafsirQuran.Infrastructure.Persistence.Migrations
{
/// <inheritdoc />
public partial class AyahBrowseAndGharaati : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ListeningProgresses_Episodes_EpisodeId",
table: "ListeningProgresses");
migrationBuilder.DropTable(
name: "Bookmarks");
migrationBuilder.DropTable(
name: "Favorites");
migrationBuilder.RenameColumn(
name: "EpisodeId",
table: "ListeningProgresses",
newName: "TafsirId");
migrationBuilder.RenameIndex(
name: "IX_ListeningProgresses_EpisodeId",
table: "ListeningProgresses",
newName: "IX_ListeningProgresses_TafsirId");
migrationBuilder.AddColumn<int>(
name: "AyahNumber",
table: "ListeningProgresses",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "SurahId",
table: "ListeningProgresses",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "AyahBookmarks",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
DeviceId = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
TafsirId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
SurahId = table.Column<int>(type: "int", nullable: false),
AyahNumber = table.Column<int>(type: "int", nullable: false),
Note = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AyahBookmarks", x => x.Id);
table.ForeignKey(
name: "FK_AyahBookmarks_Surahs_SurahId",
column: x => x.SurahId,
principalTable: "Surahs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AyahBookmarks_Tafsirs_TafsirId",
column: x => x.TafsirId,
principalTable: "Tafsirs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AyahBookmarks_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "AyahFavorites",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
DeviceId = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
TafsirId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
SurahId = table.Column<int>(type: "int", nullable: false),
AyahNumber = table.Column<int>(type: "int", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AyahFavorites", x => x.Id);
table.ForeignKey(
name: "FK_AyahFavorites_Surahs_SurahId",
column: x => x.SurahId,
principalTable: "Surahs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AyahFavorites_Tafsirs_TafsirId",
column: x => x.TafsirId,
principalTable: "Tafsirs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AyahFavorites_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "SurahBookmarks",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
DeviceId = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
TafsirId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
SurahId = table.Column<int>(type: "int", nullable: false),
Note = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SurahBookmarks", x => x.Id);
table.ForeignKey(
name: "FK_SurahBookmarks_Surahs_SurahId",
column: x => x.SurahId,
principalTable: "Surahs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_SurahBookmarks_Tafsirs_TafsirId",
column: x => x.TafsirId,
principalTable: "Tafsirs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_SurahBookmarks_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "TafsirAyahContents",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TafsirId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
SurahId = table.Column<int>(type: "int", nullable: false),
AyahNumber = table.Column<int>(type: "int", nullable: false),
NotesHtml = table.Column<string>(type: "nvarchar(max)", nullable: true),
MessagesHtml = table.Column<string>(type: "nvarchar(max)", nullable: true),
VideoEmbedUrl = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
AudioPath = table.Column<string>(type: "nvarchar(400)", maxLength: 400, nullable: true),
UpdatedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TafsirAyahContents", x => x.Id);
table.ForeignKey(
name: "FK_TafsirAyahContents_Surahs_SurahId",
column: x => x.SurahId,
principalTable: "Surahs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TafsirAyahContents_Tafsirs_TafsirId",
column: x => x.TafsirId,
principalTable: "Tafsirs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_ListeningProgresses_SurahId",
table: "ListeningProgresses",
column: "SurahId");
migrationBuilder.CreateIndex(
name: "IX_AyahBookmarks_DeviceId_UserId_TafsirId_SurahId_AyahNumber",
table: "AyahBookmarks",
columns: new[] { "DeviceId", "UserId", "TafsirId", "SurahId", "AyahNumber" },
unique: true,
filter: "[UserId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_AyahBookmarks_SurahId",
table: "AyahBookmarks",
column: "SurahId");
migrationBuilder.CreateIndex(
name: "IX_AyahBookmarks_TafsirId",
table: "AyahBookmarks",
column: "TafsirId");
migrationBuilder.CreateIndex(
name: "IX_AyahBookmarks_UserId",
table: "AyahBookmarks",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AyahFavorites_DeviceId_UserId_TafsirId_SurahId_AyahNumber",
table: "AyahFavorites",
columns: new[] { "DeviceId", "UserId", "TafsirId", "SurahId", "AyahNumber" },
unique: true,
filter: "[UserId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_AyahFavorites_SurahId",
table: "AyahFavorites",
column: "SurahId");
migrationBuilder.CreateIndex(
name: "IX_AyahFavorites_TafsirId",
table: "AyahFavorites",
column: "TafsirId");
migrationBuilder.CreateIndex(
name: "IX_AyahFavorites_UserId",
table: "AyahFavorites",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_SurahBookmarks_DeviceId_UserId_TafsirId_SurahId",
table: "SurahBookmarks",
columns: new[] { "DeviceId", "UserId", "TafsirId", "SurahId" },
unique: true,
filter: "[UserId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_SurahBookmarks_SurahId",
table: "SurahBookmarks",
column: "SurahId");
migrationBuilder.CreateIndex(
name: "IX_SurahBookmarks_TafsirId",
table: "SurahBookmarks",
column: "TafsirId");
migrationBuilder.CreateIndex(
name: "IX_SurahBookmarks_UserId",
table: "SurahBookmarks",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_TafsirAyahContents_SurahId",
table: "TafsirAyahContents",
column: "SurahId");
migrationBuilder.CreateIndex(
name: "IX_TafsirAyahContents_TafsirId_SurahId_AyahNumber",
table: "TafsirAyahContents",
columns: new[] { "TafsirId", "SurahId", "AyahNumber" },
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_ListeningProgresses_Surahs_SurahId",
table: "ListeningProgresses",
column: "SurahId",
principalTable: "Surahs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_ListeningProgresses_Tafsirs_TafsirId",
table: "ListeningProgresses",
column: "TafsirId",
principalTable: "Tafsirs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ListeningProgresses_Surahs_SurahId",
table: "ListeningProgresses");
migrationBuilder.DropForeignKey(
name: "FK_ListeningProgresses_Tafsirs_TafsirId",
table: "ListeningProgresses");
migrationBuilder.DropTable(
name: "AyahBookmarks");
migrationBuilder.DropTable(
name: "AyahFavorites");
migrationBuilder.DropTable(
name: "SurahBookmarks");
migrationBuilder.DropTable(
name: "TafsirAyahContents");
migrationBuilder.DropIndex(
name: "IX_ListeningProgresses_SurahId",
table: "ListeningProgresses");
migrationBuilder.DropColumn(
name: "AyahNumber",
table: "ListeningProgresses");
migrationBuilder.DropColumn(
name: "SurahId",
table: "ListeningProgresses");
migrationBuilder.RenameColumn(
name: "TafsirId",
table: "ListeningProgresses",
newName: "EpisodeId");
migrationBuilder.RenameIndex(
name: "IX_ListeningProgresses_TafsirId",
table: "ListeningProgresses",
newName: "IX_ListeningProgresses_EpisodeId");
migrationBuilder.CreateTable(
name: "Bookmarks",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
EpisodeId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
DeviceId = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
Note = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Bookmarks", x => x.Id);
table.ForeignKey(
name: "FK_Bookmarks_Episodes_EpisodeId",
column: x => x.EpisodeId,
principalTable: "Episodes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Bookmarks_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Favorites",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
EpisodeId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
DeviceId = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Favorites", x => x.Id);
table.ForeignKey(
name: "FK_Favorites_Episodes_EpisodeId",
column: x => x.EpisodeId,
principalTable: "Episodes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Favorites_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_Bookmarks_DeviceId_UserId_EpisodeId",
table: "Bookmarks",
columns: new[] { "DeviceId", "UserId", "EpisodeId" },
unique: true,
filter: "[UserId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_Bookmarks_EpisodeId",
table: "Bookmarks",
column: "EpisodeId");
migrationBuilder.CreateIndex(
name: "IX_Bookmarks_UserId",
table: "Bookmarks",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Favorites_DeviceId_UserId_EpisodeId",
table: "Favorites",
columns: new[] { "DeviceId", "UserId", "EpisodeId" },
unique: true,
filter: "[UserId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_Favorites_EpisodeId",
table: "Favorites",
column: "EpisodeId");
migrationBuilder.CreateIndex(
name: "IX_Favorites_UserId",
table: "Favorites",
column: "UserId");
migrationBuilder.AddForeignKey(
name: "FK_ListeningProgresses_Episodes_EpisodeId",
table: "ListeningProgresses",
column: "EpisodeId",
principalTable: "Episodes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}