gitgreen 1.1.0 → 1.1.2
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/dist/cli.js +21 -21
- package/dist/lib/integrations/migration-runner.js +6 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -17,6 +17,27 @@ const power_profile_repository_1 = require("./lib/carbon/power-profile-repositor
|
|
|
17
17
|
const sink_writer_1 = require("./lib/integrations/sink-writer");
|
|
18
18
|
const migration_runner_1 = require("./lib/integrations/migration-runner");
|
|
19
19
|
const data_sink_1 = require("./lib/integrations/data-sink");
|
|
20
|
+
const buildMigrationInput = (config) => ({
|
|
21
|
+
driver: config.driver,
|
|
22
|
+
host: config.host,
|
|
23
|
+
port: config.port,
|
|
24
|
+
username: config.username,
|
|
25
|
+
password: config.password,
|
|
26
|
+
database: config.database,
|
|
27
|
+
schema: config.driver === 'postgres' ? config.schema : undefined,
|
|
28
|
+
sslMode: config.driver === 'postgres' ? config.sslMode : undefined,
|
|
29
|
+
table: config.table,
|
|
30
|
+
timeseriesTable: config.timeseriesTable,
|
|
31
|
+
scope: config.scope
|
|
32
|
+
});
|
|
33
|
+
const runMigrationsForScope = async (scope) => {
|
|
34
|
+
const configs = (0, data_sink_1.resolveAllSinkConfigs)(scope);
|
|
35
|
+
if (!configs.length)
|
|
36
|
+
return;
|
|
37
|
+
for (const cfg of configs) {
|
|
38
|
+
await (0, migration_runner_1.runMigrations)(buildMigrationInput(cfg));
|
|
39
|
+
}
|
|
40
|
+
};
|
|
20
41
|
const program = new commander_1.Command();
|
|
21
42
|
const toIsoTimestamp = (input) => {
|
|
22
43
|
if (input instanceof Date) {
|
|
@@ -342,24 +363,3 @@ program
|
|
|
342
363
|
}
|
|
343
364
|
});
|
|
344
365
|
program.parseAsync(process.argv);
|
|
345
|
-
const buildMigrationInput = (config) => ({
|
|
346
|
-
driver: config.driver,
|
|
347
|
-
host: config.host,
|
|
348
|
-
port: config.port,
|
|
349
|
-
username: config.username,
|
|
350
|
-
password: config.password,
|
|
351
|
-
database: config.database,
|
|
352
|
-
schema: config.driver === 'postgres' ? config.schema : undefined,
|
|
353
|
-
sslMode: config.driver === 'postgres' ? config.sslMode : undefined,
|
|
354
|
-
table: config.table,
|
|
355
|
-
timeseriesTable: config.timeseriesTable,
|
|
356
|
-
scope: config.scope
|
|
357
|
-
});
|
|
358
|
-
const runMigrationsForScope = async (scope) => {
|
|
359
|
-
const configs = (0, data_sink_1.resolveAllSinkConfigs)(scope);
|
|
360
|
-
if (!configs.length)
|
|
361
|
-
return;
|
|
362
|
-
for (const cfg of configs) {
|
|
363
|
-
await (0, migration_runner_1.runMigrations)(buildMigrationInput(cfg));
|
|
364
|
-
}
|
|
365
|
-
};
|
|
@@ -30,7 +30,12 @@ const loadMigrations = (scope, driver) => {
|
|
|
30
30
|
.filter(file => file.endsWith('.sql') && file.startsWith(prefix))
|
|
31
31
|
.sort();
|
|
32
32
|
return files.map(file => {
|
|
33
|
-
const
|
|
33
|
+
const segments = file.replace('.sql', '').split('_');
|
|
34
|
+
const numericSegment = segments[2];
|
|
35
|
+
const id = Number(numericSegment);
|
|
36
|
+
if (!Number.isFinite(id)) {
|
|
37
|
+
throw new Error(`Invalid migration filename: ${file}`);
|
|
38
|
+
}
|
|
34
39
|
return {
|
|
35
40
|
id,
|
|
36
41
|
name: file,
|