Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

MigrationError: Migration 2024.06.20T07.13.41.random_file_name.ts (up) failed: Original error: migration.up is not a function

Open
#693 8 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sequelize/umzug

All issues in sequelize/umzug

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.