fix: refs #5483 routines path now uses subdir

This commit is contained in:
Juan Ferrer 2024-01-25 19:28:51 +01:00
parent edee7a5e46
commit 89cfa65084
5 changed files with 18 additions and 9 deletions

View File

@ -50,7 +50,7 @@ class Pull extends Command {
const match = patch
.newFile()
.path()
.match(/^routines\/(.+)\.sql$/);
.match(opts.routinesRegex);
if (match) return true;
}

View File

@ -461,13 +461,14 @@ class Push extends Command {
const changes = [];
const changesMap = new Map();
const {opts} = this;
async function pushChanges(diff) {
if (!diff) return;
const patches = await diff.patches();
for (const patch of patches) {
const path = patch.newFile().path();
const match = path.match(/^routines\/(.+)\.sql$/);
const match = path.match(opts.routinesRegex);
if (!match) continue;
let change = changesMap.get(match[1]);

16
myt.js
View File

@ -205,12 +205,20 @@ class Myt {
Object.assign(opts, config);
opts.configFile = configFile;
const subdir = opts.subdir || '';
if (!opts.mytDir)
opts.mytDir = path.join(opts.workspace, opts.subdir || '');
opts.mytDir = path.join(opts.workspace, subdir);
opts.routinesDir = path.join(opts.mytDir, 'routines');
opts.versionsDir = path.join(opts.mytDir, 'versions');
opts.dumpDir = path.join(opts.mytDir, 'dump');
const routinesBaseRegex = subdir
? `${subdir}\/routines`
: 'routines';
Object.assign(opts, {
routinesRegex: new RegExp(`^${routinesBaseRegex}\/(.+)\.sql$`),
routinesDir: path.join(opts.mytDir, 'routines'),
versionsDir: path.join(opts.mytDir, 'versions'),
dumpDir: path.join(opts.mytDir, 'dump')
});
// Database configuration

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@verdnatura/myt",
"version": "1.5.30",
"version": "1.5.31",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@verdnatura/myt",
"version": "1.5.30",
"version": "1.5.31",
"license": "GPL-3.0",
"dependencies": {
"@sqltools/formatter": "^1.2.5",

View File

@ -1,6 +1,6 @@
{
"name": "@verdnatura/myt",
"version": "1.5.30",
"version": "1.5.31",
"author": "Verdnatura Levante SL",
"description": "MySQL version control",
"license": "GPL-3.0",