@mikro-orm/knex
Version:
TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.
27 lines (26 loc) • 1.12 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MySqlColumnCompiler = void 0;
// @ts-ignore
const mysql_columncompiler_1 = __importDefault(require("knex/lib/dialects/mysql/schema/mysql-columncompiler"));
class MySqlColumnCompiler extends mysql_columncompiler_1.default {
// we need the old behaviour to be able to add auto_increment to a column that is already PK
increments(options) {
return this.generateDDL(options);
}
/* istanbul ignore next */
bigincrements(options) {
return this.generateDDL({ type: 'bigint', ...options });
}
generateDDL(options = {}) {
const { primaryKey = true, unsigned = true, type = 'int' } = options;
return type
+ (unsigned ? ' unsigned' : '')
+ ' not null auto_increment'
+ (this.tableCompiler._canBeAddPrimaryKey({ primaryKey }) ? ' primary key' : '');
}
}
exports.MySqlColumnCompiler = MySqlColumnCompiler;