import { libSchema } from "./names";
import { sql } from "./quote";
import { runSql } from "./runSql";

/**
 * Returns the list of active shards on a DSN.
 */
export async function listActiveSchemas({
  dsn,
}: {
  dsn: string;
}): Promise<string[]> {
  return runSql.column(
    dsn,
    sql`SELECT unnest FROM unnest(${libSchema()}.microsharding_list_active_shards())`,
  );
}
