File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -298,6 +298,29 @@ function mixinDiscovery(MySQL, mysql) {
298298 return sql ;
299299 } ;
300300
301+ /**
302+ * Discover unique keys for a given table
303+ * @param {String } table The table name
304+ * @param {Object } options The options for discovery
305+ */
306+
307+ /*!
308+ * Retrieves a list of column names that have unique key index
309+ * @param schema
310+ * @param table
311+ * @returns {string }
312+ */
313+ MySQL . prototype . buildQueryUniqueKeys = function ( schema , table ) {
314+ const sql = 'SELECT Column_name AS "columnName",' +
315+ ' table_schema AS "owner",' +
316+ ' table_name AS "tableName"' +
317+ ' FROM Information_schema.statistics' +
318+ ' WHERE Table_schema = ' + mysql . escape ( schema ) +
319+ ' AND Table_name = ' + mysql . escape ( table ) +
320+ ' AND Non_unique = 0 AND Index_name <> \'PRIMARY\';' ;
321+ return sql ;
322+ }
323+
301324 /**
302325 * Discover foreign keys that reference to the primary key of this table
303326 * @param {String } table The table name
You can’t perform that action at this time.
0 commit comments