From: Travis Webb Date: Wed, 17 Sep 2014 15:52:32 +0000 (-0400) Subject: Merge pull request #1820 from shackbarth/wipe_early X-Git-Tag: v4.7.0-beta.2~16 X-Git-Url: http://git.roojs.org/?a=commitdiff_plain;h=8c5b966332a20878a9f3a63711f35da1dfe5a5a3;hp=7639ad7ea7bb78ef10b9cd59ec2805f1ea31e7f3;p=xtuple Merge pull request #1820 from shackbarth/wipe_early wipe views before foundation database code is executed --- diff --git a/.travis.yml b/.travis.yml index 10dcc2bc2..564ef540d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,3 @@ script: - "npm run-script test-datasource" - "npm run-script test" - "npm run-script jshint" - - # test an upgrade from 4.4.0 - - "wget http://sourceforge.net/projects/postbooks/files/03%20PostBooks-databases/4.4.0/postbooks_demo-4.4.0.backup" - - "./scripts/build_app.js -d upgrade_test -i -b ./postbooks_demo-4.4.0.backup" diff --git a/enyo-client/database/source/delete_system_orms.sql b/enyo-client/database/source/delete_system_orms.sql index dc1cfbc9c..79e2b31e9 100644 --- a/enyo-client/database/source/delete_system_orms.sql +++ b/enyo-client/database/source/delete_system_orms.sql @@ -2,19 +2,6 @@ DO $$ /* Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xm.ple.com/CPAL for the full text of the software license. */ - var result, - viewname, - schemaname, - i; - - sql = "select schemaname, viewname from pg_views where schemaname in ('xm','sys', 'xt');" - result = plv8.execute(sql); - for (i = 0; i < result.length; i++) { - viewname = result[i].viewname; - schemaname = result[i].schemaname; - plv8.execute('drop view if exists ' + schemaname + '.' + viewname + ' cascade;'); - } - plv8.execute("select xt.js_init()"); plv8.execute("alter table xt.orm disable trigger orm_did_change"); plv8.execute("delete from xt.orm where orm_json ~ '\"isSystem\":true';"); diff --git a/enyo-client/database/source/wipe_views.sql b/enyo-client/database/source/wipe_views.sql new file mode 100644 index 000000000..87ec0d33f --- /dev/null +++ b/enyo-client/database/source/wipe_views.sql @@ -0,0 +1,19 @@ +DO $$ + /* Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. + See www.xm.ple.com/CPAL for the full text of the software license. */ + + var sql, + result, + viewname, + schemaname, + i; + + sql = "select schemaname, viewname from pg_views where schemaname in ('xm','sys', 'xt');" + result = plv8.execute(sql); + for (i = 0; i < result.length; i++) { + viewname = result[i].viewname; + schemaname = result[i].schemaname; + plv8.execute('drop view if exists ' + schemaname + '.' + viewname + ' cascade;'); + } + +$$ language plv8; diff --git a/scripts/lib/build_database.js b/scripts/lib/build_database.js index 6f646955c..aa0b85c58 100644 --- a/scripts/lib/build_database.js +++ b/scripts/lib/build_database.js @@ -89,7 +89,8 @@ var async = require('async'), baseName.indexOf('distribution') >= 0, registerExtension: isExtension, runJsInit: !isFoundation && !isLibOrm, - wipeViews: isApplicationCore && spec.wipeViews, + wipeViews: isFoundation && spec.wipeViews, + wipeOrms: isApplicationCore && spec.wipeViews, extensionLocation: isCoreExtension ? "/core-extensions" : isPublicExtension ? "/xtuple-extensions" : isPrivateExtension ? "/private-extensions" : diff --git a/scripts/lib/util/process_manifest.js b/scripts/lib/util/process_manifest.js index 90f60306f..44ed46a9d 100644 --- a/scripts/lib/util/process_manifest.js +++ b/scripts/lib/util/process_manifest.js @@ -56,6 +56,19 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */ } if (options.wipeViews) { + // If we want to pre-emptively wipe out the views, the best place to do it + // is at the start of the core application code + fs.readFile(path.join(__dirname, "../../../enyo-client/database/source/wipe_views.sql"), + function (err, wipeSql) { + if (err) { + callback(err); + return; + } + extensionSql = wipeSql + extensionSql; + callback(null, extensionSql); + }); + + } else if (options.wipeOrms) { // If we want to pre-emptively wipe out the views, the best place to do it // is at the start of the core application code fs.readFile(path.join(__dirname, "../../../enyo-client/database/source/delete_system_orms.sql"),