mysqlsyncr 1.0.82 → 1.0.86
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/dist/index.cjs +315 -210
- package/dist/index.js +315 -211
- package/package.json +1 -1
- package/src/compare.js +1 -1
- package/src/differences.js +23 -19
- package/src/dump.js +0 -1
- package/src/index.js +42 -8
- package/ui/dist/spa/assets/{MainLayout-Cft1OeWe.js → MainLayout-CvQD3xKr.js} +1 -1
- package/ui/dist/spa/assets/{axios-CNk6rzlZ.js → axios-C0XcclIb.js} +1 -1
- package/ui/dist/spa/assets/index-CwWo8xmP.js +40 -0
- package/ui/dist/spa/index.html +1 -1
- package/ui/src/pages/MainComponent.vue +155 -18
- package/ui/dist/spa/assets/index-DomDZ6ci.js +0 -30
package/package.json
CHANGED
package/src/compare.js
CHANGED
|
@@ -15,7 +15,7 @@ export const compareAllDatabases = async (connection, inputDir, update = false,
|
|
|
15
15
|
expectedDatabases = expectedDatabases.filter(file => file !== 'diffs.json');
|
|
16
16
|
//filter out dumpInfo.json
|
|
17
17
|
expectedDatabases = expectedDatabases.filter(file => file !== 'dumpInfo.json');
|
|
18
|
-
|
|
18
|
+
console.log('Expected databases from input directory:', expectedDatabases);
|
|
19
19
|
|
|
20
20
|
// Check existing databases
|
|
21
21
|
const existingDatabases = await getDatabases(connection);
|
package/src/differences.js
CHANGED
|
@@ -15,33 +15,38 @@ export const findDifferences = (expected, current) => {
|
|
|
15
15
|
if (!expected.tables) throw new Error('No tables found in expected');
|
|
16
16
|
for (const [tableName, contents] of Object.entries(expected.tables)) {
|
|
17
17
|
//check if craete table matches from json, if so, we dont need to compare indexes, triggers, or fields
|
|
18
|
+
const { columns, indexes, triggers, createSQL, name, engine, charset, collate } = contents;
|
|
19
|
+
|
|
18
20
|
|
|
19
21
|
if (!current.tables[tableName]) {
|
|
20
22
|
console.log('missing_table', contents);
|
|
21
23
|
differences.push({ type: 'missing_table', tableName, createSQL: contents.createSQL });
|
|
22
24
|
continue;
|
|
23
25
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
try {
|
|
27
|
+
//verify triggers
|
|
28
|
+
logger('Verifying triggers for table', tableName);
|
|
29
|
+
for (const trigger of triggers) {
|
|
30
|
+
const currentTrigger = current.tables[tableName].triggers.find(t => t.Name === trigger.Name);
|
|
31
|
+
if (!currentTrigger) {
|
|
32
|
+
logger('Missing trigger', trigger);
|
|
33
|
+
differences.push({ type: 'missing_trigger', tableName, trigger });
|
|
34
|
+
} else {
|
|
35
|
+
// Compare additional properties if needed
|
|
36
|
+
if (currentTrigger.Event !== trigger.Event || currentTrigger.Statement !== trigger.Statement) {
|
|
37
|
+
logger('Mismatched trigger', { expected: trigger, current: currentTrigger });
|
|
38
|
+
differences.push({ type: 'mismatched_trigger', tableName, trigger });
|
|
39
|
+
}
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
for (const trigger of current.tables[tableName].triggers) {
|
|
43
|
+
if (!triggers.some(t => t.Name === trigger.Name)) {
|
|
44
|
+
logger('Extra trigger', trigger);
|
|
45
|
+
differences.push({ type: 'extra_trigger', tableName, trigger });
|
|
46
|
+
}
|
|
44
47
|
}
|
|
48
|
+
} catch (e) {
|
|
49
|
+
console.error(`Error verifying triggers for table ${tableName}`, e);
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
const createTableSql = current.tables[tableName].createSQL;
|
|
@@ -53,7 +58,6 @@ export const findDifferences = (expected, current) => {
|
|
|
53
58
|
logger(createTableSql);
|
|
54
59
|
logger(contents.createSQL);
|
|
55
60
|
}
|
|
56
|
-
const { columns, indexes, triggers, createSQL, name, engine, charset, collate } = contents;
|
|
57
61
|
|
|
58
62
|
|
|
59
63
|
const currentFieldNames = current.tables[tableName].columns.map(f => f.Field);
|
package/src/dump.js
CHANGED
package/src/index.js
CHANGED
|
@@ -46,20 +46,54 @@ class DBStructureChecker {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
const compare = async (config, output) => {
|
|
49
|
-
return new Promise((resolve, reject) => {
|
|
50
|
-
try {
|
|
49
|
+
return new Promise(async (resolve, reject) => {
|
|
50
|
+
try {
|
|
51
51
|
const checker = new DBStructureChecker(config);
|
|
52
52
|
checker.connection.on('connect', async () => {
|
|
53
|
-
const diffs = await compareAllDatabases(checker.connection, output, false, 'compare', {output: output});
|
|
54
|
-
resolve(diffs);
|
|
53
|
+
const diffs = await compareAllDatabases(checker.connection, output, false, 'compare', { output: output });
|
|
54
|
+
resolve({ type: 'success', diffs });
|
|
55
|
+
|
|
55
56
|
});
|
|
56
57
|
} catch (e) {
|
|
57
|
-
reject(e);
|
|
58
|
+
reject({ type: 'error', error: e.message });
|
|
59
|
+
} finally {
|
|
60
|
+
await checker.closeConnection();
|
|
58
61
|
}
|
|
59
62
|
});
|
|
60
63
|
}
|
|
61
64
|
|
|
62
|
-
|
|
65
|
+
const apply = async (config, database, diffs) => {
|
|
66
|
+
return new Promise((resolve, reject) => {
|
|
67
|
+
try {
|
|
68
|
+
const checker = new DBStructureChecker(config, database);
|
|
69
|
+
|
|
70
|
+
checker.connection.on('error', (err) => {
|
|
71
|
+
console.error('Database connection error in route apply:', err);
|
|
72
|
+
reject({ type: 'error', error: err.message });
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
checker.connection.on('connect', async () => {
|
|
76
|
+
console.log('Connected to the database');
|
|
77
|
+
checker.targetDatabase = database;
|
|
78
|
+
checker.command = 'apply';
|
|
79
|
+
checker.options = { config, database, diffs };
|
|
80
|
+
try {
|
|
81
|
+
console.log('Applying the database structure based on JSON dumps');
|
|
82
|
+
await applyDifferences(checker.connection, database, diffs);
|
|
83
|
+
resolve({ type: 'success', message: 'Apply completed successfully' });
|
|
84
|
+
} catch (err) {
|
|
85
|
+
reject({ type: 'error', error: err.message });
|
|
86
|
+
} finally {
|
|
87
|
+
await checker.closeConnection();
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
} catch (e) {
|
|
91
|
+
reject({ type: 'error', error: e.message });
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { DBStructureChecker, dumpAllDatabases, compare, startApiServer, apply };
|
|
63
97
|
|
|
64
98
|
// Only run this if this is the main module
|
|
65
99
|
const isMain = (() => {
|
|
@@ -82,7 +116,7 @@ if (isMain) {
|
|
|
82
116
|
startApiServer(PORT, argv); // Start the Socket.IO server
|
|
83
117
|
console.log('Server started on port', PORT);
|
|
84
118
|
console.log('Open http://localhost:' + PORT + ' in your browser to use the UI');
|
|
85
|
-
if(argv.openUI && argv.openUI === true || argv.openUI === 'true'){
|
|
119
|
+
if (argv.openUI && argv.openUI === true || argv.openUI === 'true') {
|
|
86
120
|
await open(`http://localhost:${PORT}`);
|
|
87
121
|
}
|
|
88
122
|
} else {
|
|
@@ -116,7 +150,7 @@ if (isMain) {
|
|
|
116
150
|
totalDiffs = Object.values(diffs).reduce((acc, arr) => acc + arr.length, 0);
|
|
117
151
|
console.log('Total differences count:', totalDiffs);
|
|
118
152
|
runCount++;
|
|
119
|
-
if(totalDiffs > 0 && runCount < maxRuns){
|
|
153
|
+
if (totalDiffs > 0 && runCount < maxRuns) {
|
|
120
154
|
console.log('Total differences count is still greater than 0. Waiting 1 second before next run. Run count:', runCount);
|
|
121
155
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
122
156
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as L,i as I,e as P,l as D,p as N,b as g,h as m,f as J,g as C,j as X,s as Y,w as _,k as Z,o as T,m as H,n as V,q,r as ee,t as te,u as y,v as A,x as F,y as R,z as x,A as ne,B as ie,_ as oe,C as le,D as re,E as ae,F as k,G as B}from"./index-
|
|
1
|
+
import{c as L,i as I,e as P,l as D,p as N,b as g,h as m,f as J,g as C,j as X,s as Y,w as _,k as Z,o as T,m as H,n as V,q,r as ee,t as te,u as y,v as A,x as F,y as R,z as x,A as ne,B as ie,_ as oe,C as le,D as re,E as ae,F as k,G as B}from"./index-CwWo8xmP.js";const se=L({name:"QPageContainer",setup(e,{slots:p}){const{proxy:{$q:n}}=C(),t=I(D,P);if(t===P)return console.error("QPageContainer needs to be child of QLayout"),P;N(X,!0);const r=g(()=>{const a={};return t.header.space===!0&&(a.paddingTop=`${t.header.size}px`),t.right.space===!0&&(a[`padding${n.lang.rtl===!0?"Left":"Right"}`]=`${t.right.size}px`),t.footer.space===!0&&(a.paddingBottom=`${t.footer.size}px`),t.left.space===!0&&(a[`padding${n.lang.rtl===!0?"Right":"Left"}`]=`${t.left.size}px`),a});return()=>m("div",{class:"q-page-container",style:r.value},J(p.default))}}),{passive:M}=q,ce=["both","horizontal","vertical"],ue=L({name:"QScrollObserver",props:{axis:{type:String,validator:e=>ce.includes(e),default:"vertical"},debounce:[String,Number],scrollTarget:Y},emits:["scroll"],setup(e,{emit:p}){const n={position:{top:0,left:0},direction:"down",directionChanged:!1,delta:{top:0,left:0},inflectionPoint:{top:0,left:0}};let t=null,r,a;_(()=>e.scrollTarget,()=>{l(),h()});function s(){t!==null&&t();const c=Math.max(0,ee(r)),w=te(r),d={top:c-n.position.top,left:w-n.position.left};if(e.axis==="vertical"&&d.top===0||e.axis==="horizontal"&&d.left===0)return;const z=Math.abs(d.top)>=Math.abs(d.left)?d.top<0?"up":"down":d.left<0?"left":"right";n.position={top:c,left:w},n.directionChanged=n.direction!==z,n.delta=d,n.directionChanged===!0&&(n.direction=z,n.inflectionPoint=n.position),p("scroll",{...n})}function h(){r=Z(a,e.scrollTarget),r.addEventListener("scroll",o,M),o(!0)}function l(){r!==void 0&&(r.removeEventListener("scroll",o,M),r=void 0)}function o(c){if(c===!0||e.debounce===0||e.debounce==="0")s();else if(t===null){const[w,d]=e.debounce?[setTimeout(s,e.debounce),clearTimeout]:[requestAnimationFrame(s),cancelAnimationFrame];t=()=>{d(w),t=null}}}const{proxy:v}=C();return _(()=>v.$q.lang.rtl,s),T(()=>{a=v.$el.parentNode,h()}),H(()=>{t!==null&&t(),l()}),Object.assign(v,{trigger:o,getPosition:()=>n}),V}});function de(){const e=y(!A.value);return e.value===!1&&T(()=>{e.value=!0}),{isHydrated:e}}const K=typeof ResizeObserver<"u",W=K===!0?{}:{style:"display:block;position:absolute;top:0;left:0;right:0;bottom:0;height:100%;width:100%;overflow:hidden;pointer-events:none;z-index:-1;",url:"about:blank"},j=L({name:"QResizeObserver",props:{debounce:{type:[String,Number],default:100}},emits:["resize"],setup(e,{emit:p}){let n=null,t,r={width:-1,height:-1};function a(l){l===!0||e.debounce===0||e.debounce==="0"?s():n===null&&(n=setTimeout(s,e.debounce))}function s(){if(n!==null&&(clearTimeout(n),n=null),t){const{offsetWidth:l,offsetHeight:o}=t;(l!==r.width||o!==r.height)&&(r={width:l,height:o},p("resize",r))}}const{proxy:h}=C();if(h.trigger=a,K===!0){let l;const o=v=>{t=h.$el.parentNode,t?(l=new ResizeObserver(a),l.observe(t),s()):v!==!0&&F(()=>{o(!0)})};return T(()=>{o()}),H(()=>{n!==null&&clearTimeout(n),l!==void 0&&(l.disconnect!==void 0?l.disconnect():t&&l.unobserve(t))}),V}else{let l=function(){n!==null&&(clearTimeout(n),n=null),c!==void 0&&(c.removeEventListener!==void 0&&c.removeEventListener("resize",a,q.passive),c=void 0)},o=function(){l(),t&&t.contentDocument&&(c=t.contentDocument.defaultView,c.addEventListener("resize",a,q.passive),s())};const{isHydrated:v}=de();let c;return T(()=>{F(()=>{t=h.$el,t&&o()})}),H(l),()=>{if(v.value===!0)return m("object",{class:"q--avoid-card-border",style:W.style,tabindex:-1,type:"text/html",data:W.url,"aria-hidden":"true",onLoad:o})}}}}),fe=L({name:"QLayout",props:{container:Boolean,view:{type:String,default:"hhh lpr fff",validator:e=>/^(h|l)h(h|r) lpr (f|l)f(f|r)$/.test(e.toLowerCase())},onScroll:Function,onScrollHeight:Function,onResize:Function},setup(e,{slots:p,emit:n}){const{proxy:{$q:t}}=C(),r=y(null),a=y(t.screen.height),s=y(e.container===!0?0:t.screen.width),h=y({position:0,direction:"down",inflectionPoint:0}),l=y(0),o=y(A.value===!0?0:R()),v=g(()=>"q-layout q-layout--"+(e.container===!0?"containerized":"standard")),c=g(()=>e.container===!1?{minHeight:t.screen.height+"px"}:null),w=g(()=>o.value!==0?{[t.lang.rtl===!0?"left":"right"]:`${o.value}px`}:null),d=g(()=>o.value!==0?{[t.lang.rtl===!0?"right":"left"]:0,[t.lang.rtl===!0?"left":"right"]:`-${o.value}px`,width:`calc(100% + ${o.value}px)`}:null);function z(i){if(e.container===!0||document.qScrollPrevented!==!0){const u={position:i.position.top,direction:i.direction,directionChanged:i.directionChanged,inflectionPoint:i.inflectionPoint.top,delta:i.delta.top};h.value=u,e.onScroll!==void 0&&n("scroll",u)}}function U(i){const{height:u,width:b}=i;let f=!1;a.value!==u&&(f=!0,a.value=u,e.onScrollHeight!==void 0&&n("scrollHeight",u),E()),s.value!==b&&(f=!0,s.value=b),f===!0&&e.onResize!==void 0&&n("resize",i)}function G({height:i}){l.value!==i&&(l.value=i,E())}function E(){if(e.container===!0){const i=a.value>l.value?R():0;o.value!==i&&(o.value=i)}}let S=null;const O={instances:{},view:g(()=>e.view),isContainer:g(()=>e.container),rootRef:r,height:a,containerHeight:l,scrollbarWidth:o,totalWidth:g(()=>s.value+o.value),rows:g(()=>{const i=e.view.toLowerCase().split(" ");return{top:i[0].split(""),middle:i[1].split(""),bottom:i[2].split("")}}),header:x({size:0,offset:0,space:!1}),right:x({size:300,offset:0,space:!1}),footer:x({size:0,offset:0,space:!1}),left:x({size:300,offset:0,space:!1}),scroll:h,animate(){S!==null?clearTimeout(S):document.body.classList.add("q-body--layout-animate"),S=setTimeout(()=>{S=null,document.body.classList.remove("q-body--layout-animate")},155)},update(i,u,b){O[i][u]=b}};if(N(D,O),R()>0){let i=function(){f=null,$.classList.remove("hide-scrollbar")},u=function(){if(f===null){if($.scrollHeight>t.screen.height)return;$.classList.add("hide-scrollbar")}else clearTimeout(f);f=setTimeout(i,300)},b=function(Q){f!==null&&Q==="remove"&&(clearTimeout(f),i()),window[`${Q}EventListener`]("resize",u)},f=null;const $=document.body;_(()=>e.container!==!0?"add":"remove",b),e.container!==!0&&b("add"),ne(()=>{b("remove")})}return()=>{const i=ie(p.default,[m(ue,{onScroll:z}),m(j,{onResize:U})]),u=m("div",{class:v.value,style:c.value,ref:e.container===!0?void 0:r,tabindex:-1},i);return e.container===!0?m("div",{class:"q-layout-container overflow-hidden",ref:r},[m(j,{onResize:G}),m("div",{class:"absolute-full",style:w.value},[m("div",{class:"scroll",style:d.value},[u])])]):u}}}),he={};function ve(e,p){const n=le("router-view");return re(),ae(fe,{view:"lHh Lpr lFf"},{default:k(()=>[B(se,null,{default:k(()=>[B(n)]),_:1})]),_:1})}const me=oe(he,[["render",ve]]);export{me as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,a}from"./index-
|
|
1
|
+
import{d as e,a}from"./index-CwWo8xmP.js";const i=a.create({baseURL:"/"}),t=e(({app:o})=>{o.config.globalProperties.$axios=a,o.config.globalProperties.$api=i});export{i as api,t as default};
|