I have tried to setup a data migration service using postgrator version 7.1.0. I have the following code
import Postgrator from "postgrator";
import pg from "pg";
import { dirname } from "path";
import { fileURLToPath } from "url";
const __dirname = dirname(fileURLToPath(import.meta.url));
async function doMigration() {
// Create a client of your choice
const client = new pg.Client({
host: "0.0.0.1",
port: 9075,
database: "test",
user: "test",
password: "!testPwd",
});
try {
// Establish a database connection
await client.connect();
// Create postgrator instance
const postgrator = new Postgrator({
migrationDirectory: __dirname + '/migration-scripts',
driver: "pg",
database: "test",
schemaTable: "migration_version",
execQuery: (query) => client.query(query),
});
await postgrator.migrate();
console.log("schema migration completed successfully")
} catch (error) {
console.error(error);
}
// Once done migrating, close your connection.
await client.end();
}
doMigration();
But I got an error when running the above code
TypeError: invalid pattern