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) {
298
298
return sql ;
299
299
} ;
300
300
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
+
301
324
/**
302
325
* Discover foreign keys that reference to the primary key of this table
303
326
* @param {String } table The table name
You can’t perform that action at this time.
0 commit comments