Preserve characteristics on pull

This commit is contained in:
Juan Ferrer 2022-02-07 15:43:12 +01:00
parent 3996c1996c
commit 193588da45
12 changed files with 119 additions and 24 deletions

View File

@ -209,11 +209,11 @@ start a small project.
## Todo ## Todo
* Preserve all characteristics on pull: comments, SQL mode, READS SQL DATA...
* Undo changes when there is an error applying a version using "undo" files. * Undo changes when there is an error applying a version using "undo" files.
* Use a custom *Dockerfile* for local database container. * Use a custom *Dockerfile* for local database container.
* Console logging via events. * Console logging via events.
* Lock version table row when pushing. * Lock version table row when pushing.
* Preserve all characteristics on pull: SQL mode, character set, algorithm...
## Built With ## Built With

View File

@ -1,19 +1,21 @@
DROP EVENT IF EXISTS <%- schema %>.<%- name %>; DROP EVENT IF EXISTS <%- schema %>.<%- name %>;
DELIMITER $$ DELIMITER $$
CREATE DEFINER=<%- definer %> EVENT <%- schema %>.<%- name %> CREATE DEFINER=<%- definer %> EVENT <%- schema %>.<%- name %><%
ON SCHEDULE <% if (type == 'RECURRING') { %>
if (type == 'RECURRING') { ON SCHEDULE EVERY <%- intervalValue %> <%- intervalField %><%
%>EVERY <%- intervalValue %> <%- intervalField %><%
if (starts) { %> if (starts) { %>
STARTS <%- starts %><% STARTS <%- starts %><%
} %><% }
if (ends) { %> if (ends) { %>
ENDS <%- ends %><% ENDS <%- ends %><%
} %><% }
} else { } else { %>
%>AT <%- executeAt %><% ON SCHEDULE AT <%- executeAt %><%
} %> } %>
ON COMPLETION <%- onCompletion %> ON COMPLETION <%- onCompletion %>
<% if (status == 'ENABLED') { %>ENABLE<% } else { %>DISABLE<% } %> <%- status %><%
if (comment) { %>
COMMENT <%- comment %><%
} %>
DO <%- body %>$$ DO <%- body %>$$
DELIMITER ; DELIMITER ;

View File

@ -5,6 +5,21 @@ module.exports = {
escapeCols: [ escapeCols: [
'starts', 'starts',
'ends', 'ends',
'executeAt' 'executeAt',
] 'comment'
],
formatter(params) {
let status;
switch(params.status){
case 'DISABLED':
status = 'DISABLE';
break;
case 'SLAVESIDE_DISABLED':
status = 'DISABLE ON SLAVE';
break;
default:
status = 'ENABLE'
}
params.status = status;
}
}; };

View File

@ -1,7 +1,20 @@
DROP FUNCTION IF EXISTS <%- schema %>.<%- name %>; DROP FUNCTION IF EXISTS <%- schema %>.<%- name %>;
DELIMITER $$ DELIMITER $$
CREATE DEFINER=<%- definer %> FUNCTION <%- schema %>.<%- name %>(<%- paramList %>) CREATE DEFINER=<%- definer %> FUNCTION <%- schema %>.<%- name %>(<%- paramList %>)
RETURNS <%- returns %> RETURNS <%- returns %><%
<% if (isDeterministic != 'NO') { %>DETERMINISTIC<% } else { %>NOT DETERMINISTIC<% } %> if (isDeterministic == 'NO') { %>
NOT DETERMINISTIC<%
} else { %>
DETERMINISTIC<%
}
if (dataAccess) { %>
<%- dataAccess %><%
}
if (securityType == 'INVOKER') { %>
SQL SECURITY <%- securityType %><%
}
if (comment) { %>
COMMENT <%- comment %><%
} %>
<%- body %>$$ <%- body %>$$
DELIMITER ; DELIMITER ;

View File

@ -1,5 +1,23 @@
module.exports = { module.exports = {
schemaCol: 'db', schemaCol: 'db',
nameCol: 'name' nameCol: 'name',
escapeCols: [
'comment'
],
formatter(params) {
let dataAccess;
switch(params.dataAccess) {
case 'NO_SQL':
dataAccess = 'NO SQL';
break;
case 'READS_SQL_DATA':
dataAccess = 'READS SQL DATA';
break;
case 'MODIFIES_SQL_DATA':
dataAccess = 'MODIFIES SQL DATA';
break;
}
params.dataAccess = dataAccess;
}
}; };

View File

@ -4,10 +4,13 @@ SELECT
`name`, `name`,
`definer`, `definer`,
`param_list` AS `paramList`, `param_list` AS `paramList`,
`returns`,
`is_deterministic` AS `isDeterministic`,
`body`, `body`,
`modified` `sql_data_access` AS `dataAccess`,
`security_type` AS `securityType`,
`comment`,
`modified`,
`is_deterministic` AS `isDeterministic`,
`returns`
FROM `mysql`.`proc` FROM `mysql`.`proc`
WHERE ? AND `type` = 'FUNCTION' WHERE ? AND `type` = 'FUNCTION'
ORDER BY `name` ORDER BY `name`

View File

@ -1,5 +1,14 @@
DROP PROCEDURE IF EXISTS <%- schema %>.<%- name %>; DROP PROCEDURE IF EXISTS <%- schema %>.<%- name %>;
DELIMITER $$ DELIMITER $$
CREATE DEFINER=<%- definer %> PROCEDURE <%- schema %>.<%- name %>(<%- paramList %>) CREATE DEFINER=<%- definer %> PROCEDURE <%- schema %>.<%- name %>(<%- paramList %>)<%
if (dataAccess) { %>
<%- dataAccess %><%
}
if (securityType == 'INVOKER') { %>
SQL SECURITY <%- securityType %><%
}
if (comment) { %>
COMMENT <%- comment %><%
} %>
<%- body %>$$ <%- body %>$$
DELIMITER ; DELIMITER ;

View File

@ -1,5 +1,23 @@
module.exports = { module.exports = {
schemaCol: 'db', schemaCol: 'db',
nameCol: 'name' nameCol: 'name',
escapeCols: [
'comment'
],
formatter(params) {
let dataAccess;
switch(params.dataAccess) {
case 'NO_SQL':
dataAccess = 'NO SQL';
break;
case 'READS_SQL_DATA':
dataAccess = 'READS SQL DATA';
break;
case 'MODIFIES_SQL_DATA':
dataAccess = 'MODIFIES SQL DATA';
break;
}
params.dataAccess = dataAccess;
}
}; };

View File

@ -5,6 +5,9 @@ SELECT
`definer`, `definer`,
`param_list` AS `paramList`, `param_list` AS `paramList`,
`body`, `body`,
`sql_data_access` AS `dataAccess`,
`security_type` AS `securityType`,
`comment`,
`modified` `modified`
FROM `mysql`.`proc` FROM `mysql`.`proc`
WHERE ? AND `type` = 'PROCEDURE' WHERE ? AND `type` = 'PROCEDURE'

View File

@ -1,5 +1,7 @@
CREATE OR REPLACE DEFINER=<%- definer %> CREATE OR REPLACE DEFINER=<%- definer %>
SQL SECURITY <%- securityType %> SQL SECURITY <%- securityType %>
VIEW <%- schema %>.<%- name %> VIEW <%- schema %>.<%- name %>
AS <%- definition %><% if (checkOption != 'NONE') { %> AS <%- definition %><%
WITH CASCADED CHECK OPTION<% } %> if (checkOption != 'NONE') { %>
WITH <%- checkOption %> CHECK OPTION<%
} %>

View File

@ -9,5 +9,17 @@ module.exports = {
indent: '\t', indent: '\t',
reservedWordCase: 'upper' reservedWordCase: 'upper'
}); });
let algorithm;
switch (params.isUpdatable) {
case 'YES':
algorithm = 'MERGE';
break;
case 'NO':
algorithm = 'TEMPTABLE';
break;
default:
algorithm = 'UNDEFINED';
}
} }
}; };

View File

@ -1,6 +1,6 @@
{ {
"name": "myvc", "name": "myvc",
"version": "1.2.7", "version": "1.2.8",
"author": "Verdnatura Levante SL", "author": "Verdnatura Levante SL",
"description": "MySQL Version Control", "description": "MySQL Version Control",
"license": "GPL-3.0", "license": "GPL-3.0",