Add discover primary/foreign keys
This commit is contained in:
parent
c15ff3cad0
commit
e207628538
|
@ -426,6 +426,55 @@ Schema.prototype.discoverModelProperties = function (options, cb) {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Discover primary keys for a given owner/table
|
||||
*
|
||||
* Each primary key column description has the following columns:
|
||||
* TABLE_SCHEM String => table schema (may be null)
|
||||
* TABLE_NAME String => table name
|
||||
* COLUMN_NAME String => column name
|
||||
* KEY_SEQ short => sequence number within primary key( a value of 1 represents the first column of the primary key, a value of 2 would represent the second column within the primary key).
|
||||
* PK_NAME String => primary key name (may be null)
|
||||
*
|
||||
* @param owner
|
||||
* @param table
|
||||
* @param cb
|
||||
*/
|
||||
Schema.prototype.discoverPrimaryKeys= function(owner, table, cb) {
|
||||
this.freeze();
|
||||
if (this.adapter.discoverPrimaryKeys) {
|
||||
this.adapter.discoverPrimaryKeys(options, cb);
|
||||
} else if (cb) {
|
||||
cb();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Discover foreign keys for a given owner/table
|
||||
*
|
||||
* PKTABLE_SCHEM String => primary key table schema being imported (may be null)
|
||||
* PKTABLE_NAME String => primary key table name being imported
|
||||
* PKCOLUMN_NAME String => primary key column name being imported
|
||||
* FKTABLE_CAT String => foreign key table catalog (may be null)
|
||||
* FKTABLE_SCHEM String => foreign key table schema (may be null)
|
||||
* FKTABLE_NAME String => foreign key table name
|
||||
* FKCOLUMN_NAME String => foreign key column name
|
||||
* KEY_SEQ short => sequence number within a foreign key( a value of 1 represents the first column of the foreign key, a value of 2 would represent the second column within the foreign key).
|
||||
* FK_NAME String => foreign key name (may be null)
|
||||
* PK_NAME String => primary key name (may be null)
|
||||
*
|
||||
* @param owner
|
||||
* @param table
|
||||
* @param cb
|
||||
*/
|
||||
Schema.prototype.discoverForeignKeys= function(owner, table, cb) {
|
||||
this.freeze();
|
||||
if (this.adapter.discoverForeignKeys) {
|
||||
this.adapter.discoverForeignKeys(options, cb);
|
||||
} else if (cb) {
|
||||
cb();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether migrations needed
|
||||
|
|
Loading…
Reference in New Issue