Commit efb419d2 authored by npedot's avatar npedot
Browse files

renames schema.foreignsWithSource(table) and WithTarget(table)

parent 24decfb2
......@@ -98,11 +98,17 @@ class Schema () {
return constraints().filter { c -> c.type.equals(Constraint.TYPE.FOREIGN_KEY.name) }
}
fun foreignsTable(tableName: String): List<Constraint> {
fun foreignsWithSource(tableName: String): List<Constraint> {
return foreignKeys().filter { f -> f.source.name.equals(tableName) }
}
fun foreignsTargets(tableName: String): List<Constraint> {
// fun referencesTable(tableName: String): List<Constraint> {
// var rTables = foreignKeys().filter { f -> f.source.name.equals(tableName) }.toMutableList()
// rTables.addAll()
// return rTables
// }
fun foreignsWithTarget(tableName: String): List<Constraint> {
return foreignKeys().filter { f -> f.target.name.equals(tableName) }
}
......
......@@ -13,6 +13,7 @@ fun oid(schema: Schema, originTableName: String): List<String> {
val keyCols = originTableKey.map { c -> c.name }.joinToString(",")
sqlCommands.add("CREATE TABLE SKEY$originTableName AS SELECT sid,$keyCols FROM $originTableName")
// search ftables with foreign keys od double-inc as pk
// var ftables = schema.foreignsTable(originTableName)
// for each ftable adds one column oid with join with corresponding to fkey values
// replace pk origin-table
// replace fks to new surrogate id column
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment