-1

I had about 30 migration files (sequelize) looking like the following that I wanted to copy into migrations for another table, while changing the migration file's name (sequelize relies on utc-timestamp) and changing the table-name in the file at the same time:

"use strict";

module.exports = {
  up: (queryInterface, Sequelize) => {
    return queryInterface.addColumn("Providers", "column-name", { type: Sequelize.DECIMAL(8, 2) });
  },

  down: (queryInterface, Sequelize) => {
    return queryInterface.removeColumn("Providers", "column-name");
  }
};
rohit_wason
  • 177
  • 2
  • 9

1 Answers1

0
for f in migrations/*[ce]c-to*; do cat "$f" | sed 's/Providers/PracticeAssignments/g' > migrations/$(date +'%Y%m%d%H%M%S' -u)-$(echo $f | sed 's/provider/practice-assignment/g' | cut -d'-' -f2-); done

^^that script seemed to have done the trick!

rohit_wason
  • 177
  • 2
  • 9