2020-12-25 20:33:06 +02:00
|
|
|
/* eslint max-len:0*/
|
2016-03-02 17:07:05 +01:00
|
|
|
|
|
|
|
// MySQL Table Builder & Compiler
|
|
|
|
// -------
|
2019-06-04 00:37:17 +02:00
|
|
|
const TableCompiler = require('../../../schema/tablecompiler');
|
2021-10-25 23:37:26 +02:00
|
|
|
const { isObject, isString } = require('../../../util/is');
|
2016-03-02 17:07:05 +01:00
|
|
|
|
|
|
|
// Table Compiler
|
|
|
|
// ------
|
|
|
|
|
2021-01-01 18:46:16 +02:00
|
|
|
class TableCompiler_MySQL extends TableCompiler {
|
2021-02-04 15:54:26 +02:00
|
|
|
constructor(client, tableBuilder) {
|
|
|
|
super(client, tableBuilder);
|
2021-01-01 18:46:16 +02:00
|
|
|
}
|
2016-03-02 17:07:05 +01:00
|
|
|
|
2021-10-15 15:57:46 +02:00
|
|
|
createQuery(columns, ifNot, like) {
|
2018-07-09 08:10:34 -04:00
|
|
|
const createStatement = ifNot
|
|
|
|
? 'create table if not exists '
|
|
|
|
: 'create table ';
|
2016-05-17 01:01:34 +10:00
|
|
|
const { client } = this;
|
|
|
|
let conn = {};
|
2022-02-10 18:06:23 +01:00
|
|
|
let columnsSql = ' (' + columns.sql.join(', ');
|
|
|
|
|
|
|
|
columnsSql += this.primaryKeys() || '';
|
|
|
|
columnsSql += this._addChecks();
|
|
|
|
columnsSql += ')';
|
|
|
|
|
2018-07-09 08:10:34 -04:00
|
|
|
let sql =
|
2021-10-15 15:57:46 +02:00
|
|
|
createStatement +
|
|
|
|
this.tableName() +
|
|
|
|
(like && this.tableNameLike()
|
|
|
|
? ' like ' + this.tableNameLike()
|
|
|
|
: columnsSql);
|
2016-03-02 17:07:05 +01:00
|
|
|
|
|
|
|
// Check if the connection settings are set.
|
|
|
|
if (client.connectionSettings) {
|
|
|
|
conn = client.connectionSettings;
|
|
|
|
}
|
|
|
|
|
2016-05-18 19:59:24 +10:00
|
|
|
const charset = this.single.charset || conn.charset || '';
|
2016-05-17 01:01:34 +10:00
|
|
|
const collation = this.single.collate || conn.collate || '';
|
2018-07-09 08:10:34 -04:00
|
|
|
const engine = this.single.engine || '';
|
2016-03-02 17:07:05 +01:00
|
|
|
|
2021-10-15 15:57:46 +02:00
|
|
|
if (charset && !like) sql += ` default character set ${charset}`;
|
2016-05-17 01:01:34 +10:00
|
|
|
if (collation) sql += ` collate ${collation}`;
|
2018-07-09 08:10:34 -04:00
|
|
|
if (engine) sql += ` engine = ${engine}`;
|
2016-03-02 17:07:05 +01:00
|
|
|
|
|
|
|
if (this.single.comment) {
|
2018-07-09 08:10:34 -04:00
|
|
|
const comment = this.single.comment || '';
|
2021-12-05 22:09:24 +01:00
|
|
|
const MAX_COMMENT_LENGTH = 1024;
|
|
|
|
if (comment.length > MAX_COMMENT_LENGTH)
|
2018-07-09 08:10:34 -04:00
|
|
|
this.client.logger.warn(
|
2021-12-05 22:09:24 +01:00
|
|
|
`The max length for a table comment is ${MAX_COMMENT_LENGTH} characters`
|
2018-07-09 08:10:34 -04:00
|
|
|
);
|
2016-05-17 01:01:34 +10:00
|
|
|
sql += ` comment = '${comment}'`;
|
2016-03-02 17:07:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
this.pushQuery(sql);
|
2021-11-10 21:24:34 +01:00
|
|
|
if (like) {
|
|
|
|
this.addColumns(columns, this.addColumnsPrefix);
|
|
|
|
}
|
2021-01-01 18:46:16 +02:00
|
|
|
}
|
2016-03-02 17:07:05 +01:00
|
|
|
|
|
|
|
// Compiles the comment on the table.
|
2016-05-17 01:01:34 +10:00
|
|
|
comment(comment) {
|
|
|
|
this.pushQuery(`alter table ${this.tableName()} comment = '${comment}'`);
|
2021-01-01 18:46:16 +02:00
|
|
|
}
|
2016-03-02 17:07:05 +01:00
|
|
|
|
2016-05-17 01:01:34 +10:00
|
|
|
changeType() {
|
2016-03-02 17:07:05 +01:00
|
|
|
// alter table + table + ' modify ' + wrapped + '// type';
|
2021-01-01 18:46:16 +02:00
|
|
|
}
|
2016-03-02 17:07:05 +01:00
|
|
|
|
|
|
|
// Renames a column on the table.
|
2016-05-17 01:01:34 +10:00
|
|
|
renameColumn(from, to) {
|
|
|
|
const compiler = this;
|
2016-05-18 19:59:24 +10:00
|
|
|
const table = this.tableName();
|
|
|
|
const wrapped = this.formatter.wrap(from) + ' ' + this.formatter.wrap(to);
|
2016-03-02 17:07:05 +01:00
|
|
|
|
|
|
|
this.pushQuery({
|
2018-07-09 08:10:34 -04:00
|
|
|
sql:
|
2022-02-01 08:00:05 -05:00
|
|
|
`show full fields from ${table} where field = ` +
|
2021-02-04 15:54:26 +02:00
|
|
|
this.client.parameter(from, this.tableBuilder, this.bindingsHolder),
|
2016-05-17 01:01:34 +10:00
|
|
|
output(resp) {
|
|
|
|
const column = resp[0];
|
|
|
|
const runner = this;
|
2019-06-18 00:07:24 +02:00
|
|
|
return compiler.getFKRefs(runner).then(([refs]) =>
|
|
|
|
new Promise((resolve, reject) => {
|
|
|
|
try {
|
|
|
|
if (!refs.length) {
|
|
|
|
resolve();
|
2016-04-01 23:28:15 +02:00
|
|
|
}
|
2019-06-18 00:07:24 +02:00
|
|
|
resolve(compiler.dropFKRefs(runner, refs));
|
|
|
|
} catch (e) {
|
|
|
|
reject(e);
|
|
|
|
}
|
|
|
|
})
|
2020-04-19 00:40:23 +02:00
|
|
|
.then(function () {
|
2019-06-18 00:07:24 +02:00
|
|
|
let sql = `alter table ${table} change ${wrapped} ${column.Type}`;
|
|
|
|
|
|
|
|
if (String(column.Null).toUpperCase() !== 'YES') {
|
|
|
|
sql += ` NOT NULL`;
|
|
|
|
} else {
|
|
|
|
// This doesn't matter for most cases except Timestamp, where this is important
|
|
|
|
sql += ` NULL`;
|
|
|
|
}
|
|
|
|
if (column.Default !== void 0 && column.Default !== null) {
|
|
|
|
sql += ` DEFAULT '${column.Default}'`;
|
|
|
|
}
|
2022-02-01 08:00:05 -05:00
|
|
|
if (column.Collation !== void 0 && column.Collation !== null) {
|
|
|
|
sql += ` COLLATE '${column.Collation}'`;
|
|
|
|
}
|
|
|
|
// Add back the auto increment if the column it, fix issue #2767
|
2021-02-03 13:47:32 +01:00
|
|
|
if (column.Extra == 'auto_increment') {
|
|
|
|
sql += ` AUTO_INCREMENT`;
|
|
|
|
}
|
2019-06-18 00:07:24 +02:00
|
|
|
|
|
|
|
return runner.query({
|
|
|
|
sql,
|
|
|
|
});
|
2018-07-09 08:10:34 -04:00
|
|
|
})
|
2020-04-19 00:40:23 +02:00
|
|
|
.then(function () {
|
2019-06-18 00:07:24 +02:00
|
|
|
if (!refs.length) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
return compiler.createFKRefs(
|
|
|
|
runner,
|
2020-04-19 00:40:23 +02:00
|
|
|
refs.map(function (ref) {
|
2019-06-18 00:07:24 +02:00
|
|
|
if (ref.REFERENCED_COLUMN_NAME === from) {
|
|
|
|
ref.REFERENCED_COLUMN_NAME = to;
|
|
|
|
}
|
|
|
|
if (ref.COLUMN_NAME === from) {
|
|
|
|
ref.COLUMN_NAME = to;
|
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
})
|
|
|
|
);
|
|
|
|
})
|
|
|
|
);
|
2018-07-09 08:10:34 -04:00
|
|
|
},
|
2016-03-02 17:07:05 +01:00
|
|
|
});
|
2021-01-01 18:46:16 +02:00
|
|
|
}
|
2016-03-02 17:07:05 +01:00
|
|
|
|
2022-02-10 18:06:23 +01:00
|
|
|
primaryKeys() {
|
|
|
|
const pks = (this.grouped.alterTable || []).filter(
|
|
|
|
(k) => k.method === 'primary'
|
|
|
|
);
|
|
|
|
if (pks.length > 0 && pks[0].args.length > 0) {
|
|
|
|
const columns = pks[0].args[0];
|
|
|
|
let constraintName = pks[0].args[1] || '';
|
|
|
|
if (constraintName) {
|
|
|
|
constraintName = ' constraint ' + this.formatter.wrap(constraintName);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.grouped.columns) {
|
|
|
|
const incrementsCols = this._getIncrementsColumnNames();
|
|
|
|
if (incrementsCols.length) {
|
|
|
|
incrementsCols.forEach((c) => {
|
|
|
|
if (!columns.includes(c)) {
|
|
|
|
columns.unshift(c);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2023-11-29 01:10:12 +01:00
|
|
|
const bigIncrementsCols = this._getBigIncrementsColumnNames();
|
|
|
|
if (bigIncrementsCols.length) {
|
|
|
|
bigIncrementsCols.forEach((c) => {
|
|
|
|
if (!columns.includes(c)) {
|
|
|
|
columns.unshift(c);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-02-10 18:06:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return `,${constraintName} primary key (${this.formatter.columnize(
|
|
|
|
columns
|
|
|
|
)})`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-09 08:10:34 -04:00
|
|
|
getFKRefs(runner) {
|
2021-02-04 15:54:26 +02:00
|
|
|
const bindingsHolder = {
|
|
|
|
bindings: [],
|
|
|
|
};
|
|
|
|
|
2018-07-09 08:10:34 -04:00
|
|
|
const sql =
|
|
|
|
'SELECT KCU.CONSTRAINT_NAME, KCU.TABLE_NAME, KCU.COLUMN_NAME, ' +
|
|
|
|
' KCU.REFERENCED_TABLE_NAME, KCU.REFERENCED_COLUMN_NAME, ' +
|
|
|
|
' RC.UPDATE_RULE, RC.DELETE_RULE ' +
|
|
|
|
'FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU ' +
|
|
|
|
'JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ' +
|
|
|
|
' USING(CONSTRAINT_NAME)' +
|
|
|
|
'WHERE KCU.REFERENCED_TABLE_NAME = ' +
|
2021-02-04 15:54:26 +02:00
|
|
|
this.client.parameter(
|
|
|
|
this.tableNameRaw,
|
|
|
|
this.tableBuilder,
|
|
|
|
bindingsHolder
|
|
|
|
) +
|
2018-07-09 08:10:34 -04:00
|
|
|
' ' +
|
|
|
|
' AND KCU.CONSTRAINT_SCHEMA = ' +
|
2021-02-04 15:54:26 +02:00
|
|
|
this.client.parameter(
|
|
|
|
this.client.database(),
|
|
|
|
this.tableBuilder,
|
|
|
|
bindingsHolder
|
|
|
|
) +
|
2018-07-09 08:10:34 -04:00
|
|
|
' ' +
|
|
|
|
' AND RC.CONSTRAINT_SCHEMA = ' +
|
2021-02-04 15:54:26 +02:00
|
|
|
this.client.parameter(
|
|
|
|
this.client.database(),
|
|
|
|
this.tableBuilder,
|
|
|
|
bindingsHolder
|
|
|
|
);
|
2016-03-02 17:07:05 +01:00
|
|
|
|
|
|
|
return runner.query({
|
2016-05-17 01:01:34 +10:00
|
|
|
sql,
|
2021-02-04 15:54:26 +02:00
|
|
|
bindings: bindingsHolder.bindings,
|
2016-03-02 17:07:05 +01:00
|
|
|
});
|
2021-01-01 18:46:16 +02:00
|
|
|
}
|
2016-03-02 17:07:05 +01:00
|
|
|
|
2018-07-09 08:10:34 -04:00
|
|
|
dropFKRefs(runner, refs) {
|
2018-02-01 23:41:01 +01:00
|
|
|
const formatter = this.client.formatter(this.tableBuilder);
|
2016-03-02 17:07:05 +01:00
|
|
|
|
2018-07-09 08:10:34 -04:00
|
|
|
return Promise.all(
|
2020-04-19 00:40:23 +02:00
|
|
|
refs.map(function (ref) {
|
2018-07-09 08:10:34 -04:00
|
|
|
const constraintName = formatter.wrap(ref.CONSTRAINT_NAME);
|
|
|
|
const tableName = formatter.wrap(ref.TABLE_NAME);
|
|
|
|
return runner.query({
|
|
|
|
sql: `alter table ${tableName} drop foreign key ${constraintName}`,
|
|
|
|
});
|
|
|
|
})
|
|
|
|
);
|
2021-01-01 18:46:16 +02:00
|
|
|
}
|
|
|
|
|
2018-07-09 08:10:34 -04:00
|
|
|
createFKRefs(runner, refs) {
|
2018-02-01 23:41:01 +01:00
|
|
|
const formatter = this.client.formatter(this.tableBuilder);
|
2016-03-02 17:07:05 +01:00
|
|
|
|
2018-07-09 08:10:34 -04:00
|
|
|
return Promise.all(
|
2020-04-19 00:40:23 +02:00
|
|
|
refs.map(function (ref) {
|
2018-07-09 08:10:34 -04:00
|
|
|
const tableName = formatter.wrap(ref.TABLE_NAME);
|
|
|
|
const keyName = formatter.wrap(ref.CONSTRAINT_NAME);
|
|
|
|
const column = formatter.columnize(ref.COLUMN_NAME);
|
|
|
|
const references = formatter.columnize(ref.REFERENCED_COLUMN_NAME);
|
|
|
|
const inTable = formatter.wrap(ref.REFERENCED_TABLE_NAME);
|
|
|
|
const onUpdate = ` ON UPDATE ${ref.UPDATE_RULE}`;
|
|
|
|
const onDelete = ` ON DELETE ${ref.DELETE_RULE}`;
|
|
|
|
|
|
|
|
return runner.query({
|
|
|
|
sql:
|
|
|
|
`alter table ${tableName} add constraint ${keyName} ` +
|
|
|
|
'foreign key (' +
|
|
|
|
column +
|
|
|
|
') references ' +
|
|
|
|
inTable +
|
|
|
|
' (' +
|
|
|
|
references +
|
|
|
|
')' +
|
|
|
|
onUpdate +
|
|
|
|
onDelete,
|
|
|
|
});
|
|
|
|
})
|
|
|
|
);
|
2021-01-01 18:46:16 +02:00
|
|
|
}
|
|
|
|
|
2021-10-25 23:37:26 +02:00
|
|
|
index(columns, indexName, options) {
|
2021-10-21 00:20:56 +02:00
|
|
|
let storageEngineIndexType;
|
2021-10-25 23:37:26 +02:00
|
|
|
let indexType;
|
|
|
|
|
|
|
|
if (isString(options)) {
|
|
|
|
indexType = options;
|
|
|
|
} else if (isObject(options)) {
|
|
|
|
({ indexType, storageEngineIndexType } = options);
|
2021-10-21 00:20:56 +02:00
|
|
|
}
|
|
|
|
|
2018-07-09 08:10:34 -04:00
|
|
|
indexName = indexName
|
|
|
|
? this.formatter.wrap(indexName)
|
|
|
|
: this._indexCommand('index', this.tableNameRaw, columns);
|
2021-10-21 00:20:56 +02:00
|
|
|
storageEngineIndexType = storageEngineIndexType
|
|
|
|
? ` using ${storageEngineIndexType}`
|
|
|
|
: '';
|
2018-07-09 08:10:34 -04:00
|
|
|
this.pushQuery(
|
2018-11-10 13:36:10 -02:00
|
|
|
`alter table ${this.tableName()} add${
|
|
|
|
indexType ? ` ${indexType}` : ''
|
2021-10-21 00:20:56 +02:00
|
|
|
} index ${indexName}(${this.formatter.columnize(
|
|
|
|
columns
|
|
|
|
)})${storageEngineIndexType}`
|
2018-07-09 08:10:34 -04:00
|
|
|
);
|
2021-01-01 18:46:16 +02:00
|
|
|
}
|
2016-03-02 17:07:05 +01:00
|
|
|
|
2016-05-19 21:30:17 +02:00
|
|
|
primary(columns, constraintName) {
|
2021-10-10 15:47:32 -04:00
|
|
|
let deferrable;
|
|
|
|
if (isObject(constraintName)) {
|
|
|
|
({ constraintName, deferrable } = constraintName);
|
|
|
|
}
|
|
|
|
if (deferrable && deferrable !== 'not deferrable') {
|
|
|
|
this.client.logger.warn(
|
|
|
|
`mysql: primary key constraint \`${constraintName}\` will not be deferrable ${deferrable} because mysql does not support deferred constraints.`
|
|
|
|
);
|
|
|
|
}
|
2018-07-09 08:10:34 -04:00
|
|
|
constraintName = constraintName
|
|
|
|
? this.formatter.wrap(constraintName)
|
|
|
|
: this.formatter.wrap(`${this.tableNameRaw}_pkey`);
|
2022-01-03 20:55:24 +01:00
|
|
|
|
|
|
|
const primaryCols = columns;
|
|
|
|
let incrementsCols = [];
|
2023-11-29 01:10:12 +01:00
|
|
|
let bigIncrementsCols = [];
|
2022-01-03 20:55:24 +01:00
|
|
|
if (this.grouped.columns) {
|
|
|
|
incrementsCols = this._getIncrementsColumnNames();
|
|
|
|
if (incrementsCols) {
|
|
|
|
incrementsCols.forEach((c) => {
|
|
|
|
if (!primaryCols.includes(c)) {
|
|
|
|
primaryCols.unshift(c);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2023-11-29 01:10:12 +01:00
|
|
|
bigIncrementsCols = this._getBigIncrementsColumnNames();
|
|
|
|
if (bigIncrementsCols) {
|
|
|
|
bigIncrementsCols.forEach((c) => {
|
|
|
|
if (!primaryCols.includes(c)) {
|
|
|
|
primaryCols.unshift(c);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-01-03 20:55:24 +01:00
|
|
|
}
|
2022-02-10 18:06:23 +01:00
|
|
|
if (this.method !== 'create' && this.method !== 'createIfNot') {
|
|
|
|
this.pushQuery(
|
|
|
|
`alter table ${this.tableName()} add primary key ${constraintName}(${this.formatter.columnize(
|
|
|
|
primaryCols
|
|
|
|
)})`
|
|
|
|
);
|
|
|
|
}
|
2022-01-03 20:55:24 +01:00
|
|
|
if (incrementsCols.length) {
|
|
|
|
this.pushQuery(
|
|
|
|
`alter table ${this.tableName()} modify column ${this.formatter.columnize(
|
|
|
|
incrementsCols
|
|
|
|
)} int unsigned not null auto_increment`
|
|
|
|
);
|
|
|
|
}
|
2023-11-29 01:10:12 +01:00
|
|
|
if (bigIncrementsCols.length) {
|
|
|
|
this.pushQuery(
|
|
|
|
`alter table ${this.tableName()} modify column ${this.formatter.columnize(
|
|
|
|
bigIncrementsCols
|
|
|
|
)} bigint unsigned not null auto_increment`
|
|
|
|
);
|
|
|
|
}
|
2021-01-01 18:46:16 +02:00
|
|
|
}
|
2016-03-02 17:07:05 +01:00
|
|
|
|
2016-05-17 01:01:34 +10:00
|
|
|
unique(columns, indexName) {
|
2021-10-21 00:20:56 +02:00
|
|
|
let storageEngineIndexType;
|
2021-10-10 15:47:32 -04:00
|
|
|
let deferrable;
|
|
|
|
if (isObject(indexName)) {
|
2021-10-21 00:20:56 +02:00
|
|
|
({ indexName, deferrable, storageEngineIndexType } = indexName);
|
2021-10-10 15:47:32 -04:00
|
|
|
}
|
|
|
|
if (deferrable && deferrable !== 'not deferrable') {
|
|
|
|
this.client.logger.warn(
|
|
|
|
`mysql: unique index \`${indexName}\` will not be deferrable ${deferrable} because mysql does not support deferred constraints.`
|
|
|
|
);
|
|
|
|
}
|
2018-07-09 08:10:34 -04:00
|
|
|
indexName = indexName
|
|
|
|
? this.formatter.wrap(indexName)
|
|
|
|
: this._indexCommand('unique', this.tableNameRaw, columns);
|
2021-10-21 00:20:56 +02:00
|
|
|
storageEngineIndexType = storageEngineIndexType
|
|
|
|
? ` using ${storageEngineIndexType}`
|
|
|
|
: '';
|
2018-07-09 08:10:34 -04:00
|
|
|
this.pushQuery(
|
|
|
|
`alter table ${this.tableName()} add unique ${indexName}(${this.formatter.columnize(
|
|
|
|
columns
|
2021-10-21 00:20:56 +02:00
|
|
|
)})${storageEngineIndexType}`
|
2018-07-09 08:10:34 -04:00
|
|
|
);
|
2021-01-01 18:46:16 +02:00
|
|
|
}
|
2016-03-02 17:07:05 +01:00
|
|
|
|
|
|
|
// Compile a drop index command.
|
2016-05-17 01:01:34 +10:00
|
|
|
dropIndex(columns, indexName) {
|
2018-07-09 08:10:34 -04:00
|
|
|
indexName = indexName
|
|
|
|
? this.formatter.wrap(indexName)
|
|
|
|
: this._indexCommand('index', this.tableNameRaw, columns);
|
2016-05-17 01:01:34 +10:00
|
|
|
this.pushQuery(`alter table ${this.tableName()} drop index ${indexName}`);
|
2021-01-01 18:46:16 +02:00
|
|
|
}
|
2016-03-02 17:07:05 +01:00
|
|
|
|
|
|
|
// Compile a drop foreign key command.
|
2016-05-17 01:01:34 +10:00
|
|
|
dropForeign(columns, indexName) {
|
2018-07-09 08:10:34 -04:00
|
|
|
indexName = indexName
|
|
|
|
? this.formatter.wrap(indexName)
|
|
|
|
: this._indexCommand('foreign', this.tableNameRaw, columns);
|
|
|
|
this.pushQuery(
|
|
|
|
`alter table ${this.tableName()} drop foreign key ${indexName}`
|
|
|
|
);
|
2021-01-01 18:46:16 +02:00
|
|
|
}
|
2016-03-02 17:07:05 +01:00
|
|
|
|
|
|
|
// Compile a drop primary key command.
|
2016-05-17 01:01:34 +10:00
|
|
|
dropPrimary() {
|
|
|
|
this.pushQuery(`alter table ${this.tableName()} drop primary key`);
|
2021-01-01 18:46:16 +02:00
|
|
|
}
|
2016-03-02 17:07:05 +01:00
|
|
|
|
|
|
|
// Compile a drop unique key command.
|
2016-05-17 01:01:34 +10:00
|
|
|
dropUnique(column, indexName) {
|
2018-07-09 08:10:34 -04:00
|
|
|
indexName = indexName
|
|
|
|
? this.formatter.wrap(indexName)
|
|
|
|
: this._indexCommand('unique', this.tableNameRaw, column);
|
2016-05-17 01:01:34 +10:00
|
|
|
this.pushQuery(`alter table ${this.tableName()} drop index ${indexName}`);
|
2021-01-01 18:46:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TableCompiler_MySQL.prototype.addColumnsPrefix = 'add ';
|
|
|
|
TableCompiler_MySQL.prototype.alterColumnsPrefix = 'modify ';
|
|
|
|
TableCompiler_MySQL.prototype.dropColumnPrefix = 'drop ';
|
2016-03-02 17:07:05 +01:00
|
|
|
|
2019-06-04 00:37:17 +02:00
|
|
|
module.exports = TableCompiler_MySQL;
|