From 33e0ab20bccdff2f83ea4297f9f1ea98d9141e47 Mon Sep 17 00:00:00 2001 From: Nitay Rabinovich Date: Mon, 25 Feb 2019 19:45:27 +0200 Subject: [PATCH] Fix migration connect (#94) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix migration * Fix migration * Fןס PR --- .../20190215192818-migrate-from-spark.js | 27 ++++++++----------- package.json | 2 +- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/db/migrations/20190215192818-migrate-from-spark.js b/db/migrations/20190215192818-migrate-from-spark.js index bae53fc0..333fe935 100644 --- a/db/migrations/20190215192818-migrate-from-spark.js +++ b/db/migrations/20190215192818-migrate-from-spark.js @@ -106,40 +106,35 @@ async function getGroupMembersData (group, members) { role, group_id: group.id, user_id: member.user_id, - createdAt: new Date(), - updatedAt: new Date(), - record_status: 'active', + createdAt: new Date (), + updatedAt: new Date (), + record_status: 'active', }; communitiesMemberships.push (communitiesMembership); } return communitiesMemberships; } - /** +/** * Starting function */ async function Migrate (queryInterface) { - const isLocal = process.argv.includes ('local'); - try { + try { const sparkConfig = { username: process.env.SPARK_DB_USER || 'spark', password: process.env.SPARK_DB_PASSWORD || 'spark', database: process.env.SPARK_DB_DBNAME || 'spark', - host: process.env.SPARK_DB_HOSTNAME || process.env.SPARK_DB_HOSTNAME || isLocal - ? 'localhost' - : 'sparkdb', + host: process.env.SPARK_DB_HOSTNAME || 'sparkdb', dialect: 'mysql', - logging: false + logging: false, }; const communitiesConfig = { dialect: 'mysql', - host: process.env.MYSQL_DB_HOST || isLocal - ? 'localhost' - : 'communitiesdb', + host: process.env.MYSQL_DB_HOST || 'communitiesdb', database: process.env.MYSQL_DB_NAME || 'communities', username: process.env.MYSQL_DB_USERNAME || 'root', password: process.env.MYSQL_DB_PASSWORD, - logging: false + logging: false, }; const communitiesDb = await getCommunitiesDb (communitiesConfig); const sparkDb = await getSparkDb (sparkConfig); @@ -163,12 +158,12 @@ async function Migrate (queryInterface) { ) ); if (groupMembers && groupMembers.length) { - await queryInterface.bulkInsert('GroupMembers', groupMembers); + await queryInterface.bulkInsert ('GroupMembers', groupMembers); } results.success.push (result); } catch (e) { results.failure.push (group.spark_id); - console.warn(e); + console.warn (e); } } console.log (`Migrated ${results.success.length} groups`); diff --git a/package.json b/package.json index 08956eed..2f738fb4 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,7 @@ "test": "node scripts/test.js", "test:once": "jest", "sequelize": "sequelize", - "migrate": "sequelize db:migrate local && npm run erd", + "migrate": "sequelize db:migrate && npm run erd", "createdb": "mysql -u root -p < db/create_db.sql", "erd": "node db/erd.js" },