extract-mysql-schema 0.7.1 → 0.7.3
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/index.js +1 -1
- package/package.json +1 -1
- package/run.js +8 -4
package/index.js
CHANGED
|
@@ -53,7 +53,7 @@ const extractSchemas = async function (connection, options) {
|
|
|
53
53
|
queryProcedures=queryProcedures[0];
|
|
54
54
|
|
|
55
55
|
let queryParameters = await adapter.query(`
|
|
56
|
-
SELECT p.* FROM INFORMATION_SCHEMA.PARAMETERS as p join INFORMATION_SCHEMA.ROUTINES as r on p.SPECIFIC_NAME=r.SPECIFIC_NAME
|
|
56
|
+
SELECT p.* FROM INFORMATION_SCHEMA.PARAMETERS as p join INFORMATION_SCHEMA.ROUTINES as r on p.SPECIFIC_NAME=r.SPECIFIC_NAME and p.SPECIFIC_SCHEMA=r.ROUTINE_SCHEMA
|
|
57
57
|
WHERE ROUTINE_SCHEMA='${schemaName}'
|
|
58
58
|
ORDER BY p.SPECIFIC_NAME,p.ORDINAL_POSITION
|
|
59
59
|
`);
|
package/package.json
CHANGED
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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
|
|