Compare commits
4 Commits
master
...
6758-realm
Author | SHA1 | Date |
---|---|---|
|
c2ad64561b | |
|
3ce9efa4f2 | |
|
0cda39f1d2 | |
|
efb048bbe9 |
19
README.md
19
README.md
|
@ -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
|
||||
|
|
27
myt-run.js
27
myt-run.js
|
@ -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,6 +225,14 @@ class Run extends Command {
|
|||
} catch (e) {}
|
||||
throw err;
|
||||
}
|
||||
|
||||
async function execFile(path){
|
||||
await ct.exec(null, 'docker-import.sh',
|
||||
[`/workspace/${path}` ],
|
||||
'spawn',
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
3
myt.js
3
myt.js
|
@ -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',
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -12,3 +12,4 @@ RUN echo "[LOG] Import finished." \
|
|||
&& rm -rf dump
|
||||
|
||||
COPY fixtures.*.sql dump/
|
||||
COPY realms realms/
|
||||
|
|
Loading…
Reference in New Issue