Files
metapi/src/server/db/sharedIndexSchemaCompatibility.test.ts
T
ciat-777 b15da138d1 feat: enhance MySQL upgrade generation with index prefix length control
- Added support for specifying prefix lengths for live text-backed columns in MySQL upgrade SQL generation.
- Introduced `mysqlIndexPrefixRequirements` option to `generateUpgradeSql` function.
- Updated tests to validate the new functionality for MySQL upgrade generation.
- Removed legacy shared index compatibility specifications to avoid duplication with runtime schema bootstrap.
- Improved error handling and response structure in account token coverage refresh logic.
- Added tests for coverage refresh failure scenarios to ensure proper handling of token persistence.

# Conflicts:
#	src/server/db/sharedIndexSchemaCompatibility.test.ts
#	src/server/db/sharedIndexSchemaCompatibility.ts
#	src/server/index.ts
2026-03-15 23:13:37 +08:00

63 lines
1.6 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { ensureSharedIndexSchemaCompatibility, type SharedIndexSchemaInspector } from './sharedIndexSchemaCompatibility.js';
function createInspector(
dialect: SharedIndexSchemaInspector['dialect'],
options?: {
existingTables?: string[];
},
) {
const executedSql: string[] = [];
const existingTables = new Set(options?.existingTables ?? []);
const inspector: SharedIndexSchemaInspector = {
dialect,
async tableExists(table) {
return existingTables.has(table);
},
async execute(sqlText) {
executedSql.push(sqlText);
},
};
return { inspector, executedSql };
}
describe('ensureSharedIndexSchemaCompatibility', () => {
it.each([
'sqlite',
'mysql',
'postgres',
] as const)('is a no-op for %s now that contract-defined indexes come from runtime bootstrap', async (dialect) => {
const { inspector, executedSql } = createInspector(dialect, {
existingTables: [
'sites',
'accounts',
'account_tokens',
'checkin_logs',
'model_availability',
'token_model_availability',
'token_routes',
'route_channels',
'proxy_logs',
'proxy_video_tasks',
'downstream_api_keys',
'events',
],
});
await ensureSharedIndexSchemaCompatibility(inspector);
expect(executedSql).toEqual([]);
});
it('skips indexes for tables that do not exist', async () => {
const { inspector, executedSql } = createInspector('postgres', {
existingTables: ['sites'],
});
await ensureSharedIndexSchemaCompatibility(inspector);
expect(executedSql).toEqual([]);
});
});