fix : remove unused colum in database
This commit is contained in:
+3
-13
@@ -9,7 +9,6 @@ import {
|
|||||||
deleteGlossaryAlias,
|
deleteGlossaryAlias,
|
||||||
} from "@/lib/glossary-repository";
|
} from "@/lib/glossary-repository";
|
||||||
import { requireAdmin } from "@/lib/auth/server";
|
import { requireAdmin } from "@/lib/auth/server";
|
||||||
import { getCurrentCatalogVersion } from "@/lib/catalog/sync";
|
|
||||||
import { publicGuideSections } from "@/lib/guides/public-sections";
|
import { publicGuideSections } from "@/lib/guides/public-sections";
|
||||||
import { publicationIssues } from "@/lib/guides/publication";
|
import { publicationIssues } from "@/lib/guides/publication";
|
||||||
import { getAdminGuideContentById } from "@/lib/guides/queries";
|
import { getAdminGuideContentById } from "@/lib/guides/queries";
|
||||||
@@ -206,34 +205,25 @@ export async function setStructuredGuideVisibility(
|
|||||||
const parsed = z.strictObject({
|
const parsed = z.strictObject({
|
||||||
isPublic: z.boolean(),
|
isPublic: z.boolean(),
|
||||||
expectedVersion: z.number().int().positive(),
|
expectedVersion: z.number().int().positive(),
|
||||||
publicationNote: z.string().trim().max(500).optional(),
|
|
||||||
}).safeParse(input);
|
}).safeParse(input);
|
||||||
if (!parsed.success) return { status: "error" as const, message: "ข้อมูลการเผยแพร่ไม่ถูกต้อง" };
|
if (!parsed.success) return { status: "error" as const, message: "ข้อมูลการเผยแพร่ไม่ถูกต้อง" };
|
||||||
if (!parsed.data.isPublic) {
|
if (!parsed.data.isPublic) {
|
||||||
return runGuideAction(() => setGuideVisibility(guideId, parsed.data));
|
return runGuideAction(() => setGuideVisibility(guideId, parsed.data));
|
||||||
}
|
}
|
||||||
|
|
||||||
const [guide, catalogVersion] = await Promise.all([
|
const guide = await getAdminGuideContentById(guideId);
|
||||||
getAdminGuideContentById(guideId),
|
|
||||||
getCurrentCatalogVersion(),
|
|
||||||
]);
|
|
||||||
const issues = publicationIssues({
|
const issues = publicationIssues({
|
||||||
exists: Boolean(guide),
|
exists: Boolean(guide),
|
||||||
overview: guide?.overview ?? "",
|
overview: guide?.overview ?? "",
|
||||||
coverReady: guide?.coverStatus === "ready",
|
coverReady: guide?.coverStatus === "ready",
|
||||||
catalogVersion,
|
|
||||||
renderableSectionCount: guide ? publicGuideSections(guide).length : 0,
|
renderableSectionCount: guide ? publicGuideSections(guide).length : 0,
|
||||||
version: guide?.version ?? 0,
|
version: guide?.version ?? 0,
|
||||||
expectedVersion: parsed.data.expectedVersion,
|
expectedVersion: parsed.data.expectedVersion,
|
||||||
});
|
});
|
||||||
if (issues.length || !catalogVersion) {
|
if (issues.length) {
|
||||||
return { status: "error" as const, message: issues.join(" • "), issues };
|
return { status: "error" as const, message: issues.join(" • "), issues };
|
||||||
}
|
}
|
||||||
return runGuideAction(() => setGuideVisibility(guideId, {
|
return runGuideAction(() => setGuideVisibility(guideId, parsed.data));
|
||||||
...parsed.data,
|
|
||||||
publicationNote: parsed.data.publicationNote || null,
|
|
||||||
catalogVersion,
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteStructuredGuide(guideId: string) {
|
export async function deleteStructuredGuide(guideId: string) {
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ type GuideCard = {
|
|||||||
rarity: number | null;
|
rarity: number | null;
|
||||||
updatedAt: Date;
|
updatedAt: Date;
|
||||||
publishedAt: Date | null;
|
publishedAt: Date | null;
|
||||||
publishedCatalogVersion: string | null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const elementLabels: Record<string, string> = {
|
const elementLabels: Record<string, string> = {
|
||||||
@@ -160,9 +159,6 @@ export function StructuredDirectory({ guides }: { guides: GuideCard[] }) {
|
|||||||
<CardDescription className="line-clamp-3">
|
<CardDescription className="line-clamp-3">
|
||||||
{guide.overview}
|
{guide.overview}
|
||||||
</CardDescription>
|
</CardDescription>
|
||||||
<div className="flex flex-wrap gap-2 pt-2">
|
|
||||||
{guide.publishedCatalogVersion ? <Badge variant="outline">v{guide.publishedCatalogVersion}</Badge> : null}
|
|
||||||
</div>
|
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
</Card>
|
</Card>
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -207,12 +207,10 @@ function GuideOverview({
|
|||||||
<h1 className="font-heading text-4xl font-bold">{guide.name}</h1>
|
<h1 className="font-heading text-4xl font-bold">{guide.name}</h1>
|
||||||
<p className="text-lg font-semibold">{guide.overview}</p>
|
<p className="text-lg font-semibold">{guide.overview}</p>
|
||||||
<div className="flex flex-wrap justify-center gap-2">
|
<div className="flex flex-wrap justify-center gap-2">
|
||||||
{guide.publishedCatalogVersion ? <Badge variant="outline">เวอร์ชัน {guide.publishedCatalogVersion}</Badge> : null}
|
|
||||||
<Badge variant="secondary">
|
<Badge variant="secondary">
|
||||||
อัปเดต {new Date(guide.publishedAt ?? guide.updatedAt).toLocaleDateString("th-TH")}
|
อัปเดต {new Date(guide.publishedAt ?? guide.updatedAt).toLocaleDateString("th-TH")}
|
||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
{guide.publicationNote ? <p className="text-sm text-muted-foreground">{guide.publicationNote}</p> : null}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="grid items-start gap-6 lg:grid-cols-2">
|
<div className="grid items-start gap-6 lg:grid-cols-2">
|
||||||
<div className="order-1 relative aspect-square w-full overflow-hidden rounded-xl border bg-muted lg:col-start-1 lg:row-start-1">
|
<div className="order-1 relative aspect-square w-full overflow-hidden rounded-xl border bg-muted lg:col-start-1 lg:row-start-1">
|
||||||
|
|||||||
@@ -295,8 +295,6 @@ export const guides = guidesSchema.table(
|
|||||||
version: integer("version").default(1).notNull(),
|
version: integer("version").default(1).notNull(),
|
||||||
isPublic: boolean("is_public").default(false).notNull(),
|
isPublic: boolean("is_public").default(false).notNull(),
|
||||||
publishedAt: timestamp("published_at", { withTimezone: true }),
|
publishedAt: timestamp("published_at", { withTimezone: true }),
|
||||||
publishedCatalogVersion: varchar("published_catalog_version", { length: 32 }),
|
|
||||||
publicationNote: varchar("publication_note", { length: 500 }),
|
|
||||||
sortOrder: integer("sort_order").default(0).notNull(),
|
sortOrder: integer("sort_order").default(0).notNull(),
|
||||||
trashedAt: timestamp("trashed_at", { withTimezone: true }),
|
trashedAt: timestamp("trashed_at", { withTimezone: true }),
|
||||||
...timestamps,
|
...timestamps,
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE "guides"."guide" DROP COLUMN "published_catalog_version";--> statement-breakpoint
|
||||||
|
ALTER TABLE "guides"."guide" DROP COLUMN "publication_note";
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -358,6 +358,13 @@
|
|||||||
"when": 1790440719770,
|
"when": 1790440719770,
|
||||||
"tag": "0050_swift_valeria_richards",
|
"tag": "0050_swift_valeria_richards",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 51,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1790497927427,
|
||||||
|
"tag": "0051_silky_big_bertha",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -430,8 +430,6 @@ export async function setGuideVisibility(
|
|||||||
input: {
|
input: {
|
||||||
isPublic: boolean;
|
isPublic: boolean;
|
||||||
expectedVersion: number;
|
expectedVersion: number;
|
||||||
catalogVersion?: string;
|
|
||||||
publicationNote?: string | null;
|
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
return getDb().transaction(async (tx) => {
|
return getDb().transaction(async (tx) => {
|
||||||
@@ -442,8 +440,6 @@ export async function setGuideVisibility(
|
|||||||
version: sql`${guides.version} + 1`,
|
version: sql`${guides.version} + 1`,
|
||||||
...(input.isPublic ? {
|
...(input.isPublic ? {
|
||||||
publishedAt: new Date(),
|
publishedAt: new Date(),
|
||||||
publishedCatalogVersion: input.catalogVersion,
|
|
||||||
publicationNote: input.publicationNote ?? null,
|
|
||||||
} : {}),
|
} : {}),
|
||||||
})
|
})
|
||||||
.where(and(
|
.where(and(
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ const complete = {
|
|||||||
exists: true,
|
exists: true,
|
||||||
overview: "Build overview",
|
overview: "Build overview",
|
||||||
coverReady: true,
|
coverReady: true,
|
||||||
catalogVersion: "6.0",
|
|
||||||
renderableSectionCount: 1,
|
renderableSectionCount: 1,
|
||||||
version: 4,
|
version: 4,
|
||||||
expectedVersion: 4,
|
expectedVersion: 4,
|
||||||
@@ -22,13 +21,11 @@ describe("publicationIssues", () => {
|
|||||||
...complete,
|
...complete,
|
||||||
overview: " ",
|
overview: " ",
|
||||||
coverReady: false,
|
coverReady: false,
|
||||||
catalogVersion: null,
|
|
||||||
renderableSectionCount: 0,
|
renderableSectionCount: 0,
|
||||||
expectedVersion: 3,
|
expectedVersion: 3,
|
||||||
})).toEqual([
|
})).toEqual([
|
||||||
"กรุณากรอก Overview",
|
"กรุณากรอก Overview",
|
||||||
"รูปปกยังไม่พร้อมใช้งาน",
|
"รูปปกยังไม่พร้อมใช้งาน",
|
||||||
"กรุณา Sync Catalog ก่อนเผยแพร่",
|
|
||||||
"กรุณาเพิ่มเนื้อหาอย่างน้อยหนึ่ง Section",
|
"กรุณาเพิ่มเนื้อหาอย่างน้อยหนึ่ง Section",
|
||||||
"Guide ถูกแก้ไขแล้ว กรุณาลองใหม่",
|
"Guide ถูกแก้ไขแล้ว กรุณาลองใหม่",
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ export interface PublicationCheckInput {
|
|||||||
exists: boolean;
|
exists: boolean;
|
||||||
overview: string;
|
overview: string;
|
||||||
coverReady: boolean;
|
coverReady: boolean;
|
||||||
catalogVersion: string | null;
|
|
||||||
renderableSectionCount: number;
|
renderableSectionCount: number;
|
||||||
version: number;
|
version: number;
|
||||||
expectedVersion: number;
|
expectedVersion: number;
|
||||||
@@ -13,7 +12,6 @@ export function publicationIssues(input: PublicationCheckInput): string[] {
|
|||||||
const issues: string[] = [];
|
const issues: string[] = [];
|
||||||
if (!input.overview.trim()) issues.push("กรุณากรอก Overview");
|
if (!input.overview.trim()) issues.push("กรุณากรอก Overview");
|
||||||
if (!input.coverReady) issues.push("รูปปกยังไม่พร้อมใช้งาน");
|
if (!input.coverReady) issues.push("รูปปกยังไม่พร้อมใช้งาน");
|
||||||
if (!input.catalogVersion) issues.push("กรุณา Sync Catalog ก่อนเผยแพร่");
|
|
||||||
if (input.renderableSectionCount === 0) issues.push("กรุณาเพิ่มเนื้อหาอย่างน้อยหนึ่ง Section");
|
if (input.renderableSectionCount === 0) issues.push("กรุณาเพิ่มเนื้อหาอย่างน้อยหนึ่ง Section");
|
||||||
if (input.version !== input.expectedVersion) issues.push("Guide ถูกแก้ไขแล้ว กรุณาลองใหม่");
|
if (input.version !== input.expectedVersion) issues.push("Guide ถูกแก้ไขแล้ว กรุณาลองใหม่");
|
||||||
return issues;
|
return issues;
|
||||||
|
|||||||
@@ -241,7 +241,6 @@ export async function listPublicGuideCards() {
|
|||||||
version: guides.version,
|
version: guides.version,
|
||||||
updatedAt: guides.updatedAt,
|
updatedAt: guides.updatedAt,
|
||||||
publishedAt: guides.publishedAt,
|
publishedAt: guides.publishedAt,
|
||||||
publishedCatalogVersion: guides.publishedCatalogVersion,
|
|
||||||
element: catalogCharacters.element,
|
element: catalogCharacters.element,
|
||||||
weaponType: catalogCharacters.weaponType,
|
weaponType: catalogCharacters.weaponType,
|
||||||
rarity: catalogCharacters.rarity,
|
rarity: catalogCharacters.rarity,
|
||||||
|
|||||||
Reference in New Issue
Block a user