knex-schema-inspector
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -231,3 +231,3 @@ "use strict"; | ||
.as('is_primary'), knex | ||
.select(knex.raw("'YES'")) | ||
.select(knex.raw("case when count(1) >0 then 'YES' else null end")) | ||
.from('pg_index') | ||
@@ -237,3 +237,3 @@ .join('pg_attribute', function () { | ||
}) | ||
.whereRaw('pg_index.indrelid = c.table_name::regclass') | ||
.whereRaw('pg_index.indrelid = quote_ident(c.table_name)::regclass') | ||
.andWhere(knex.raw('pg_attribute.attname = c.column_name')) | ||
@@ -244,3 +244,3 @@ .andWhere(knex.raw('pg_index.indisunique')) | ||
.from('pg_catalog.pg_class') | ||
.whereRaw("pg_catalog.pg_class.oid = (select('\"' || c.table_name || '\"'):: regclass:: oid)") | ||
.whereRaw("pg_catalog.pg_class.oid = (select quote_ident(c.table_name):: regclass:: oid)") | ||
.andWhere({ 'pg_catalog.pg_class.relname': 'c.table_name' }) | ||
@@ -247,0 +247,0 @@ .as('column_comment'), knex.raw('pg_get_serial_sequence(quote_ident(c.table_name), c.column_name) as serial'), 'ffk.referenced_table_schema', 'ffk.referenced_table_name', 'ffk.referenced_column_name') |
@@ -229,3 +229,3 @@ import { Knex } from 'knex'; | ||
knex | ||
.select(knex.raw(`'YES'`)) | ||
.select(knex.raw(`case when count(1) >0 then 'YES' else null end`)) | ||
.from('pg_index') | ||
@@ -237,3 +237,3 @@ .join('pg_attribute', function () { | ||
}) | ||
.whereRaw('pg_index.indrelid = c.table_name::regclass') | ||
.whereRaw('pg_index.indrelid = quote_ident(c.table_name)::regclass') | ||
.andWhere(knex.raw('pg_attribute.attname = c.column_name')) | ||
@@ -251,3 +251,3 @@ .andWhere(knex.raw('pg_index.indisunique')) | ||
.whereRaw( | ||
`pg_catalog.pg_class.oid = (select('"' || c.table_name || '"'):: regclass:: oid)` | ||
`pg_catalog.pg_class.oid = (select quote_ident(c.table_name):: regclass:: oid)` | ||
) | ||
@@ -254,0 +254,0 @@ .andWhere({ 'pg_catalog.pg_class.relname': 'c.table_name' }) |
{ | ||
"name": "knex-schema-inspector", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Utility for extracting information about existing DB schema", | ||
@@ -5,0 +5,0 @@ "main": "dist/lib/index.js", |
@@ -34,2 +34,3 @@ import knex, { Knex } from 'knex'; | ||
'users', | ||
'camelCase', | ||
'page_visits', | ||
@@ -43,2 +44,3 @@ ]); | ||
expect(await inspector.tableInfo()).to.deep.equal([ | ||
{ name: 'camelCase', schema: 'public', comment: null }, | ||
{ name: 'page_visits', schema: 'public', comment: null }, | ||
@@ -71,3 +73,5 @@ { name: 'teams', schema: 'public', comment: null }, | ||
{ table: 'users', column: 'id' }, | ||
{ table: 'page_visits', column: 'request_path' }, | ||
{ table: 'users', column: 'password' }, | ||
{ table: 'camelCase', column: 'primaryKey' }, | ||
{ table: 'users', column: 'email' }, | ||
@@ -77,7 +81,6 @@ { table: 'teams', column: 'uuid' }, | ||
{ table: 'teams', column: 'credits' }, | ||
{ table: 'page_visits', column: 'request_path' }, | ||
{ table: 'page_visits', column: 'user_agent' }, | ||
{ table: 'teams', column: 'created_at' }, | ||
{ table: 'teams', column: 'description' }, | ||
{ table: 'teams', column: 'id' }, | ||
{ table: 'page_visits', column: 'user_agent' }, | ||
{ table: 'users', column: 'team_id' }, | ||
@@ -91,3 +94,5 @@ { table: 'teams', column: 'name' }, | ||
{ table: 'users', column: 'id' }, | ||
{ table: 'page_visits', column: 'request_path' }, | ||
{ table: 'users', column: 'password' }, | ||
{ table: 'camelCase', column: 'primaryKey' }, | ||
{ table: 'users', column: 'email' }, | ||
@@ -97,7 +102,6 @@ { table: 'teams', column: 'uuid' }, | ||
{ table: 'teams', column: 'credits' }, | ||
{ table: 'page_visits', column: 'request_path' }, | ||
{ table: 'page_visits', column: 'user_agent' }, | ||
{ table: 'teams', column: 'created_at' }, | ||
{ table: 'teams', column: 'description' }, | ||
{ table: 'teams', column: 'id' }, | ||
{ table: 'page_visits', column: 'user_agent' }, | ||
{ table: 'users', column: 'team_id' }, | ||
@@ -126,2 +130,20 @@ { table: 'teams', column: 'name' }, | ||
{ | ||
name: 'primaryKey', | ||
table: 'camelCase', | ||
data_type: 'integer', | ||
default_value: 'nextval(\'"camelCase_primaryKey_seq"\'::regclass)', | ||
max_length: null, | ||
numeric_precision: 32, | ||
numeric_scale: 0, | ||
is_nullable: false, | ||
is_unique: true, | ||
is_primary_key: true, | ||
has_auto_increment: true, | ||
foreign_key_column: null, | ||
foreign_key_table: null, | ||
comment: null, | ||
schema: 'public', | ||
foreign_key_schema: null, | ||
}, | ||
{ | ||
name: 'request_path', | ||
@@ -128,0 +150,0 @@ table: 'page_visits', |
Sorry, the diff of this file is not supported yet
472628
9686