rake-db 2.25.14 → 2.25.16

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/index.js CHANGED
@@ -7,9 +7,9 @@ var node_url = require('node:url');
7
7
  var fs = require('fs/promises');
8
8
 
9
9
  const getFirstWordAndRest = (input) => {
10
- const i = input.search(/(?=[A-Z])|[-_]/);
10
+ const i = input.search(/(?=[A-Z])|[-_ ]/);
11
11
  if (i !== -1) {
12
- const restStart = input[i] === "-" || input[i] === "_" ? i + 1 : i;
12
+ const restStart = input[i] === "-" || input[i] === "_" || input[i] === " " ? i + 1 : i;
13
13
  const rest = input.slice(restStart);
14
14
  return [input.slice(0, i), rest[0].toLowerCase() + rest.slice(1)];
15
15
  } else {
@@ -19,17 +19,17 @@ const getFirstWordAndRest = (input) => {
19
19
  const getTextAfterRegExp = (input, regex, length) => {
20
20
  let i = input.search(regex);
21
21
  if (i === -1) return;
22
- if (input[i] === "-" || input[i] === "_") i++;
22
+ if (input[i] === "-" || input[i] === "_" || input[i] === " ") i++;
23
23
  i += length;
24
- const start = input[i] == "-" || input[i] === "_" ? i + 1 : i;
24
+ const start = input[i] == "-" || input[i] === "_" || input[i] === " " ? i + 1 : i;
25
25
  const text = input.slice(start);
26
26
  return text[0].toLowerCase() + text.slice(1);
27
27
  };
28
28
  const getTextAfterTo = (input) => {
29
- return getTextAfterRegExp(input, /(To|-to|_to)[A-Z-_]/, 2);
29
+ return getTextAfterRegExp(input, /(To|-to|_to| to)[A-Z-_ ]/, 2);
30
30
  };
31
31
  const getTextAfterFrom = (input) => {
32
- return getTextAfterRegExp(input, /(From|-from|_from)[A-Z-_]/, 4);
32
+ return getTextAfterRegExp(input, /(From|-from|_from| from)[A-Z-_ ]/, 4);
33
33
  };
34
34
  const joinWords = (...words) => {
35
35
  return words.slice(1).reduce(
@@ -2533,7 +2533,10 @@ GROUP BY n.nspname, c.relname`
2533
2533
 
2534
2534
  const writeMigrationFile = async (config, version, name, migrationCode) => {
2535
2535
  await fs.mkdir(config.migrationsPath, { recursive: true });
2536
- const filePath = path.resolve(config.migrationsPath, `${version}_${name}.ts`);
2536
+ const filePath = path.resolve(
2537
+ config.migrationsPath,
2538
+ `${version}_${name.replaceAll(" ", "-")}.ts`
2539
+ );
2537
2540
  const importPath = orchidCore.getImportPath(
2538
2541
  filePath,
2539
2542
  path.join(config.basePath, config.dbScript)
@@ -3166,6 +3169,24 @@ const migrateOrRollback = async (trx, config, set, versions, count, up, redo2, f
3166
3169
  return migrations;
3167
3170
  };
3168
3171
  const checkMigrationOrder = (config, set, { sequence, map }, force) => {
3172
+ if (config.migrationId !== "timestamp") {
3173
+ let prev = set.migrations[0];
3174
+ for (let i = 1; i < set.migrations.length; i++) {
3175
+ const file = set.migrations[i];
3176
+ const version = +file.version;
3177
+ const prevVersion = +prev.version;
3178
+ if (version === prevVersion) {
3179
+ throw new Error(
3180
+ `Found migrations with the same number: ${prev.path} and ${file.path}`
3181
+ );
3182
+ } else if (version - prevVersion > 1) {
3183
+ throw new Error(
3184
+ `There is a gap between migrations ${prev.path} and ${file.path}`
3185
+ );
3186
+ }
3187
+ prev = file;
3188
+ }
3189
+ }
3169
3190
  const last = sequence[sequence.length - 1];
3170
3191
  if (last) {
3171
3192
  for (const file of set.migrations) {