Skip to content

Migration timeouts #618

Closed
Closed

Description

@ofekatr

Does the tool support configuring timeouts on migrations?
What's the recommended way of setting these up?

Activity

  1. mmkal commented on Nov 6, 2023

    @mmkal
    Contributor

    Nothing out of the box, but I'm open to it if you can think of a clean API. Would need to make sure it's clear what happens when a migration times out, whether a timeout config is global or local, can it be overridden etc.

    I don't want to go far as to say that this is the official recommended way to do this, but you could do something like

    import { Umzug } from 'umzug'
    
    const migrator = new Umzug({
      migrations: {
        glob: 'migrations/*.js',
        resolve(params) {
          const base = Umzug.defaultResolver(params);
          return {
            ...base,
            async up(upParams) {
              return Promise.race([
                base.up(upParams),
                new Promise((_resolve, reject) =>
                  setTimeout(() => {
                    reject(new Error('timeout'));
                  }, 1000)
                ),
              ]);
            },
            async down(downParams) {
              return Promise.race([
                base.down(downParams),
                new Promise((_resolve, reject) =>
                  setTimeout(() => {
                    reject(new Error('timeout'));
                  }, 1000)
                ),
              ]);
            },
          };
      },
    })
  2. locked and limited conversation to collaborators on Jan 8, 2025
  3. converted this issue into a discussion #696 on Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions