Skip to content

migrate:down VERSION=xxxx does not work as expected. #45

@safijunaid17

Description

@safijunaid17

HI team,

root@ubuntu-pod:/houseplant/db2# ~/.local/bin/houseplant migrate:status

Database: db2

┏━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┓
┃ Status ┃ Migration ID   ┃ Migration Name  ┃
┡━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━┩
│   up   │ 20250615111718 │ old table2 test │
│   up   │ 20250616005618 │ new table test  │
│  down  │ 20250616011718 │ new table2 test │
└────────┴────────────────┴─────────────────┘

root@ubuntu-pod:/houseplant/db2# ~/.local/bin/houseplant migrate:up VERSION=20250616011718
✓ Applied migration 20250616011718_new_table2_test.yml
root@ubuntu-pod:/houseplant/db2# ~/.local/bin/houseplant migrate:status

Database: db2

┏━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┓
┃ Status ┃ Migration ID   ┃ Migration Name  ┃
┡━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━┩
│   up   │ 20250615111718 │ old table2 test │
│   up   │ 20250616005618 │ new table test  │
│   up   │ 20250616011718 │ new table2 test │
└────────┴────────────────┴─────────────────┘

root@ubuntu-pod:/houseplant/db2# ~/.local/bin/houseplant migrate:down VERSION=20250615111718
✓ Rolled back migration 20250616011718_new_table2_test.yml

root@ubuntu-pod:/houseplant/db2# ~/.local/bin/houseplant migrate:status

Database: db2

┏━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┓
┃ Status ┃ Migration ID   ┃ Migration Name  ┃
┡━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━┩
│   up   │ 20250615111718 │ old table2 test │
│   up   │ 20250616005618 │ new table test  │
│  down  │ 20250616011718 │ new table2 test │
└────────┴────────────────┴─────────────────┘

I created 3 files, added 3 distinct timestamps as versions and 3 distinct table names and migration name.

if I try to migrate:down on the any specific version, it always ends up rolling back the last up'ed version even though I specify the VERSION. Can be seen in above.

I tried running migrate:up for all files, and then running migrate:up VERSION=xxx for each of the 3 files separately. In either case, the migrate:down to specific version doesn't work.

NOTE: I just generated 1 file via houseplant generate and rest I created manually by adding the required timestamps and names as version etc.

Is there something wrong with the tool or am doing something wrong?

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