@verdnatura/myt 1.8.1 → 1.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -296,7 +296,7 @@ Builds and starts local database server container. It only rebuilds the image
296
296
  when dump have been modified.
297
297
 
298
298
  ```text
299
- $ myt run [<realm>|-m|--realm <string>] [-c|--ci] [-r|--random] [-p|--persist] [-n|--network <string>]
299
+ $ myt run [<realm>|-m|--realm <string>] [-c|--ci] [-r|--random] [-p|--persist] [-n|--network <string>] [-i|--ip]
300
300
  ```
301
301
 
302
302
  ### start
package/myt-run.js CHANGED
@@ -22,7 +22,8 @@ class Run extends Command {
22
22
  random: 'Whether to use a random container name and port',
23
23
  persist: 'Whether to not use tmpfs mount for MySQL data',
24
24
  keep: 'Keep container on failure',
25
- realm: 'Name of fixture realm to use'
25
+ realm: 'Name of fixture realm to use',
26
+ realm: 'Use container IP instead of localhost'
26
27
  },
27
28
  operand: 'realm'
28
29
  };
@@ -33,7 +34,8 @@ class Run extends Command {
33
34
  random: 'r',
34
35
  persist: 'p',
35
36
  keep: 'k',
36
- realm: 'm'
37
+ realm: 'm',
38
+ ip: 'i'
37
39
  },
38
40
  boolean: [
39
41
  'ci',
@@ -138,21 +140,27 @@ class Run extends Command {
138
140
  const ctNetworks = netSettings.Networks;
139
141
 
140
142
  let host;
141
- if (network) {
142
- host = network != 'host'
143
- ? ctNetworks[network].IPAddress
144
- : '127.0.0.1'
143
+ let port;
144
+ let localhost = '127.0.0.1';
145
+ if (opts.ip) {
146
+ if (network) {
147
+ host = network != 'host'
148
+ ? ctNetworks[network].IPAddress
149
+ : localhost
150
+ } else {
151
+ host = netSettings.IPAddress
152
+ ?? ctNetworks.bridge?.IPAddress
153
+ }
154
+ port = 3306;
145
155
  } else {
146
- host = netSettings.IPAddress
147
- ?? ctNetworks.bridge?.IPAddress
156
+ host = localhost;
157
+ port = netSettings.Ports['3306/tcp'][0].HostPort
148
158
  }
159
+
149
160
  if (!host)
150
161
  throw new Error(`Cannot get database host`);
151
162
 
152
- Object.assign(dbConfig, {
153
- host,
154
- port: 3306
155
- });
163
+ Object.assign(dbConfig, {host, port});
156
164
  } catch (err) {
157
165
  await server.rm();
158
166
  throw err;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdnatura/myt",
3
- "version": "1.8.1",
3
+ "version": "1.8.4",
4
4
  "author": "Verdnatura Levante SL",
5
5
  "description": "MySQL version control",
6
6
  "license": "GPL-3.0",
@@ -0,0 +1,30 @@
1
+ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `account`;
2
+
3
+ CREATE TABLE `version` (
4
+ `code` VARCHAR(50) NOT NULL,
5
+ `number` CHAR(11) NULL DEFAULT NULL,
6
+ `gitCommit` VARCHAR(255) NULL DEFAULT NULL,
7
+ `updated` DATETIME NOT NULL,
8
+ `lastNumber` CHAR(11) NULL DEFAULT NULL
9
+ ) ENGINE=InnoDB;
10
+
11
+ ALTER TABLE `version`
12
+ ADD PRIMARY KEY (`code`);
13
+
14
+ CREATE TABLE `versionLog` (
15
+ `code` VARCHAR(50) NOT NULL,
16
+ `number` CHAR(11) NOT NULL,
17
+ `file` VARCHAR(255) NOT NULL,
18
+ `user` VARCHAR(255) NULL,
19
+ `updated` DATETIME NOT NULL,
20
+ `errorNumber` INT(10) UNSIGNED DEFAULT NULL,
21
+ `errorMessage` VARCHAR(255) DEFAULT NULL
22
+ ) ENGINE=InnoDB;
23
+
24
+ ALTER TABLE `versionLog`
25
+ ADD PRIMARY KEY (`code`,`number`,`file`);
26
+
27
+ CREATE TABLE `util`.`versionConfig` (
28
+ `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
29
+ `realm` VARCHAR(16) NULL DEFAULT NULL COMMENT 'Data set on which the project runs'
30
+ ) ENGINE=InnoDB;