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
* Preserve all characteristics on pull: comments, SQL mode, READS SQL DATA...
* Undo changes when there is an error applying a version using "undo" files.
* Use a custom *Dockerfile* for local database container.
* Console logging via events.
* Lock version table row when pushing.
* Preserve all characteristics on pull: SQL mode, character set, algorithm...
## Built With

View File

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

View File

@ -5,6 +5,21 @@ module.exports = {
escapeCols: [
'starts',
'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 %>;
DELIMITER $$
CREATE DEFINER=<%- definer %> FUNCTION <%- schema %>.<%- name %>(<%- paramList %>)
RETURNS <%- returns %>
<% if (isDeterministic != 'NO') { %>DETERMINISTIC<% } else { %>NOT DETERMINISTIC<% } %>
RETURNS <%- returns %><%
if (isDeterministic == 'NO') { %>
NOT DETERMINISTIC<%
} else { %>
DETERMINISTIC<%
}
if (dataAccess) { %>
<%- dataAccess %><%
}
if (securityType == 'INVOKER') { %>
SQL SECURITY <%- securityType %><%
}
if (comment) { %>
COMMENT <%- comment %><%
} %>
<%- body %>$$
DELIMITER ;

View File

@ -1,5 +1,23 @@
module.exports = {
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`,
`definer`,
`param_list` AS `paramList`,
`returns`,
`is_deterministic` AS `isDeterministic`,
`body`,
`modified`
`sql_data_access` AS `dataAccess`,
`security_type` AS `securityType`,
`comment`,
`modified`,
`is_deterministic` AS `isDeterministic`,
`returns`
FROM `mysql`.`proc`
WHERE ? AND `type` = 'FUNCTION'
ORDER BY `name`

View File

@ -1,5 +1,14 @@
DROP PROCEDURE IF EXISTS <%- schema %>.<%- name %>;
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 %>$$
DELIMITER ;

View File

@ -1,5 +1,23 @@
module.exports = {
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`,
`param_list` AS `paramList`,
`body`,
`sql_data_access` AS `dataAccess`,
`security_type` AS `securityType`,
`comment`,
`modified`
FROM `mysql`.`proc`
WHERE ? AND `type` = 'PROCEDURE'

View File

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

View File

@ -9,5 +9,17 @@ module.exports = {
indent: '\t',
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",
"version": "1.2.7",
"version": "1.2.8",
"author": "Verdnatura Levante SL",
"description": "MySQL Version Control",
"license": "GPL-3.0",