Skip to content

Instantly share code, notes, and snippets.

@aizatto
Created May 18, 2019 05:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aizatto/6428f9a2a5191126d62a9c35f37a8dc5 to your computer and use it in GitHub Desktop.
Save aizatto/6428f9a2a5191126d62a9c35f37a8dc5 to your computer and use it in GitHub Desktop.
knex: Migrate from MySQL to PostgreSQL
const pg = require('pg');
pg.defaults.ssl = true;
const configs = require("config/knexfile.js");
const mysql = require("knex")(configs["mysql"]);
const postgres = require("knex")(configs["postgres"]);
async function migrate(table) {
const results = await mysql.from(table);
await postgres(table).insert(results);
}
(async () => {
await migrate("users");
await migrate("entries");
await migrate("tags");
await migrate("entry_to_tag");
})().catch(err => {
console.error(err);
process.exit(1);
});
@eufelipemateus
Copy link

This don't working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment