extract-mysql-schema 0.7.1 → 0.7.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/run.js +8 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extract-mysql-schema",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": "./run.js",
package/run.js CHANGED
@@ -26,6 +26,7 @@ async function main(options) {
26
26
  }
27
27
  };
28
28
 
29
+ tableContent.push(`USE ${config.connection.database};`);
29
30
  const tablesPath=path.join(process.cwd(),"tables");
30
31
  if(result[config.connection.database].tables.length>0) {
31
32
  // write table sql
@@ -48,6 +49,7 @@ async function main(options) {
48
49
  processFolder(tablesPath,tableContent); // add files not in the database
49
50
 
50
51
  const proceduresPath=path.join(process.cwd(),"procedures");
52
+ proceduresPath.push(`USE ${config.connection.database};`);
51
53
  if(result[config.connection.database].procedures.length>0) {
52
54
  // write routines
53
55
  if (!fs.existsSync(proceduresPath)){
@@ -64,6 +66,7 @@ async function main(options) {
64
66
  processFolder(proceduresPath,sprocContent); // add files not in the database
65
67
 
66
68
  const seedPath = path.join(process.cwd(),"seed");
69
+ proceduresPath.push(`USE ${config.connection.database};`);
67
70
  if(fs.existsSync(seedPath)) {
68
71
  result[config.connection.database].tableOrder.forEach(table => {
69
72
  let seedfile = path.join(seedPath,table+'.sql');
@@ -76,21 +79,22 @@ async function main(options) {
76
79
  processFolder(seedPath,seedContent); // add files not in the database
77
80
 
78
81
  const patchContent=[];
82
+ patchContent.push(`USE ${config.connection.database};`);
79
83
  processFolder(path.join(process.cwd(),"patch"), patchContent);
80
84
 
81
85
  if(content.length>0) {
82
86
  fs.writeFileSync(path.join(process.cwd(),"0.init.sql"), content.join('\n\n') ,"utf8");
83
87
  }
84
- if(tableContent.length>0) {
88
+ if(tableContent.length>1) {
85
89
  fs.writeFileSync(path.join(process.cwd(),"1.table.sql"), tableContent.join('\n\n') ,"utf8");
86
90
  }
87
- if(seedContent.length>0) {
91
+ if(seedContent.length>1) {
88
92
  fs.writeFileSync(path.join(process.cwd(),"2.seed.sql"), seedContent.join('\n\n') ,"utf8");
89
93
  }
90
- if(sprocContent.length>0) {
94
+ if(sprocContent.length>1) {
91
95
  fs.writeFileSync(path.join(process.cwd(),"3.procedures.sql"), sprocContent.join('\n\n') ,"utf8");
92
96
  }
93
- if(patchContent.length>0) {
97
+ if(patchContent.length>1) {
94
98
  fs.writeFileSync(path.join(process.cwd(),"4.patch.sql"), patchContent.join('\n\n') ,"utf8");
95
99
  }
96
100