-
Notifications
You must be signed in to change notification settings - Fork 8
/
runSequelizeMigrations.js
31 lines (23 loc) · 1.02 KB
/
runSequelizeMigrations.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const {exec} = require('child_process');
import { readdir } from 'fs/promises'
// npx sequelize-cli db:migrate --url 'mysql://root:password@mysql_host.com/database_name'
async function runManualMigrations() {
// const getDirectories = async source =>
// (await readdir(source, { withFileTypes: true }))
// .filter(dirent => dirent.isDirectory())
// .map(dirent => dirent.name)
// console.log(await getDirectories('/app/'))
// console.log(await getDirectories('/app/.next/'))
// console.log(await getDirectories('/'))
return new Promise((resolve, reject) => {
const migrate = exec(
"npx sequelize-cli db:migrate --env=local --url 'mysql://"+process.env.DB_USER+":"+process.env.DB_PASS+"@"+process.env.DB_HOST+"/"+process.env.DB_NAME+"'",
{env: process.env},
err => (err ? reject(err): resolve(true))
);
// Forward stdout+stderr to this process
migrate.stdout.pipe(process.stdout);
migrate.stderr.pipe(process.stderr);
});
}
export default runManualMigrations