forked from boos/BoosAPI
fix: trust proxy headers and align proxy file mysql indexes
This commit is contained in:
@@ -62,6 +62,19 @@ describe('ensureProxyFileSchemaCompatibility', () => {
|
||||
expect(executedSql.some((sqlText) => ownerIndexPattern.test(sqlText))).toBe(true);
|
||||
});
|
||||
|
||||
it('emits MySQL indexes compatible with generated bootstrap SQL', async () => {
|
||||
const { inspector, executedSql } = createInspector('mysql');
|
||||
|
||||
await ensureProxyFileSchemaCompatibility(inspector);
|
||||
|
||||
expect(executedSql).toContain(
|
||||
'CREATE UNIQUE INDEX `proxy_files_public_id_unique` ON `proxy_files` (`public_id`(191))',
|
||||
);
|
||||
expect(executedSql).toContain(
|
||||
'CREATE INDEX `proxy_files_owner_lookup_idx` ON `proxy_files` (`owner_type`(191), `owner_id`(191), `deleted_at`)',
|
||||
);
|
||||
});
|
||||
|
||||
it('adds missing columns on existing table before ensuring indexes', async () => {
|
||||
const { inspector, executedSql } = createInspector('postgres', {
|
||||
hasTable: true,
|
||||
|
||||
@@ -127,8 +127,8 @@ const CREATE_INDEX_SQL: Record<ProxyFileSchemaDialect, string[]> = {
|
||||
'CREATE INDEX IF NOT EXISTS "proxy_files_owner_lookup_idx" ON "proxy_files" ("owner_type", "owner_id", "deleted_at")',
|
||||
],
|
||||
mysql: [
|
||||
'CREATE UNIQUE INDEX `proxy_files_public_id_unique` ON `proxy_files` (`public_id`)',
|
||||
'CREATE INDEX `proxy_files_owner_lookup_idx` ON `proxy_files` (`owner_type`, `owner_id`)',
|
||||
'CREATE UNIQUE INDEX `proxy_files_public_id_unique` ON `proxy_files` (`public_id`(191))',
|
||||
'CREATE INDEX `proxy_files_owner_lookup_idx` ON `proxy_files` (`owner_type`(191), `owner_id`(191), `deleted_at`)',
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user