Search code examples
mysqlnode.jsnpmdatabase-migrationknex.js

How to run a specific migration of an accidentally dropped table


I accidentally dropped a table using the mysql command line. Luckily the table was empty.

But I need this table back. So I would like to re-run only the migration for that table, and not for other tables since these are still present.

When I run knex migrate:latest, it returns "Already up to date". The same if I npm run migrate name-of-specific-miration-file.

I use knex. How can I run only the specific migration file I want it to run?


Solution

  • I got it to work doing the following:

    • On MySql command line: create table my_table_name (hello text);
    • In terminal: knex migrate:down name_of_migration_file.js
    • In terminal: knex migrate:up name_of_migration_file.js