feat(postgres): add table vacuum action
This commit is contained in:
1 parent
0e0edcd206
commit
11407b537f
23 files changed
+554
-36
No files matched your search
@@ -12,6 +12,7 @@ import {
|
||||
supportsQueryEditorBlockComments,
|
||||
supportsSqlInListPaste,
|
||||
supportsTableImport,
|
||||
supportsTableVacuum,
|
||||
supportsTransaction,
|
||||
usesConnectionOnlyQueryTarget,
|
||||
} from "@/lib/database/databaseFeatureSupport";
|
||||
@@ -139,6 +140,20 @@ describe("supportsQueryEditorBlockComments", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("supportsTableVacuum", () => {
|
||||
it("enables VACUUM for the supported PostgreSQL family", () => {
|
||||
for (const databaseType of ["postgres", "gaussdb", "opengauss", "kingbase", "vastbase", "highgo", "uxdb", "kwdb"] as const) {
|
||||
expect(supportsTableVacuum(databaseType)).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it("does not enable VACUUM for unrelated database types", () => {
|
||||
for (const databaseType of ["mysql", "sqlite", "redshift", "oracle", "jdbc"] as const) {
|
||||
expect(supportsTableVacuum(databaseType)).toBe(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("supportsTableImport", () => {
|
||||
it("enables OceanBase Oracle table import", () => {
|
||||
expect(supportsTableImport("oceanbase-oracle")).toBe(true);
|
||||
|
||||
@@ -9,12 +9,14 @@ const apiMock = vi.hoisted(() => ({
|
||||
buildCreateTableSql: vi.fn(),
|
||||
buildDuplicateTableStructureSql: vi.fn(),
|
||||
buildMysqlAutoIncrementSql: vi.fn(),
|
||||
buildVacuumTableSql: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("@/lib/backend/api", () => apiMock);
|
||||
|
||||
import {
|
||||
buildDuplicateTableStructurePlan,
|
||||
buildVacuumTableSql,
|
||||
buildMysqlAutoIncrementSql,
|
||||
collectDuplicateTableColumnComments,
|
||||
damengDropSchemaExecutionSchema,
|
||||
@@ -66,6 +68,29 @@ describe("MySQL AUTO_INCREMENT administration", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("PostgreSQL-family VACUUM administration", () => {
|
||||
it("forwards independent FULL and ANALYZE options", async () => {
|
||||
apiMock.buildVacuumTableSql.mockResolvedValue('VACUUM FULL ANALYZE "public"."events";');
|
||||
|
||||
await expect(
|
||||
buildVacuumTableSql({
|
||||
databaseType: "postgres",
|
||||
schema: "public",
|
||||
tableName: "events",
|
||||
full: true,
|
||||
analyze: true,
|
||||
}),
|
||||
).resolves.toBe('VACUUM FULL ANALYZE "public"."events";');
|
||||
expect(apiMock.buildVacuumTableSql).toHaveBeenCalledWith({
|
||||
databaseType: "postgres",
|
||||
schema: "public",
|
||||
tableName: "events",
|
||||
full: true,
|
||||
analyze: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("collectDuplicateTableColumnComments", () => {
|
||||
it("preserves meaningful whitespace and excludes whitespace-only comments", () => {
|
||||
expect(
|
||||
|
||||
Reference in new issue
Block a user