- Add script to your package.json ```json { "db:setup": "node --experimental-modules --no-warnings ./src/db/migrate.mjs" } ```

Usage no npm install needed!

<script type="module">
  import mjsDbMigrator from 'https://cdn.skypack.dev/mjs-db-migrator';


DataBase migrator for mysql

  • Add script to your package.json
"db:setup": "node --experimental-modules --no-warnings ./src/db/migrate.mjs"
  • Create migrate.mjs file
import migrate from 'mjs-db-migrator'

  config: {
    MYSQL_USER: 'root',
    MYSQL_PASSWORD: 'root',
    MYSQL_DATABASE: 'test',
    MYSQL_HOST: 'localhost'
  dir: './src/db/migrations',
  migrations: [
    // 'users'
  • if migrations array not specified or empty then all tables in database will be deleted, else only specified tables will be deleted
  • dir is that directory where migrations can be found