feat: sql-tools overrides (#19796)

This commit is contained in:
Jason Rasmussen 2025-07-08 08:17:40 -04:00 committed by GitHub
parent 1f9813a28e
commit df4a27e8a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
114 changed files with 775 additions and 289 deletions

View file

@ -1,7 +1,7 @@
import { sql } from 'kysely';
import { DatabaseReader } from 'src/sql-tools/types';
import { Reader } from 'src/sql-tools/types';
export const readIndexes: DatabaseReader = async (schema, db) => {
export const readIndexes: Reader = async (ctx, db) => {
const indexes = await db
.selectFrom('pg_index as ix')
// matching index, which has column information
@ -34,12 +34,12 @@ export const readIndexes: DatabaseReader = async (schema, db) => {
.select((eb) => eb.fn<string[]>('json_agg', ['a.attname']).as('column_name'))
.as('column_names'),
])
.where('pg_namespace.nspname', '=', schema.schemaName)
.where('pg_namespace.nspname', '=', ctx.schemaName)
.where('ix.indisprimary', '=', sql.lit(false))
.execute();
for (const index of indexes) {
const table = schema.tables.find((table) => table.name === index.table_name);
const table = ctx.getTableByName(index.table_name);
if (!table) {
continue;
}