All files / blong-int-adapter/mysql/adapter/sql sqlSchemaTableSync.ts

100% Statements 25/25
100% Branches 2/2
100% Functions 1/1
100% Lines 25/25

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 261x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import {handler} from '@feasibleone/blong';
 
/**
 * sqlSchemaTableSync — creates or synchronises the `schema_item` integration-test
 * table using the knex adapter's built-in `schemaTableSync` method driven by the
 * TypeBox schema declared in the test fixtures.
 *
 * Passing `dropColumns: true` will additionally remove any columns not present
 * in the TypeBox schema (useful for cleanup between test runs).
 */
export default handler(
    ({schema}) =>
        async function sqlSchemaTableSync(
            params: {dropColumns?: boolean},
            _$meta: Record<string, unknown>,
        ): Promise<{created: boolean; added: string[]; dropped: string[]}> {
            return (
                this.schemaTableSync as (
                    ...args: unknown[]
                ) => Promise<{created: boolean; added: string[]; dropped: string[]}>
            )('sql_item', schema.mysql.item, {
                dropColumns: params.dropColumns ?? false,
            });
        },
);