Comparing version 1.1.11 to 1.1.12
@@ -132,3 +132,3 @@ Schema Version Control | ||
- Missing Columns | ||
If a column is renamed or removed rom one version to the next, we really need | ||
If a column is renamed or removed from one version to the next, we really need | ||
some kind of alter script to run just prior to the drop/create cycle on the | ||
@@ -135,0 +135,0 @@ table. This will be done in a transaction so it can be safe from other |
@@ -89,3 +89,3 @@ //Manage data migration commands | ||
let delta = this.loadFile(dir) | ||
//console.log("dir:", dir, "delta:", delta) | ||
//console.log("updateDB dir:", dir, "delta:", delta) | ||
if (Object.keys(delta).length > 0) this.pushDB(delta) | ||
@@ -92,0 +92,0 @@ if (commit && dir != this.mainDir) { //Can't commit with deltas in sub modules |
@@ -11,2 +11,3 @@ //Wyseman schema file parser; A wrapper around the TCL core parser | ||
const Tcl = require('tcl').Tcl | ||
const yamParse = require('./yam_parse.js') | ||
@@ -40,4 +41,4 @@ module.exports = class { | ||
this.db.x("select wm.make(null, false, true);") //And build it | ||
this.parse(Path.join(__dirname, 'run_time.wmt')) //Read text descriptions | ||
this.parse(Path.join(__dirname, 'run_time.wmd')) //Read display switches | ||
this.parse(Path.join(__dirname, 'run_time.wmt')) //Read text descriptions | ||
this.parse(Path.join(__dirname, 'run_time.wmd')) //Read display settings | ||
} | ||
@@ -66,14 +67,14 @@ this.db.x('delete from wm.objects where obj_ver <= 0;') //Remove any failed working entries | ||
let fullName = Path.resolve(file) | ||
, ext = Path.extname(file) | ||
this.dirName = Path.dirname(fullName) //Pass around the side to sql generator | ||
if (Path.extname(file) == '.wmi') { | ||
let sql = Child.execFileSync(fullName).toString() | ||
//console.log('sql:', sql) | ||
if (ext == '.wmi') { | ||
let sql = Child.execFileSync(fullName).toString() ///console.log('sql:', sql) | ||
return sql | ||
} | ||
try { | ||
} else if (ext == '.wmd' && yamParse(file, (sql) => this.db.x(sql))) { | ||
return '' | ||
} else try { | ||
let res = this.tcl.$("wmparse::parse " + file) | ||
} catch(e) { | ||
console.error('Tcl parse error: ', e.message) | ||
return null | ||
} | ||
@@ -105,3 +106,3 @@ return '' | ||
pQuery(...args) { | ||
let [name, sql] = args | ||
let [name, sql] = args //;console.log('sql:', sql) | ||
this.db.x(sql) | ||
@@ -108,0 +109,0 @@ } |
@@ -187,3 +187,3 @@ //Manage a schema release object/file | ||
//console.log(" rec:", Array.isArray(row.grants), rec) | ||
let [ obj_nam, mod, level, priv ] = rec.split(',') | ||
let [ obj_nam, mod, level, priv ] = rec.split('|') | ||
, [ otyp, onam ] = obj_nam.split(':') | ||
@@ -190,0 +190,0 @@ , perm = (mod == 'public') ? mod : mod + '_' + level |
{ | ||
"name": "wyseman", | ||
"version": "1.1.11", | ||
"version": "1.1.12", | ||
"description": "PostgreSQL Schema Manager with Javascript, Ruby, TCL API", | ||
@@ -27,2 +27,4 @@ "main": "lib/index.js", | ||
"wyseman-info": "bin/info.js", | ||
"wm-csv2db": "bin/wm-csv2db", | ||
"wm-db2wmt": "bin/wm-db2wmt", | ||
"wmdump": "bin/wmdump", | ||
@@ -45,6 +47,8 @@ "wmrestore": "bin/wmrestore", | ||
"devDependencies": { | ||
"csv": "^6.2.8", | ||
"mocha": "^9.1.3", | ||
"pg-native": "^3.0.0", | ||
"tcl": "^3.0.0" | ||
"tcl": "^3.0.0", | ||
"yaml": "^2.2.1" | ||
} | ||
} |
@@ -23,3 +23,4 @@ //Check basic database data dictionary | ||
it('Check for undocumented tables', function(done) { | ||
let sql = "select sch,tab from wm.table_lang where language = 'en' and help isnull and sch = 'wm' order by 1,2" | ||
let sql = `select * from wm.table_data td where td_sch = 'wm' and not exists | ||
(select * from wm.table_text tt where tt.tt_sch = td.td_sch and tt.tt_tab = td.td_tab and tt.language = 'eng');` | ||
db.query(sql, null, (err, res) => { | ||
@@ -34,3 +35,3 @@ if (err) done(err) | ||
it('Check for undocumented columns', function(done) { | ||
let sql = "select sch,tab,col from wm.column_lang where language = 'en' and help isnull and sch = 'wm' order by 1,2" | ||
let sql = "select sch,tab,col from wm.column_lang where language = 'eng' and help isnull and sch = 'wm' order by 1,2" | ||
log.debug("SQL:", sql) | ||
@@ -37,0 +38,0 @@ db.query(sql, null, (err, res) => { |
@@ -37,3 +37,3 @@ //Check dropping objects out of a schema; run after versions.js | ||
}) | ||
/* | ||
it('can disable pruning', function(done) { | ||
@@ -66,3 +66,3 @@ Child.exec("wyseman objects testo.wms --no-prune", {cwd: SchemaDir}, (e,o) => {if (e) done(e); done()}) | ||
}) | ||
/* */ | ||
after('Disconnect from test database', function() { | ||
@@ -69,0 +69,0 @@ db.disconnect() |
@@ -11,3 +11,3 @@ //Build test database schema; Run first | ||
const Child = require('child_process') | ||
const { TestDB, DBAdmin, Log, DbClient, SchemaDir, SchemaFile, WmItems } = require('./settings') | ||
const { TestDB, DBAdmin, Log, DbClient, SchemaDir, SchemaFile } = require('./settings') | ||
var log = Log('test-schema') | ||
@@ -18,2 +18,3 @@ const dbConfig = {database: TestDB, user: DBAdmin, connect: true, log} | ||
var jsonSchema = SchemaFile(release) | ||
var interTest = {} | ||
@@ -57,6 +58,6 @@ describe("Schema: Build DB schema files", function() { | ||
it('should have 15 wyselib tables built', function(done) { | ||
it('check for number of wyselib tables built', function(done) { | ||
let sql = "select * from pg_tables where schemaname = 'base'" | ||
db.query(sql, null, (e, res) => {if (e) done(e) | ||
assert.equal(res.rows.length, 15) | ||
assert.equal(res.rows.length, 17) | ||
done() | ||
@@ -123,3 +124,3 @@ }) | ||
it('should build a JSON schema file with objects', function(done) { | ||
it('should build a JSON schema file with expected objects', function(done) { | ||
Child.exec("wyseman init test1.wmi -S " + jsonSchema, {cwd: SchemaDir}, (e,o) => {if (e) done(e) | ||
@@ -130,3 +131,3 @@ let content = Fs.readFileSync(jsonSchema).toString() | ||
log.debug("Schema objects:", sch.objects.length) | ||
assert.equal(sch.objects.length, WmItems) | ||
assert.equal(sch.objects.length, 199) | ||
done() | ||
@@ -171,2 +172,23 @@ }) | ||
it('counting rows in wm.column_data', function(done) { | ||
let sql = "select count(*) from wm.column_data where cdt_sch in ('wm','wylib') and field >= 0" | ||
db.query(sql, null, (e, res) => {if (e) done(e) | ||
assert.equal(res.rows.length, 1) | ||
let row = res.rows[0] | ||
assert(row.count > 0) ;log.debug('cd:', row.count) | ||
interTest.rowCount = row.count | ||
done() | ||
}) | ||
}) | ||
it('comparing rows in wm.column_lang', function(done) { | ||
let sql = "select count(*) from wm.column_lang where sch in ('wm','wylib') and language = 'eng'" | ||
db.query(sql, null, (e, res) => {if (e) done(e) | ||
assert.equal(res.rows.length, 1) | ||
let row = res.rows[0] | ||
assert.equal(row.count, interTest.rowCount) | ||
done() | ||
}) | ||
}) | ||
/* */ | ||
after('Disconnect from test database', function(done) { | ||
@@ -173,0 +195,0 @@ db.disconnect() |
@@ -17,4 +17,3 @@ //Copyright WyattERP.org; See license in root of this package | ||
DbClient: require("../lib/dbclient.js"), | ||
SchemaFile: schemaFile, | ||
WmItems: 199 | ||
SchemaFile: schemaFile | ||
} |
@@ -8,3 +8,3 @@ //Build test database schema; run after schema.js | ||
const Child = require('child_process') | ||
const { TestDB, DBAdmin, Log, DbClient, SchemaDir, SchemaFile, WmItems } = require('./settings') | ||
const { TestDB, DBAdmin, Log, DbClient, SchemaDir, SchemaFile } = require('./settings') | ||
var log = Log('test-schema') | ||
@@ -28,2 +28,10 @@ const dbConfig = {database: TestDB, user: DBAdmin, connect: true, log} | ||
it('can build development objects', function(done) { | ||
let files = ['run_time.wms','develop.wms','run_time.wmt','develop.wmt'].map(f => | ||
Path.join(__dirname, '../lib', f) | ||
) | ||
log.debug('cmd:', `wyseman ${files}`) | ||
Child.exec(`wyseman ${files.join(' ')}`, {cwd: SchemaDir}, (e,o) => {if (e) done(e); done()}) | ||
}) | ||
it('wm.objects exists and has items', function(done) { | ||
@@ -35,3 +43,3 @@ let sql = "select count(*), wm.next() from wm.objects" | ||
log.debug("Schema objects:", row.count) | ||
assert.equal(row.count, WmItems) | ||
assert.equal(row.count, 204) | ||
assert.equal(row.next, 1) | ||
@@ -38,0 +46,0 @@ done() |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
546432
106
3273
5
17