fix(schema-diff): skip view DDL when disabled
This commit is contained in:
1 parent
9cfee7f497
commit
3e8e7a4146
3 files changed
+18
-3
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { createConcurrencyLimiter, mapWithConcurrency, schemaDiffMetadataConcurrency } from "@/lib/schema/schemaDiffMetadataLoad";
|
||||
import { createConcurrencyLimiter, mapWithConcurrency, schemaDiffMetadataConcurrency, shouldFetchSchemaDiffDdl } from "@/lib/schema/schemaDiffMetadataLoad";
|
||||
|
||||
function wait(ms: number) {
|
||||
return new Promise<void>((resolve) => setTimeout(resolve, ms));
|
||||
@@ -17,6 +17,13 @@ describe("schemaDiffMetadataLoad", () => {
|
||||
expect(schemaDiffMetadataConcurrency(undefined)).toBe(6);
|
||||
});
|
||||
|
||||
it("skips view DDL when views are disabled while preserving table DDL options", () => {
|
||||
expect(shouldFetchSchemaDiffDdl(true, { tables: true, views: false })).toBe(false);
|
||||
expect(shouldFetchSchemaDiffDdl(true, { tables: false, views: true })).toBe(true);
|
||||
expect(shouldFetchSchemaDiffDdl(false, { tables: false, views: true })).toBe(false);
|
||||
expect(shouldFetchSchemaDiffDdl(false, { tables: true, views: false })).toBe(true);
|
||||
});
|
||||
|
||||
it("maps items with limited concurrency and preserves output order", async () => {
|
||||
let active = 0;
|
||||
let maxActive = 0;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { SchemaDiffCompareOptions } from "@/types/schemaDiff";
|
||||
|
||||
const MYSQL_LARGE_SCHEMA_DIFF_METADATA_CONCURRENCY = 2;
|
||||
const MYSQL_SMALL_SCHEMA_DIFF_METADATA_CONCURRENCY = 4;
|
||||
const MYSQL_SMALL_SCHEMA_TABLE_LIMIT = 30;
|
||||
@@ -18,6 +20,10 @@ export function schemaDiffMetadataConcurrency(dbType: string | null | undefined,
|
||||
return DEFAULT_SCHEMA_DIFF_METADATA_CONCURRENCY;
|
||||
}
|
||||
|
||||
export function shouldFetchSchemaDiffDdl(isView: boolean, options: Pick<SchemaDiffCompareOptions, "tables" | "views">): boolean {
|
||||
return isView ? options.views : options.tables;
|
||||
}
|
||||
|
||||
export async function mapWithConcurrency<T, R>(items: readonly T[], limit: number, worker: (item: T, index: number) => Promise<R>): Promise<R[]> {
|
||||
const workerCount = Math.min(normalizeConcurrencyLimit(limit), items.length);
|
||||
if (workerCount === 0) return [];
|
||||
|
||||
Reference in new issue
Block a user