fix(ci): migrate on tag release and wire drizzle schema generate
Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
20b85381fe
commit
67656a9aad
5 files changed
+91
No files matched your search
@@ -31,4 +31,14 @@ describe("CI workflow", () => {
|
||||
expect(workflow).toContain("Creating release for");
|
||||
expect(workflow).toContain("startsWith(gitea.ref_name, 'v')");
|
||||
});
|
||||
|
||||
it("applies CMS migrations on tag release before build", () => {
|
||||
const release = workflow.slice(workflow.indexOf("\n release:"));
|
||||
expect(release).toContain("pnpm db:migrate");
|
||||
expect(release).toContain("unset DATABASE_URL");
|
||||
const migrateAt = release.indexOf("pnpm db:migrate");
|
||||
const buildAt = release.indexOf("pnpm build");
|
||||
expect(migrateAt).toBeGreaterThan(-1);
|
||||
expect(buildAt).toBeGreaterThan(migrateAt);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,60 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
describe("prisma-facade include contract", () => {
|
||||
const src = readFileSync(
|
||||
resolve(process.cwd(), "src/lib/prisma-facade.ts"),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
it("groups many-relations as arrays (polls/tickets/events)", () => {
|
||||
expect(src).toContain('mode: "one" | "many"');
|
||||
expect(src).toContain('mode === "many"');
|
||||
expect(src).toContain("list.push(cleaned)");
|
||||
expect(src).toContain('"many"');
|
||||
expect(src).toMatch(/queryRelationRows\([\s\S]*?"many"/);
|
||||
});
|
||||
|
||||
it("recurses nested include on related rows", () => {
|
||||
expect(src).toContain("opts.include && related.length > 0");
|
||||
expect(src).toContain(
|
||||
"await attachIncludes(client, rel.referencedTable, related, opts.include)",
|
||||
);
|
||||
});
|
||||
|
||||
it("applies relation where filters when present", () => {
|
||||
expect(src).toContain("buildCondition(rel.referencedTable, opts.where)");
|
||||
});
|
||||
|
||||
it("ships poll/ticket/event drizzle relations used by admin includes", () => {
|
||||
const relations = readFileSync(
|
||||
resolve(process.cwd(), "src/db/relations.ts"),
|
||||
"utf8",
|
||||
);
|
||||
expect(relations).toContain("questions: many(WebsitePollQuestion)");
|
||||
expect(relations).toContain("votes: many(WebsitePollVote)");
|
||||
expect(relations).toContain("messages: many(WebsiteTicketMessage)");
|
||||
expect(relations).toContain("prizes: many(WebsiteEventPrize)");
|
||||
expect(relations).toContain(
|
||||
"registrations: many(WebsiteEventRegistration)",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("drizzle schema generate script", () => {
|
||||
it("is wired as pnpm db:schema:generate", () => {
|
||||
const pkg = JSON.parse(
|
||||
readFileSync(resolve(process.cwd(), "package.json"), "utf8"),
|
||||
) as { scripts: Record<string, string> };
|
||||
expect(pkg.scripts["db:schema:generate"]).toContain(
|
||||
"generate-drizzle-schema.mjs",
|
||||
);
|
||||
expect(
|
||||
readFileSync(
|
||||
resolve(process.cwd(), "scripts/generate-drizzle-schema.mjs"),
|
||||
"utf8",
|
||||
),
|
||||
).toContain("Usage: pnpm db:schema:generate");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user