Postgres hasTable does not exist on withSchema
Environment
Knex version: 2.4 Database + version: Postgres (localhost) v14 OS: MacOs Scenario: Migration
Bug
- Explain what kind of behaviour you are getting and how you think it should do
I have various tables on different schemas within a single database. I was using the knex.schema.createTableIfNotExists() method but saw a log warning that I should use hasTable and then createTable.
So I switched my code to knex.schema.hasTable('sys.sometable') and I noticed it was not matching the table correctly because it was checking INFORMATION_SCHEMA.tables and using current_schema.
So then I tried knex.withSchema('sys').hasTable('sometable') but its throwing an error.
knex.withSchema(...).hasTable is not a function
TypeError: knex.withSchema(...).hasTable is not a functionIMO all of the migration functions available on knex.schema should be available on knex.withSchema() and if schema is not pertinent to the function it can just ignore it.
OR hasTable should split the table name if a schema is provided to use in its query.
Source: knex/knex