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