knex-schema-inspector
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -6,24 +6,2 @@ import { Knex } from 'knex'; | ||
import { ForeignKey } from '../types/foreign-key'; | ||
declare type RawColumn = { | ||
column_name: string; | ||
table_name: string; | ||
table_schema: string; | ||
data_type: string; | ||
column_default: string | null; | ||
character_maximum_length: null | number | string; | ||
is_generated: 'NEVER' | 'ALWAYS'; | ||
is_nullable: 'YES' | 'NO'; | ||
is_unique: boolean; | ||
is_primary: boolean; | ||
is_identity: 'YES' | 'NO'; | ||
generation_expression: null | string; | ||
numeric_precision: null | number | string; | ||
numeric_scale: null | number | string; | ||
serial: null | string; | ||
column_comment: string | null; | ||
foreign_key_schema: null | string; | ||
foreign_key_table: null | string; | ||
foreign_key_column: null | string; | ||
}; | ||
export declare function rawColumnToColumn(rawColumn: RawColumn): Column; | ||
/** | ||
@@ -80,2 +58,1 @@ * Converts CockroachDB default value to JS | ||
} | ||
export {}; |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -39,30 +50,4 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseDefaultValue = exports.rawColumnToColumn = void 0; | ||
exports.parseDefaultValue = void 0; | ||
var strip_quotes_1 = require("../utils/strip-quotes"); | ||
function convertStringOrNumber(t) { | ||
return t == undefined ? t : Number(t); | ||
} | ||
function rawColumnToColumn(rawColumn) { | ||
return { | ||
name: rawColumn.column_name, | ||
table: rawColumn.table_name, | ||
data_type: rawColumn.data_type, | ||
default_value: parseDefaultValue(rawColumn.column_default), | ||
generation_expression: rawColumn.generation_expression || null, | ||
max_length: convertStringOrNumber(rawColumn.character_maximum_length), | ||
numeric_precision: convertStringOrNumber(rawColumn.numeric_precision), | ||
numeric_scale: convertStringOrNumber(rawColumn.numeric_scale), | ||
is_generated: rawColumn.is_generated === 'ALWAYS', | ||
is_nullable: rawColumn.is_nullable === 'YES', | ||
is_unique: rawColumn.is_unique, | ||
is_primary_key: rawColumn.is_primary, | ||
has_auto_increment: rawColumn.serial !== null || rawColumn.is_identity === 'YES', | ||
comment: rawColumn.column_comment, | ||
schema: rawColumn.table_schema, | ||
foreign_key_schema: rawColumn.foreign_key_schema, | ||
foreign_key_table: rawColumn.foreign_key_table, | ||
foreign_key_column: rawColumn.foreign_key_column, | ||
}; | ||
} | ||
exports.rawColumnToColumn = rawColumnToColumn; | ||
/** | ||
@@ -234,30 +219,33 @@ * Converts CockroachDB default value to JS | ||
return __awaiter(this, void 0, void 0, function () { | ||
var knex, query, rawColumn, records; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
var knex, bindings, schemaIn, _a, columns, constraints, parsedColumms; | ||
var _this = this; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
knex = this.knex; | ||
query = knex | ||
.select('c.column_name', 'c.table_name', 'c.data_type', 'c.column_default', 'c.character_maximum_length', 'c.is_generated', 'c.is_nullable', 'c.numeric_precision', 'c.numeric_scale', 'c.table_schema', 'c.is_identity', 'c.generation_expression', knex.raw('pg_get_serial_sequence(quote_ident(c.table_name), c.column_name) as serial'), knex.raw('pg_catalog.col_description(pg_class.oid, c.ordinal_position:: int) as column_comment'), knex.raw("COALESCE(pg.indisunique, false) as is_unique"), knex.raw("COALESCE(pg.indisprimary, false) as is_primary"), 'ffk.foreign_key_schema', 'ffk.foreign_key_table', 'ffk.foreign_key_column') | ||
.from(knex.raw('information_schema.columns c')) | ||
.joinRaw("\n LEFT JOIN pg_catalog.pg_class\n ON pg_catalog.pg_class.oid = CONCAT_WS('.', quote_ident(c.table_schema), quote_ident(c.table_name)):: regclass:: oid\n AND pg_catalog.pg_class.relname = c.table_name\n ") | ||
.joinRaw("\n LEFT JOIN LATERAL (\n SELECT\n pg_index.indisprimary,\n pg_index.indisunique\n FROM pg_index\n JOIN pg_attribute\n ON pg_attribute.attrelid = pg_index.indrelid\n AND pg_attribute.attnum = any(pg_index.indkey)\n WHERE pg_index.indrelid = quote_ident(c.table_name)::regclass\n AND pg_attribute.attname = c.column_name\n AND pg_index.indnatts = 1\n LIMIT 1\n ) pg ON true\n ") | ||
.joinRaw("\n LEFT JOIN LATERAL (\n SELECT\n k2.table_schema AS foreign_key_schema,\n k2.table_name AS foreign_key_table,\n k2.column_name AS foreign_key_column\n FROM\n information_schema.key_column_usage k1\n JOIN information_schema.referential_constraints fk using (\n constraint_schema, constraint_name\n )\n JOIN information_schema.key_column_usage k2\n ON k2.constraint_schema = fk.unique_constraint_schema\n AND k2.constraint_name = fk.unique_constraint_name\n AND k2.ordinal_position = k1.position_in_unique_constraint\n WHERE k1.table_name = c.table_name\n AND k1.column_name = c.column_name\n ) ffk ON TRUE\n ") | ||
.whereIn('c.table_schema', this.explodedSchema) | ||
.andWhere('pg_class.relkind', '!=', 'S') | ||
.orderBy(['c.table_name', 'c.ordinal_position']); | ||
if (table) { | ||
query.andWhere({ 'c.table_name': table }); | ||
} | ||
if (!column) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, query | ||
.andWhere({ 'c.column_name': column }) | ||
.first()]; | ||
bindings = []; | ||
if (table) | ||
bindings.push(table); | ||
if (column) | ||
bindings.push(column); | ||
schemaIn = this.explodedSchema.map(function (schemaName) { return "".concat(_this.knex.raw('?', [schemaName]), "::regnamespace"); }); | ||
return [4 /*yield*/, Promise.all([ | ||
knex.raw("\n SELECT *, CASE WHEN res.is_generated THEN (\n SELECT\n generation_expression\n FROM\n information_schema.columns\n WHERE\n table_schema = res.schema \n AND table_name = res.table \n AND column_name = res.name\n ) ELSE NULL END AS generation_expression\n FROM (\n SELECT\n att.attname AS name,\n rel.relname AS table,\n rel.relnamespace::regnamespace::text AS schema,\n format_type(att.atttypid, null) AS data_type,\n NOT att.attnotnull AS is_nullable,\n CASE WHEN att.attgenerated = '' THEN pg_get_expr(ad.adbin, ad.adrelid) ELSE null END AS default_value,\n att.attgenerated = 's' AS is_generated,\n CASE\n WHEN att.atttypid IN (1042, 1043) THEN (att.atttypmod - 4)::int4\n WHEN att.atttypid IN (1560, 1562) THEN (att.atttypmod)::int4\n ELSE NULL\n END AS max_length,\n des.description AS comment,\n CASE att.atttypid\n WHEN 21 THEN 16\n WHEN 23 THEN 32\n WHEN 20 THEN 64\n WHEN 1700 THEN\n CASE WHEN atttypmod = -1 THEN NULL\n ELSE (((atttypmod - 4) >> 16) & 65535)::int4\n END\n WHEN 700 THEN 24\n WHEN 701 THEN 53\n ELSE NULL\n END AS numeric_precision,\n CASE\n WHEN atttypid IN (21, 23, 20) THEN 0\n WHEN atttypid = 1700 THEN\n CASE\n WHEN atttypmod = -1 THEN NULL\n ELSE ((atttypmod - 4) & 65535)::int4\n END\n ELSE null\n END AS numeric_scale\n FROM\n pg_attribute att\n LEFT JOIN pg_class rel ON att.attrelid = rel.oid\n LEFT JOIN pg_attrdef ad ON (att.attrelid, att.attnum) = (ad.adrelid, ad.adnum)\n LEFT JOIN pg_description des ON (att.attrelid, att.attnum) = (des.objoid, des.objsubid)\n WHERE\n rel.relnamespace IN (".concat(schemaIn, ")\n ").concat(table ? 'AND rel.relname = ?' : '', "\n ").concat(column ? 'AND att.attname = ?' : '', "\n AND rel.relkind = 'r'\n AND att.attnum > 0\n AND NOT att.attisdropped\n ORDER BY rel.relname, att.attnum) res;\n "), bindings), | ||
knex.raw("\n SELECT\n con.contype AS type,\n rel.relname AS table,\n att.attname AS column,\n frel.relnamespace::regnamespace::text AS foreign_key_schema,\n frel.relname AS foreign_key_table,\n fatt.attname AS foreign_key_column,\n false AS has_auto_increment\n FROM\n pg_constraint con\n LEFT JOIN pg_class rel ON con.conrelid = rel.oid\n LEFT JOIN pg_class frel ON con.confrelid = frel.oid\n LEFT JOIN pg_attribute att ON att.attrelid = con.conrelid AND att.attnum = con.conkey[1]\n LEFT JOIN pg_attribute fatt ON fatt.attrelid = con.confrelid AND fatt.attnum = con.confkey[1]\n WHERE con.connamespace IN (".concat(schemaIn, ")\n AND array_length(con.conkey, 1) <= 1\n AND (con.confkey IS NULL OR array_length(con.confkey, 1) = 1)\n ").concat(table ? 'AND rel.relname = ?' : '', "\n ").concat(column ? 'AND att.attname = ?' : '', "\n "), bindings), | ||
])]; | ||
case 1: | ||
rawColumn = _a.sent(); | ||
return [2 /*return*/, rawColumnToColumn(rawColumn)]; | ||
case 2: return [4 /*yield*/, query]; | ||
case 3: | ||
records = _a.sent(); | ||
return [2 /*return*/, records.map(rawColumnToColumn)]; | ||
_a = _b.sent(), columns = _a[0], constraints = _a[1]; | ||
parsedColumms = columns.rows.map(function (col) { | ||
var _a, _b, _c; | ||
var constraintsForColumn = constraints.rows.filter(function (constraint) { | ||
return constraint.table === col.table && constraint.column === col.name; | ||
}); | ||
var foreignKeyConstraint = constraintsForColumn.find(function (constraint) { return constraint.type === 'f'; }); | ||
return __assign(__assign({}, col), { is_unique: constraintsForColumn.some(function (constraint) { | ||
return ['u', 'p'].includes(constraint.type); | ||
}), is_primary_key: constraintsForColumn.some(function (constraint) { return constraint.type === 'p'; }), has_auto_increment: constraintsForColumn.some(function (constraint) { return constraint.has_auto_increment; }), default_value: parseDefaultValue(col.default_value), foreign_key_schema: (_a = foreignKeyConstraint === null || foreignKeyConstraint === void 0 ? void 0 : foreignKeyConstraint.foreign_key_schema) !== null && _a !== void 0 ? _a : null, foreign_key_table: (_b = foreignKeyConstraint === null || foreignKeyConstraint === void 0 ? void 0 : foreignKeyConstraint.foreign_key_table) !== null && _b !== void 0 ? _b : null, foreign_key_column: (_c = foreignKeyConstraint === null || foreignKeyConstraint === void 0 ? void 0 : foreignKeyConstraint.foreign_key_column) !== null && _c !== void 0 ? _c : null }); | ||
}); | ||
if (table && column) | ||
return [2 /*return*/, parsedColumms[0]]; | ||
return [2 /*return*/, parsedColumms]; | ||
} | ||
@@ -264,0 +252,0 @@ }); |
@@ -15,51 +15,26 @@ import { Knex } from 'knex'; | ||
type RawColumn = { | ||
column_name: string; | ||
table_name: string; | ||
table_schema: string; | ||
name: string; | ||
table: string; | ||
schema: string; | ||
data_type: string; | ||
column_default: string | null; | ||
character_maximum_length: null | number | string; | ||
is_generated: 'NEVER' | 'ALWAYS'; | ||
is_nullable: 'YES' | 'NO'; | ||
is_unique: boolean; | ||
is_primary: boolean; | ||
is_identity: 'YES' | 'NO'; | ||
is_nullable: boolean; | ||
generation_expression: null | string; | ||
numeric_precision: null | number | string; | ||
numeric_scale: null | number | string; | ||
serial: null | string; | ||
column_comment: string | null; | ||
default_value: null | string; | ||
is_generated: boolean; | ||
max_length: null | number; | ||
comment: null | string; | ||
numeric_precision: null | number; | ||
numeric_scale: null | number; | ||
}; | ||
type Constraint = { | ||
type: 'f' | 'p' | 'u'; | ||
table: string; | ||
column: string; | ||
foreign_key_schema: null | string; | ||
foreign_key_table: null | string; | ||
foreign_key_column: null | string; | ||
has_auto_increment: null | boolean; | ||
}; | ||
function convertStringOrNumber(t: string | number | null): number | null { | ||
return t == undefined ? t : Number(t); | ||
} | ||
export function rawColumnToColumn(rawColumn: RawColumn): Column { | ||
return { | ||
name: rawColumn.column_name, | ||
table: rawColumn.table_name, | ||
data_type: rawColumn.data_type, | ||
default_value: parseDefaultValue(rawColumn.column_default), | ||
generation_expression: rawColumn.generation_expression || null, | ||
max_length: convertStringOrNumber(rawColumn.character_maximum_length), | ||
numeric_precision: convertStringOrNumber(rawColumn.numeric_precision), | ||
numeric_scale: convertStringOrNumber(rawColumn.numeric_scale), | ||
is_generated: rawColumn.is_generated === 'ALWAYS', | ||
is_nullable: rawColumn.is_nullable === 'YES', | ||
is_unique: rawColumn.is_unique, | ||
is_primary_key: rawColumn.is_primary, | ||
has_auto_increment: | ||
rawColumn.serial !== null || rawColumn.is_identity === 'YES', | ||
comment: rawColumn.column_comment, | ||
schema: rawColumn.table_schema, | ||
foreign_key_schema: rawColumn.foreign_key_schema, | ||
foreign_key_table: rawColumn.foreign_key_table, | ||
foreign_key_column: rawColumn.foreign_key_column, | ||
}; | ||
} | ||
/** | ||
@@ -223,97 +198,131 @@ * Converts CockroachDB default value to JS | ||
const query = knex | ||
.select( | ||
'c.column_name', | ||
'c.table_name', | ||
'c.data_type', | ||
'c.column_default', | ||
'c.character_maximum_length', | ||
'c.is_generated', | ||
'c.is_nullable', | ||
'c.numeric_precision', | ||
'c.numeric_scale', | ||
'c.table_schema', | ||
'c.is_identity', | ||
'c.generation_expression', | ||
const bindings: any[] = []; | ||
if (table) bindings.push(table); | ||
if (column) bindings.push(column); | ||
knex.raw( | ||
'pg_get_serial_sequence(quote_ident(c.table_name), c.column_name) as serial' | ||
), | ||
const schemaIn = this.explodedSchema.map( | ||
(schemaName) => `${this.knex.raw('?', [schemaName])}::regnamespace` | ||
); | ||
knex.raw( | ||
'pg_catalog.col_description(pg_class.oid, c.ordinal_position:: int) as column_comment' | ||
), | ||
knex.raw(`COALESCE(pg.indisunique, false) as is_unique`), | ||
knex.raw(`COALESCE(pg.indisprimary, false) as is_primary`), | ||
'ffk.foreign_key_schema', | ||
'ffk.foreign_key_table', | ||
'ffk.foreign_key_column' | ||
) | ||
.from(knex.raw('information_schema.columns c')) | ||
.joinRaw( | ||
const [columns, constraints] = await Promise.all([ | ||
knex.raw<{ rows: RawColumn[] }>( | ||
` | ||
LEFT JOIN pg_catalog.pg_class | ||
ON pg_catalog.pg_class.oid = CONCAT_WS('.', quote_ident(c.table_schema), quote_ident(c.table_name)):: regclass:: oid | ||
AND pg_catalog.pg_class.relname = c.table_name | ||
` | ||
) | ||
.joinRaw( | ||
` | ||
LEFT JOIN LATERAL ( | ||
SELECT *, CASE WHEN res.is_generated THEN ( | ||
SELECT | ||
pg_index.indisprimary, | ||
pg_index.indisunique | ||
FROM pg_index | ||
JOIN pg_attribute | ||
ON pg_attribute.attrelid = pg_index.indrelid | ||
AND pg_attribute.attnum = any(pg_index.indkey) | ||
WHERE pg_index.indrelid = quote_ident(c.table_name)::regclass | ||
AND pg_attribute.attname = c.column_name | ||
AND pg_index.indnatts = 1 | ||
LIMIT 1 | ||
) pg ON true | ||
` | ||
) | ||
.joinRaw( | ||
generation_expression | ||
FROM | ||
information_schema.columns | ||
WHERE | ||
table_schema = res.schema | ||
AND table_name = res.table | ||
AND column_name = res.name | ||
) ELSE NULL END AS generation_expression | ||
FROM ( | ||
SELECT | ||
att.attname AS name, | ||
rel.relname AS table, | ||
rel.relnamespace::regnamespace::text AS schema, | ||
format_type(att.atttypid, null) AS data_type, | ||
NOT att.attnotnull AS is_nullable, | ||
CASE WHEN att.attgenerated = '' THEN pg_get_expr(ad.adbin, ad.adrelid) ELSE null END AS default_value, | ||
att.attgenerated = 's' AS is_generated, | ||
CASE | ||
WHEN att.atttypid IN (1042, 1043) THEN (att.atttypmod - 4)::int4 | ||
WHEN att.atttypid IN (1560, 1562) THEN (att.atttypmod)::int4 | ||
ELSE NULL | ||
END AS max_length, | ||
des.description AS comment, | ||
CASE att.atttypid | ||
WHEN 21 THEN 16 | ||
WHEN 23 THEN 32 | ||
WHEN 20 THEN 64 | ||
WHEN 1700 THEN | ||
CASE WHEN atttypmod = -1 THEN NULL | ||
ELSE (((atttypmod - 4) >> 16) & 65535)::int4 | ||
END | ||
WHEN 700 THEN 24 | ||
WHEN 701 THEN 53 | ||
ELSE NULL | ||
END AS numeric_precision, | ||
CASE | ||
WHEN atttypid IN (21, 23, 20) THEN 0 | ||
WHEN atttypid = 1700 THEN | ||
CASE | ||
WHEN atttypmod = -1 THEN NULL | ||
ELSE ((atttypmod - 4) & 65535)::int4 | ||
END | ||
ELSE null | ||
END AS numeric_scale | ||
FROM | ||
pg_attribute att | ||
LEFT JOIN pg_class rel ON att.attrelid = rel.oid | ||
LEFT JOIN pg_attrdef ad ON (att.attrelid, att.attnum) = (ad.adrelid, ad.adnum) | ||
LEFT JOIN pg_description des ON (att.attrelid, att.attnum) = (des.objoid, des.objsubid) | ||
WHERE | ||
rel.relnamespace IN (${schemaIn}) | ||
${table ? 'AND rel.relname = ?' : ''} | ||
${column ? 'AND att.attname = ?' : ''} | ||
AND rel.relkind = 'r' | ||
AND att.attnum > 0 | ||
AND NOT att.attisdropped | ||
ORDER BY rel.relname, att.attnum) res; | ||
`, | ||
bindings | ||
), | ||
knex.raw<{ rows: Constraint[] }>( | ||
` | ||
LEFT JOIN LATERAL ( | ||
SELECT | ||
k2.table_schema AS foreign_key_schema, | ||
k2.table_name AS foreign_key_table, | ||
k2.column_name AS foreign_key_column | ||
FROM | ||
information_schema.key_column_usage k1 | ||
JOIN information_schema.referential_constraints fk using ( | ||
constraint_schema, constraint_name | ||
) | ||
JOIN information_schema.key_column_usage k2 | ||
ON k2.constraint_schema = fk.unique_constraint_schema | ||
AND k2.constraint_name = fk.unique_constraint_name | ||
AND k2.ordinal_position = k1.position_in_unique_constraint | ||
WHERE k1.table_name = c.table_name | ||
AND k1.column_name = c.column_name | ||
) ffk ON TRUE | ||
` | ||
) | ||
.whereIn('c.table_schema', this.explodedSchema) | ||
.andWhere('pg_class.relkind', '!=', 'S') | ||
.orderBy(['c.table_name', 'c.ordinal_position']); | ||
SELECT | ||
con.contype AS type, | ||
rel.relname AS table, | ||
att.attname AS column, | ||
frel.relnamespace::regnamespace::text AS foreign_key_schema, | ||
frel.relname AS foreign_key_table, | ||
fatt.attname AS foreign_key_column, | ||
false AS has_auto_increment | ||
FROM | ||
pg_constraint con | ||
LEFT JOIN pg_class rel ON con.conrelid = rel.oid | ||
LEFT JOIN pg_class frel ON con.confrelid = frel.oid | ||
LEFT JOIN pg_attribute att ON att.attrelid = con.conrelid AND att.attnum = con.conkey[1] | ||
LEFT JOIN pg_attribute fatt ON fatt.attrelid = con.confrelid AND fatt.attnum = con.confkey[1] | ||
WHERE con.connamespace IN (${schemaIn}) | ||
AND array_length(con.conkey, 1) <= 1 | ||
AND (con.confkey IS NULL OR array_length(con.confkey, 1) = 1) | ||
${table ? 'AND rel.relname = ?' : ''} | ||
${column ? 'AND att.attname = ?' : ''} | ||
`, | ||
bindings | ||
), | ||
]); | ||
if (table) { | ||
query.andWhere({ 'c.table_name': table }); | ||
} | ||
const parsedColumms: Column[] = columns.rows.map((col): Column => { | ||
const constraintsForColumn = constraints.rows.filter( | ||
(constraint) => | ||
constraint.table === col.table && constraint.column === col.name | ||
); | ||
if (column) { | ||
const rawColumn = await query | ||
.andWhere({ 'c.column_name': column }) | ||
.first(); | ||
const foreignKeyConstraint = constraintsForColumn.find( | ||
(constraint) => constraint.type === 'f' | ||
); | ||
return rawColumnToColumn(rawColumn); | ||
} | ||
return { | ||
...col, | ||
is_unique: constraintsForColumn.some((constraint) => | ||
['u', 'p'].includes(constraint.type) | ||
), | ||
is_primary_key: constraintsForColumn.some( | ||
(constraint) => constraint.type === 'p' | ||
), | ||
has_auto_increment: constraintsForColumn.some( | ||
(constraint) => constraint.has_auto_increment | ||
), | ||
default_value: parseDefaultValue(col.default_value), | ||
foreign_key_schema: foreignKeyConstraint?.foreign_key_schema ?? null, | ||
foreign_key_table: foreignKeyConstraint?.foreign_key_table ?? null, | ||
foreign_key_column: foreignKeyConstraint?.foreign_key_column ?? null, | ||
}; | ||
}); | ||
const records: RawColumn[] = await query; | ||
return records.map(rawColumnToColumn); | ||
if (table && column) return parsedColumms[0]; | ||
return parsedColumms; | ||
} | ||
@@ -320,0 +329,0 @@ |
{ | ||
"name": "knex-schema-inspector", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "Utility for extracting information about existing DB schema", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"scripts": { | ||
"build": "tsc --build", | ||
"prepare": "npm run build", | ||
"lint": "prettier --check .", | ||
"test": "npm run lint && ts-mocha test/**/*.spec.ts --timeout 10000" | ||
}, | ||
"repository": { | ||
@@ -71,3 +65,8 @@ "type": "git", | ||
"lodash.isnil": "^4.0.0" | ||
}, | ||
"scripts": { | ||
"build": "tsc --build", | ||
"lint": "prettier --check .", | ||
"test": "npm run lint && ts-mocha test/**/*.spec.ts --timeout 10000" | ||
} | ||
} | ||
} |
@@ -133,98 +133,38 @@ import knex, { Knex } from 'knex'; | ||
table: 'camelCase', | ||
schema: 'public', | ||
data_type: 'bigint', | ||
is_nullable: false, | ||
generation_expression: null, | ||
default_value: 'unique_rowid()', | ||
is_generated: false, | ||
max_length: null, | ||
comment: null, | ||
numeric_precision: 64, | ||
numeric_scale: 0, | ||
is_generated: false, | ||
generation_expression: null, | ||
is_nullable: false, | ||
is_unique: true, | ||
is_primary_key: true, | ||
has_auto_increment: false, | ||
foreign_key_column: null, | ||
foreign_key_schema: null, | ||
foreign_key_table: null, | ||
comment: null, | ||
schema: 'public', | ||
foreign_key_schema: null, | ||
}, | ||
{ | ||
comment: null, | ||
data_type: 'bigint', | ||
default_value: 'unique_rowid()', | ||
foreign_key_column: null, | ||
foreign_key_schema: null, | ||
foreign_key_table: null, | ||
generation_expression: null, | ||
has_auto_increment: false, | ||
is_generated: false, | ||
is_nullable: false, | ||
is_primary_key: true, | ||
is_unique: true, | ||
max_length: null, | ||
name: 'rowid', | ||
numeric_precision: 64, | ||
numeric_scale: 0, | ||
schema: 'public', | ||
table: 'page_visits', | ||
}, | ||
{ | ||
comment: null, | ||
data_type: 'bigint', | ||
default_value: null, | ||
foreign_key_column: 'primaryKey', | ||
foreign_key_schema: 'public', | ||
foreign_key_table: 'camelCase', | ||
generation_expression: null, | ||
has_auto_increment: false, | ||
is_generated: false, | ||
is_nullable: false, | ||
is_primary_key: false, | ||
is_unique: false, | ||
max_length: null, | ||
name: 'team_id', | ||
numeric_precision: 64, | ||
numeric_scale: 0, | ||
schema: 'public', | ||
table: 'users', | ||
}, | ||
{ | ||
comment: null, | ||
data_type: 'bigint', | ||
default_value: null, | ||
foreign_key_column: 'id', | ||
foreign_key_schema: 'public', | ||
foreign_key_table: 'users', | ||
generation_expression: null, | ||
has_auto_increment: false, | ||
is_generated: false, | ||
is_nullable: false, | ||
is_primary_key: false, | ||
is_unique: false, | ||
max_length: null, | ||
name: 'team_id', | ||
numeric_precision: 64, | ||
numeric_scale: 0, | ||
schema: 'public', | ||
table: 'users', | ||
}, | ||
{ | ||
name: 'request_path', | ||
table: 'page_visits', | ||
schema: 'public', | ||
data_type: 'character varying', | ||
is_nullable: true, | ||
generation_expression: null, | ||
default_value: null, | ||
is_generated: false, | ||
max_length: 100, | ||
comment: null, | ||
numeric_precision: null, | ||
numeric_scale: null, | ||
is_generated: false, | ||
generation_expression: null, | ||
is_nullable: true, | ||
is_unique: false, | ||
is_primary_key: false, | ||
has_auto_increment: false, | ||
foreign_key_schema: null, | ||
foreign_key_table: null, | ||
foreign_key_column: null, | ||
foreign_key_table: null, | ||
comment: null, | ||
schema: 'public', | ||
foreign_key_schema: null, | ||
}, | ||
@@ -234,18 +174,18 @@ { | ||
table: 'page_visits', | ||
schema: 'public', | ||
data_type: 'character varying', | ||
is_nullable: true, | ||
generation_expression: null, | ||
default_value: null, | ||
is_generated: false, | ||
max_length: 200, | ||
comment: null, | ||
numeric_precision: null, | ||
numeric_scale: null, | ||
is_generated: false, | ||
generation_expression: null, | ||
is_nullable: true, | ||
is_unique: false, | ||
is_primary_key: false, | ||
has_auto_increment: false, | ||
foreign_key_schema: null, | ||
foreign_key_table: null, | ||
foreign_key_column: null, | ||
foreign_key_table: null, | ||
comment: null, | ||
schema: 'public', | ||
foreign_key_schema: null, | ||
}, | ||
@@ -255,18 +195,38 @@ { | ||
table: 'page_visits', | ||
schema: 'public', | ||
data_type: 'timestamp without time zone', | ||
is_nullable: true, | ||
generation_expression: null, | ||
default_value: null, | ||
is_generated: false, | ||
max_length: null, | ||
comment: null, | ||
numeric_precision: null, | ||
numeric_scale: null, | ||
is_generated: false, | ||
generation_expression: null, | ||
is_nullable: true, | ||
is_unique: false, | ||
is_primary_key: false, | ||
has_auto_increment: false, | ||
foreign_key_schema: null, | ||
foreign_key_table: null, | ||
foreign_key_column: null, | ||
foreign_key_table: null, | ||
}, | ||
{ | ||
name: 'rowid', | ||
table: 'page_visits', | ||
schema: 'public', | ||
data_type: 'bigint', | ||
is_nullable: false, | ||
generation_expression: null, | ||
default_value: 'unique_rowid()', | ||
is_generated: false, | ||
max_length: null, | ||
comment: null, | ||
schema: 'public', | ||
numeric_precision: 64, | ||
numeric_scale: 0, | ||
is_unique: false, | ||
is_primary_key: false, | ||
has_auto_increment: false, | ||
foreign_key_schema: null, | ||
foreign_key_table: null, | ||
foreign_key_column: null, | ||
}, | ||
@@ -276,18 +236,18 @@ { | ||
table: 'teams', | ||
schema: 'public', | ||
data_type: 'bigint', | ||
is_nullable: false, | ||
generation_expression: null, | ||
default_value: 'unique_rowid()', | ||
is_generated: false, | ||
max_length: null, | ||
comment: null, | ||
numeric_precision: 64, | ||
numeric_scale: 0, | ||
is_generated: false, | ||
generation_expression: null, | ||
is_nullable: false, | ||
is_unique: true, | ||
is_primary_key: true, | ||
has_auto_increment: false, | ||
foreign_key_schema: null, | ||
foreign_key_table: null, | ||
foreign_key_column: null, | ||
foreign_key_table: null, | ||
comment: null, | ||
schema: 'public', | ||
foreign_key_schema: null, | ||
}, | ||
@@ -297,18 +257,18 @@ { | ||
table: 'teams', | ||
schema: 'public', | ||
data_type: 'character', | ||
is_nullable: false, | ||
generation_expression: null, | ||
default_value: null, | ||
is_generated: false, | ||
max_length: 36, | ||
comment: null, | ||
numeric_precision: null, | ||
numeric_scale: null, | ||
is_generated: false, | ||
generation_expression: null, | ||
is_nullable: false, | ||
is_unique: true, | ||
is_primary_key: false, | ||
has_auto_increment: false, | ||
foreign_key_schema: null, | ||
foreign_key_table: null, | ||
foreign_key_column: null, | ||
foreign_key_table: null, | ||
comment: null, | ||
schema: 'public', | ||
foreign_key_schema: null, | ||
}, | ||
@@ -318,18 +278,18 @@ { | ||
table: 'teams', | ||
schema: 'public', | ||
data_type: 'character varying', | ||
is_nullable: true, | ||
generation_expression: null, | ||
default_value: null, | ||
is_generated: false, | ||
max_length: 100, | ||
comment: null, | ||
numeric_precision: null, | ||
numeric_scale: null, | ||
is_generated: false, | ||
generation_expression: null, | ||
is_nullable: true, | ||
is_unique: false, | ||
is_primary_key: false, | ||
has_auto_increment: false, | ||
foreign_key_schema: null, | ||
foreign_key_table: null, | ||
foreign_key_column: null, | ||
foreign_key_table: null, | ||
comment: null, | ||
schema: 'public', | ||
foreign_key_schema: null, | ||
}, | ||
@@ -339,18 +299,18 @@ { | ||
table: 'teams', | ||
schema: 'public', | ||
data_type: 'character varying', | ||
is_nullable: true, | ||
generation_expression: 'upper(name)', | ||
default_value: null, | ||
is_generated: true, | ||
max_length: 100, | ||
comment: null, | ||
numeric_precision: null, | ||
numeric_scale: null, | ||
is_generated: false, | ||
generation_expression: 'upper(name)', | ||
is_nullable: true, | ||
is_unique: false, | ||
is_primary_key: false, | ||
has_auto_increment: false, | ||
foreign_key_schema: null, | ||
foreign_key_table: null, | ||
foreign_key_column: null, | ||
foreign_key_table: null, | ||
comment: null, | ||
schema: 'public', | ||
foreign_key_schema: null, | ||
}, | ||
@@ -360,18 +320,18 @@ { | ||
table: 'teams', | ||
schema: 'public', | ||
data_type: 'text', | ||
is_nullable: true, | ||
generation_expression: null, | ||
default_value: null, | ||
is_generated: false, | ||
max_length: null, | ||
comment: null, | ||
numeric_precision: null, | ||
numeric_scale: null, | ||
is_generated: false, | ||
generation_expression: null, | ||
is_nullable: true, | ||
is_unique: false, | ||
is_primary_key: false, | ||
has_auto_increment: false, | ||
foreign_key_schema: null, | ||
foreign_key_table: null, | ||
foreign_key_column: null, | ||
foreign_key_table: null, | ||
comment: null, | ||
schema: 'public', | ||
foreign_key_schema: null, | ||
}, | ||
@@ -381,18 +341,18 @@ { | ||
table: 'teams', | ||
schema: 'public', | ||
data_type: 'bigint', | ||
is_nullable: true, | ||
generation_expression: null, | ||
default_value: null, | ||
is_generated: false, | ||
max_length: null, | ||
comment: 'Remaining usage credits', | ||
numeric_precision: 64, | ||
numeric_scale: 0, | ||
is_generated: false, | ||
generation_expression: null, | ||
is_nullable: true, | ||
is_unique: false, | ||
is_primary_key: false, | ||
has_auto_increment: false, | ||
foreign_key_schema: null, | ||
foreign_key_table: null, | ||
foreign_key_column: null, | ||
foreign_key_table: null, | ||
comment: 'Remaining usage credits', | ||
schema: 'public', | ||
foreign_key_schema: null, | ||
}, | ||
@@ -402,18 +362,18 @@ { | ||
table: 'teams', | ||
schema: 'public', | ||
data_type: 'timestamp without time zone', | ||
is_nullable: true, | ||
generation_expression: null, | ||
default_value: null, | ||
is_generated: false, | ||
max_length: null, | ||
comment: null, | ||
numeric_precision: null, | ||
numeric_scale: null, | ||
is_generated: false, | ||
generation_expression: null, | ||
is_nullable: true, | ||
is_unique: false, | ||
is_primary_key: false, | ||
has_auto_increment: false, | ||
foreign_key_schema: null, | ||
foreign_key_table: null, | ||
foreign_key_column: null, | ||
foreign_key_table: null, | ||
comment: null, | ||
schema: 'public', | ||
foreign_key_schema: null, | ||
}, | ||
@@ -423,18 +383,18 @@ { | ||
table: 'teams', | ||
schema: 'public', | ||
data_type: 'date', | ||
is_nullable: true, | ||
generation_expression: null, | ||
default_value: null, | ||
is_generated: false, | ||
max_length: null, | ||
comment: null, | ||
numeric_precision: null, | ||
numeric_scale: null, | ||
is_generated: false, | ||
generation_expression: null, | ||
is_nullable: true, | ||
is_unique: false, | ||
is_primary_key: false, | ||
has_auto_increment: false, | ||
foreign_key_schema: null, | ||
foreign_key_table: null, | ||
foreign_key_column: null, | ||
foreign_key_table: null, | ||
comment: null, | ||
schema: 'public', | ||
foreign_key_schema: null, | ||
}, | ||
@@ -444,18 +404,18 @@ { | ||
table: 'users', | ||
schema: 'public', | ||
data_type: 'bigint', | ||
is_nullable: false, | ||
generation_expression: null, | ||
default_value: 'unique_rowid()', | ||
is_generated: false, | ||
max_length: null, | ||
comment: null, | ||
numeric_precision: 64, | ||
numeric_scale: 0, | ||
is_generated: false, | ||
generation_expression: null, | ||
is_nullable: false, | ||
is_unique: true, | ||
is_primary_key: true, | ||
has_auto_increment: false, | ||
foreign_key_schema: null, | ||
foreign_key_table: null, | ||
foreign_key_column: null, | ||
foreign_key_table: null, | ||
comment: null, | ||
schema: 'public', | ||
foreign_key_schema: null, | ||
}, | ||
@@ -465,18 +425,18 @@ { | ||
table: 'users', | ||
schema: 'public', | ||
data_type: 'bigint', | ||
is_nullable: false, | ||
generation_expression: null, | ||
default_value: null, | ||
is_generated: false, | ||
max_length: null, | ||
comment: null, | ||
numeric_precision: 64, | ||
numeric_scale: 0, | ||
is_generated: false, | ||
generation_expression: null, | ||
is_nullable: false, | ||
is_unique: false, | ||
is_primary_key: false, | ||
has_auto_increment: false, | ||
foreign_key_schema: 'public', | ||
foreign_key_table: 'teams', | ||
foreign_key_column: 'id', | ||
foreign_key_table: 'teams', | ||
comment: null, | ||
schema: 'public', | ||
foreign_key_schema: 'public', | ||
}, | ||
@@ -486,18 +446,18 @@ { | ||
table: 'users', | ||
schema: 'public', | ||
data_type: 'character varying', | ||
is_nullable: true, | ||
generation_expression: null, | ||
default_value: null, | ||
is_generated: false, | ||
max_length: 100, | ||
comment: null, | ||
numeric_precision: null, | ||
numeric_scale: null, | ||
is_generated: false, | ||
generation_expression: null, | ||
is_nullable: true, | ||
is_unique: false, | ||
is_primary_key: false, | ||
has_auto_increment: false, | ||
foreign_key_schema: null, | ||
foreign_key_table: null, | ||
foreign_key_column: null, | ||
foreign_key_table: null, | ||
comment: null, | ||
schema: 'public', | ||
foreign_key_schema: null, | ||
}, | ||
@@ -507,18 +467,18 @@ { | ||
table: 'users', | ||
schema: 'public', | ||
data_type: 'character varying', | ||
is_nullable: true, | ||
generation_expression: null, | ||
default_value: null, | ||
is_generated: false, | ||
max_length: 60, | ||
comment: null, | ||
numeric_precision: null, | ||
numeric_scale: null, | ||
is_generated: false, | ||
generation_expression: null, | ||
is_nullable: true, | ||
is_unique: false, | ||
is_primary_key: false, | ||
has_auto_increment: false, | ||
foreign_key_schema: null, | ||
foreign_key_table: null, | ||
foreign_key_column: null, | ||
foreign_key_table: null, | ||
comment: null, | ||
schema: 'public', | ||
foreign_key_schema: null, | ||
}, | ||
@@ -528,18 +488,18 @@ { | ||
table: 'users', | ||
schema: 'public', | ||
data_type: 'character varying', | ||
is_nullable: true, | ||
generation_expression: null, | ||
default_value: 'active', | ||
is_generated: false, | ||
max_length: 60, | ||
comment: null, | ||
numeric_precision: null, | ||
numeric_scale: null, | ||
is_generated: false, | ||
generation_expression: null, | ||
is_nullable: true, | ||
is_unique: false, | ||
is_primary_key: false, | ||
has_auto_increment: false, | ||
foreign_key_schema: null, | ||
foreign_key_table: null, | ||
foreign_key_column: null, | ||
foreign_key_table: null, | ||
comment: null, | ||
schema: 'public', | ||
foreign_key_schema: null, | ||
}, | ||
@@ -619,3 +579,3 @@ ]); | ||
numeric_scale: null, | ||
is_generated: false, | ||
is_generated: true, | ||
generation_expression: 'upper(name)', | ||
@@ -622,0 +582,0 @@ is_nullable: true, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
408288
9088
5