feat: edit print templates on the printer page and store them on presets
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using Data;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20260903010000_PrintPresetTemplateMarkdown")]
|
||||
public partial class PrintPresetTemplateMarkdown : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "TemplateMarkdown",
|
||||
table: "PrintPresets",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.Sql(
|
||||
"""
|
||||
UPDATE PrintPresets
|
||||
SET TemplateMarkdown = COALESCE(
|
||||
(SELECT Content FROM Notes WHERE Notes.Id = PrintPresets.NoteId),
|
||||
''
|
||||
);
|
||||
""");
|
||||
|
||||
migrationBuilder.Sql(
|
||||
"""
|
||||
CREATE TABLE "PrintPresets_new" (
|
||||
"Id" INTEGER NOT NULL CONSTRAINT "PK_PrintPresets" PRIMARY KEY AUTOINCREMENT,
|
||||
"Name" TEXT NOT NULL,
|
||||
"TemplateMarkdown" TEXT NOT NULL,
|
||||
"EntityType" TEXT NOT NULL,
|
||||
"FiltersJson" TEXT NOT NULL,
|
||||
"UpdatedAt" TEXT NOT NULL
|
||||
);
|
||||
""");
|
||||
|
||||
migrationBuilder.Sql(
|
||||
"""
|
||||
INSERT INTO "PrintPresets_new" ("Id", "Name", "TemplateMarkdown", "EntityType", "FiltersJson", "UpdatedAt")
|
||||
SELECT "Id", "Name", "TemplateMarkdown", "EntityType", "FiltersJson", "UpdatedAt"
|
||||
FROM "PrintPresets";
|
||||
""");
|
||||
|
||||
migrationBuilder.Sql("""DROP TABLE "PrintPresets";""");
|
||||
migrationBuilder.Sql("""ALTER TABLE "PrintPresets_new" RENAME TO "PrintPresets";""");
|
||||
migrationBuilder.Sql(
|
||||
"""CREATE UNIQUE INDEX "IX_PrintPresets_Name" ON "PrintPresets" ("Name");""");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql(
|
||||
"""
|
||||
CREATE TABLE "PrintPresets_old" (
|
||||
"Id" INTEGER NOT NULL CONSTRAINT "PK_PrintPresets" PRIMARY KEY AUTOINCREMENT,
|
||||
"Name" TEXT NOT NULL,
|
||||
"NoteId" INTEGER NOT NULL,
|
||||
"EntityType" TEXT NOT NULL,
|
||||
"FiltersJson" TEXT NOT NULL,
|
||||
"UpdatedAt" TEXT NOT NULL
|
||||
);
|
||||
""");
|
||||
|
||||
migrationBuilder.Sql(
|
||||
"""
|
||||
INSERT INTO "PrintPresets_old" ("Id", "Name", "NoteId", "EntityType", "FiltersJson", "UpdatedAt")
|
||||
SELECT "Id", "Name", 0, "EntityType", "FiltersJson", "UpdatedAt"
|
||||
FROM "PrintPresets";
|
||||
""");
|
||||
|
||||
migrationBuilder.Sql("""DROP TABLE "PrintPresets";""");
|
||||
migrationBuilder.Sql("""ALTER TABLE "PrintPresets_old" RENAME TO "PrintPresets";""");
|
||||
migrationBuilder.Sql(
|
||||
"""CREATE UNIQUE INDEX "IX_PrintPresets_Name" ON "PrintPresets" ("Name");""");
|
||||
migrationBuilder.Sql(
|
||||
"""CREATE INDEX "IX_PrintPresets_NoteId" ON "PrintPresets" ("NoteId");""");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,8 +197,9 @@ namespace Data.Migrations
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("NoteId")
|
||||
.HasColumnType("INTEGER");
|
||||
b.Property<string>("TemplateMarkdown")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
@@ -208,8 +209,6 @@ namespace Data.Migrations
|
||||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("NoteId");
|
||||
|
||||
b.ToTable("PrintPresets");
|
||||
});
|
||||
|
||||
@@ -503,17 +502,6 @@ namespace Data.Migrations
|
||||
b.Navigation("Note");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Core.Entities.PrintPreset", b =>
|
||||
{
|
||||
b.HasOne("Core.Entities.Note", "Note")
|
||||
.WithMany()
|
||||
.HasForeignKey("NoteId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Note");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Core.Entities.StudentEventRanking", b =>
|
||||
{
|
||||
b.HasOne("Core.Entities.EventDefinition", "EventDefinition")
|
||||
|
||||
Reference in New Issue
Block a user