PATH:
usr
/
local
/
lib
/
node_modules
/
knex-migrator
/
node_modules
/
knex
/
lib
/
dialects
/
mssql
/
schema
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _inherits = _interopRequireDefault(require("inherits")); var _compiler = _interopRequireDefault(require("../../../schema/compiler")); var _lodash = require("lodash"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // MySQL Schema Compiler // ------- function SchemaCompiler_MSSQL(client, builder) { _compiler.default.call(this, client, builder); } (0, _inherits.default)(SchemaCompiler_MSSQL, _compiler.default); (0, _lodash.assign)(SchemaCompiler_MSSQL.prototype, { dropTablePrefix: 'DROP TABLE ', dropTableIfExists(tableName) { const name = this.formatter.wrap(prefixedTableName(this.schema, tableName)); this.pushQuery(`if object_id('${name}', 'U') is not null DROP TABLE ${name}`); }, // Rename a table on the schema. renameTable(tableName, to) { this.pushQuery(`exec sp_rename ${this.formatter.parameter(prefixedTableName(this.schema, tableName))}, ${this.formatter.parameter(to)}`); }, // Check whether a table exists on the query. hasTable(tableName) { const formattedTable = this.formatter.parameter(this.formatter.wrap(prefixedTableName(this.schema, tableName))); const sql = `select object_id from sys.tables ` + `where object_id = object_id(${formattedTable})`; this.pushQuery({ sql, output: resp => resp.length > 0 }); }, // Check whether a column exists on the schema. hasColumn(tableName, column) { const formattedColumn = this.formatter.parameter(column); const formattedTable = this.formatter.parameter(this.formatter.wrap(prefixedTableName(this.schema, tableName))); const sql = `select object_id from sys.columns ` + `where name = ${formattedColumn} ` + `and object_id = object_id(${formattedTable})`; this.pushQuery({ sql, output: resp => resp.length > 0 }); } }); function prefixedTableName(prefix, table) { return prefix ? `${prefix}.${table}` : table; } var _default = SchemaCompiler_MSSQL; exports.default = _default; module.exports = exports.default;
[+]
..
[-] tablecompiler.js
[edit]
[-] columncompiler.js
[edit]
[-] compiler.js
[edit]