oradm-to-gql 32.0.0 → 32.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oradm-to-gql",
3
- "version": "32.0.0",
3
+ "version": "32.1.3",
4
4
  "description": "Oracle Data Modeler CSV Export to Apollo GraphQL Endpoint Generator",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,7 +1,9 @@
1
1
  const _ = require('lodash');
2
2
  const maxLength = 25;
3
+
3
4
  function shortenName(name, targetLength){
4
5
  targetLength = targetLength || maxLength;
6
+
5
7
  var words = _.snakeCase(name).split('_');
6
8
 
7
9
  var newWords = [];
package/src/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const Promise = require("bluebird");
2
+ const { shortenName, maxLength } = require("./datamodel-csv-parser/Utils");
2
3
  const {
3
4
  loadResolvers,
4
5
  loadMockResolvers,
@@ -25,6 +26,8 @@ module.exports = (function () {
25
26
  truncateAndSeedDatabase,
26
27
  knexTools,
27
28
  graphqlGenerators,
29
+ shortenName,
30
+ maxLength
28
31
  };
29
32
 
30
33
  function mockPromise() {
@@ -4,7 +4,7 @@ function createRelationships(db, relationships, opts = {}) {
4
4
  const { logDebug = () => {}, commonSchema, moduleSchema } = opts;
5
5
 
6
6
  db.logSQL(`Creating relationships`);
7
- return Promise.each(relationships, (rel) => {
7
+ return Promise.each(relationships, async (rel) => {
8
8
  logDebug(
9
9
  "[ORADM-FK] Creating FK for field " + rel.tableName + "." + rel.columnName
10
10
  );
@@ -27,6 +27,12 @@ function createRelationships(db, relationships, opts = {}) {
27
27
  return;
28
28
  }
29
29
  logDebug("[ORADM-FK]", rel);
30
+
31
+ // For cross module foreign keys they may be duplicated so drop if they exist
32
+ await db.raw(
33
+ `ALTER TABLE "${rel.schema}"."${rel.tableName}" DROP CONSTRAINT IF EXISTS "${rel.fkName}"`
34
+ );
35
+
30
36
  let qb = db.schema
31
37
  .withSchema(rel.schema)
32
38
  .table(rel.tableName, function (table) {