Libraries
    Preparing search index...

    Function introspectDatabase

    • Introspect a PostgreSQL table and return its current state.

      Queries information_schema.columns, pg_indexes, pg_constraint, and referential constraint metadata to build a complete picture of the table's columns, indexes, foreign keys, and check constraints.

      Parameters

      • knex: Knex

        A configured Knex instance connected to a PostgreSQL database.

      • tableName: string

        The table name to introspect.

      Returns Promise<DatabaseTableState>

      The current database state for the table.

      const dbState = await introspectDatabase(knex, 'users');
      console.log(dbState.columns); // { id: { type: 'integer', ... }, ... }