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 const match = patch
.newFile() .newFile()
.path() .path()
.match(/^routines\/(.+)\.sql$/); .match(opts.routinesRegex);
if (match) return true; if (match) return true;
} }

View File

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

16
myt.js
View File

@ -205,12 +205,20 @@ class Myt {
Object.assign(opts, config); Object.assign(opts, config);
opts.configFile = configFile; opts.configFile = configFile;
const subdir = opts.subdir || '';
if (!opts.mytDir) 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'); const routinesBaseRegex = subdir
opts.versionsDir = path.join(opts.mytDir, 'versions'); ? `${subdir}\/routines`
opts.dumpDir = path.join(opts.mytDir, 'dump'); : '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 // Database configuration

4
package-lock.json generated
View File

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

View File

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