Compare commits

..

4 Commits

6 changed files with 1361 additions and 9 deletions

View File

@ -191,6 +191,23 @@ You can create your local fixture and structure files.
* *dump/fixtures.after.sql*
* *dump/fixtures.local.sql*
### Realms
You can create your local realms folders.
```text
dump
`- realms
|- marvel
| `- 00-spiderman.sql
| `- 01-hulk.sql
`- dc
`- 00-superman.sql
`- 01-batman.sql
`- 02-wonder_woman.sql
`- 03-flash.sql
```
## Versioning commands
### init
@ -279,7 +296,7 @@ Builds and starts local database server container. It only rebuilds the image
when dump have been modified.
```text
$ myt run [-c|--ci] [-r|--random] [-t|--tmpfs] [-n|--network <string>]
$ myt run [-c|--ci] [-r|--random] [-t|--tmpfs] [-n|--network <string>] [--realm <string>]
```
### start

View File

@ -47,6 +47,7 @@ class Run extends Command {
waitingDb: 'Waiting for MySQL init process.',
mockingDate: 'Mocking date functions.',
applyingFixtures: 'Applying fixtures.',
applyingRealms: (realm) => console.log(`Applying '${realm}' realm fixtures.`),
creatingTriggers: 'Creating triggers.'
};
@ -185,11 +186,19 @@ class Run extends Command {
]
for (const file of fixturesFiles) {
if (!await fs.exists(`${dumpDir}/${file}.sql`)) continue;
await ct.exec(null, 'docker-import.sh',
[`/workspace/dump/${file}`],
'spawn',
true
);
await execFile(`dump/${file}`)
}
// Apply realms
if(opts.realm) {
this.emit('applyingRealms', opts.realm);
const realmDir = `realms/${opts.realm}`;
let realmFiles = await fs.readdir(`${dumpDir}/${realmDir}`);
realmFiles = realmFiles.map(file => path.parse(file).name);
for (const file of realmFiles) {
await execFile(`${realmDir}/${file}`)
}
}
// Create triggers
@ -216,10 +225,18 @@ class Run extends Command {
} catch (e) {}
throw err;
}
async function execFile(path){
await ct.exec(null, 'docker-import.sh',
[`/workspace/${path}` ],
'spawn',
true
);
}
}
}
module.exports = Run;
if (require.main === module)
new Myt().cli(Run);
new Myt().cli(Run);

3
myt.js
View File

@ -21,7 +21,8 @@ class Myt {
workspace: 'The base directory of the project',
debug: 'Whether to enable debug mode',
version: 'Display the version number and exit',
help: 'Display this help message'
help: 'Display this help message',
realm: 'Name of fixture realm to use',
}
};

View File

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

1316
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -12,3 +12,4 @@ RUN echo "[LOG] Import finished." \
&& rm -rf dump
COPY fixtures.*.sql dump/
COPY realms realms/