mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 10:16:00 +00:00
sqlite FK analyser, query runs in transaction
This commit is contained in:
@@ -46,6 +46,23 @@ class Analyser extends DatabaseAnalyser {
|
||||
};
|
||||
}
|
||||
|
||||
const fklist = await this.driver.query(this.pool, `pragma foreign_key_list('${tableName}')`);
|
||||
tableObj.foreignKeys = _.values(_.groupBy(fklist.rows, 'id')).map((fkcols) => {
|
||||
const fkcol = fkcols[0];
|
||||
const fk = {
|
||||
pureName: tableName,
|
||||
refTableName: fkcol.table,
|
||||
columns: fkcols.map((col) => ({
|
||||
columnName: col.from,
|
||||
refColumnName: col.to,
|
||||
})),
|
||||
updateAction: fkcol.on_update,
|
||||
deleteAction: fkcol.on_delete,
|
||||
constraintName: `FK_${tableName}_${fkcol.id}`,
|
||||
};
|
||||
return fk;
|
||||
});
|
||||
|
||||
// console.log(info);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user