-DO $$
+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. */
+ See www.xtuple.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("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';");
- plv8.execute("alter table xt.orm enable trigger orm_did_change");
+ plv8.execute("alter table xt.orm enable trigger orm_did_change;");
$$ language plv8;
--- /dev/null
-DO $$
++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;
++declare
++ sqlstring text;
++begin
++ select string_agg('drop view ' || t.oid::regclass || ';', ' ') into sqlstring
++ from pg_class t
++ join pg_namespace n on n.oid = relnamespace
++ where relkind = 'v'
++ and nspname in ('xm','sys', 'xt');
++ if length(sqlstring) > 0 then
++ execute sqlstring;
++ end if;
++end
++$$;
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" :
return memo + script;
}, "");
- // Without this, when we delegate to exec psql the err var will not be set even
- // on the case of error.
- allSql = "\\set ON_ERROR_STOP TRUE;\n" + allSql;
+ // Without this, psql runs all input and returns success even if errors occurred
+ allSql = "\\set ON_ERROR_STOP TRUE\n" + allSql;
winston.info("Applying build to database " + spec.database);
credsClone.database = spec.database;