// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
// SPDX-License-Identifier: Apache-2.0
/*
* Generated by @medplum/generator
* Do not edit manually.
*/
import type { PoolClient } from 'pg';
export async function run(client: PoolClient): Promise<void> {
const columns = [
['Address', 'address'],
['Address', 'city'],
['Address', 'country'],
['Address', 'postalCode'],
['Address', 'state'],
['Address', 'use'],
['HumanName', 'name'],
['HumanName', 'given'],
['HumanName', 'family'],
];
for (const [table, column] of columns) {
await client.query(
`ALTER TABLE "${table}" ADD COLUMN IF NOT EXISTS "${column}_tsv" tsvector GENERATED ALWAYS AS (to_tsvector('english', "${column}")) STORED`
);
await client.query(
`CREATE INDEX CONCURRENTLY IF NOT EXISTS "${table}_${column}_tsv_idx" ON "${table}" USING GIN ("${column}_tsv")`
);
}
}