MigrationError: Migration 2024.06.20T07.13.41.random_file_name.ts (up) failed: Original error: migration.up is not a function
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 32/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- nodejs, typescript
- Domain
- databases
Research direction
Review the Umzug initialization, especially the migrations.glob and resolve callback, then inspect the compiled files under build/migrations and their exported up/down functions. Try to reproduce the intermittent failure with the reported TypeScript compilation and migration filenames, including random_file.ts.ts. Done means identifying a reproducible cause for migration.up not being a function and verifying migrations execute successfully.
Written by the indexing model from the issue text.
Description
"mysql2": "^3.10.0",
"sequelize": "^6.37.3",
"umzug": "^3.8.1"
node version v20.10.0
We have migrations written in typescript like
import { MigrationParams } from "@local-types";
import { DataTypes } from "sequelize";
export const up = async ({ context: sequelize }: MigrationParams) => {
await sequelize.addColumn(
// some code
);
};
export const down = async ({ context: sequelize }: MigrationParams) => {
await sequelize.removeColumn(
// some code
);
};
which gets compiled to .js files and is run through nodejs lambda
The error is happening randomly without any concurrent pattern seen.
FYI: we have few files like random_file.ts.ts in between as tech debt but couldnt reproduce with them as well
also this is how i am initializing umzug
import fs from "fs";
import path from "path";
import { Sequelize } from "sequelize";
import { Umzug, SequelizeStorage } from "umzug";
interface Props {
databaseName: string;
}
export const getUmzug = (
sequelize: Sequelize,
props?: Props,
migrationsGlob?: string
) => {
return new Umzug({
migrations: {
glob: "build/migrations/*.{ts,js}",
resolve: ({ name, path, context }) => {
const migration = require(path);
return {
name: name.replace(/\.js$/, ".ts"),
up: async () =>
migration.up({
context,
...(props && { databaseName: props.databaseName })
}),
down: async () => migration.down({ context })
};
}
},
context: sequelize.getQueryInterface(),
storage: new SequelizeStorage({
sequelize: sequelize,
tableName: process.env.DB_META_TABLE_NAME || "SequelizeMeta"
}),
logger: console,
create: {
folder: "src/migrations",
template: filePath => [
[
filePath,
fs.readFileSync(
path.join(__dirname, "template", "sample-migration.ts"),
"utf-8"
)
]
]
}
});
};
- Dominant language
- TypeScript
- Stars
- 2.2k
- Forks
- 162
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sequelize/umzug
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Security Vulnerability: ajv (JSON Schema Validator)Possibly taken @claabs claimed this 238 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 40/100
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Graphify-Labs/graphify#4860 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
sveltejs/eslint-plugin-svelte#1615 ·
Maintainers usually reply within 7 days
-
Parallel reticle_verify opens per-flow leases without the source lease's ignoreHTTPSErrorsPossibly taken @as992949791 claimed this today. Opengood first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
reticlehq/reticle#2033 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day