From 7638c9e49be6a0e195ad87597530fd0db257f244 Mon Sep 17 00:00:00 2001 From: Krishna maurya Date: Thu, 23 Sep 2021 00:57:00 +0530 Subject: [PATCH 1/2] updated notes for setting up mysql --- migrations/db-migrate-command | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/migrations/db-migrate-command b/migrations/db-migrate-command index 4e90ded..a40ea84 100644 --- a/migrations/db-migrate-command +++ b/migrations/db-migrate-command @@ -1,6 +1,14 @@ From the root of project ====>>>>>> +Create databse `exp` + create database exp; + +Create user and grant all access on all database on localhost + CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password'; + GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost'; + FLUSH PRIVILEGES; + To create the existing tables node ./node_modules/db-migrate/bin/db-migrate up `tablename` --env development @@ -25,6 +33,9 @@ Speciic to MacOS 9. Try login in with new password. 10. Done. +-- if creating tables with db-migrate commands not work out even with above fix directly +run the mysql query into mysql prompt. + Also there are two type of authentication mechanism 'caching_sha2_password' (ver 8) and 'mysql_native_password' (ver older). References: From 5aa511b7cca28cb4be1ae45fe33b68f73b9c64d3 Mon Sep 17 00:00:00 2001 From: Krishna maurya Date: Fri, 24 Sep 2021 20:54:54 +0530 Subject: [PATCH 2/2] added migration for title character set change from latin1 to utf8 --- ...4151954-experience-title-character-utf8.js | 53 +++++++++++++++++++ ...4-experience-title-character-utf8-down.sql | 2 + ...954-experience-title-character-utf8-up.sql | 2 + 3 files changed, 57 insertions(+) create mode 100644 migrations/20210924151954-experience-title-character-utf8.js create mode 100644 migrations/sqls/20210924151954-experience-title-character-utf8-down.sql create mode 100644 migrations/sqls/20210924151954-experience-title-character-utf8-up.sql diff --git a/migrations/20210924151954-experience-title-character-utf8.js b/migrations/20210924151954-experience-title-character-utf8.js new file mode 100644 index 0000000..2cc7b90 --- /dev/null +++ b/migrations/20210924151954-experience-title-character-utf8.js @@ -0,0 +1,53 @@ +'use strict'; + +var dbm; +var type; +var seed; +var fs = require('fs'); +var path = require('path'); +var Promise; + +/** + * We receive the dbmigrate dependency from dbmigrate initially. + * This enables us to not have to rely on NODE_PATH. + */ +exports.setup = function(options, seedLink) { + dbm = options.dbmigrate; + type = dbm.dataType; + seed = seedLink; + Promise = options.Promise; +}; + +exports.up = function(db) { + var filePath = path.join(__dirname, 'sqls', '20210924151954-experience-title-character-utf8-up.sql'); + return new Promise( function( resolve, reject ) { + fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ + if (err) return reject(err); + console.log('received data: ' + data); + + resolve(data); + }); + }) + .then(function(data) { + return db.runSql(data); + }); +}; + +exports.down = function(db) { + var filePath = path.join(__dirname, 'sqls', '20210924151954-experience-title-character-utf8-down.sql'); + return new Promise( function( resolve, reject ) { + fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ + if (err) return reject(err); + console.log('received data: ' + data); + + resolve(data); + }); + }) + .then(function(data) { + return db.runSql(data); + }); +}; + +exports._meta = { + "version": 1 +}; diff --git a/migrations/sqls/20210924151954-experience-title-character-utf8-down.sql b/migrations/sqls/20210924151954-experience-title-character-utf8-down.sql new file mode 100644 index 0000000..63f17e5 --- /dev/null +++ b/migrations/sqls/20210924151954-experience-title-character-utf8-down.sql @@ -0,0 +1,2 @@ +/* Replace with your SQL commands */ +ALTER TABLE `experiences` MODIFY `title` varchar(180) CHARACTER SET 'latin1'; \ No newline at end of file diff --git a/migrations/sqls/20210924151954-experience-title-character-utf8-up.sql b/migrations/sqls/20210924151954-experience-title-character-utf8-up.sql new file mode 100644 index 0000000..280d253 --- /dev/null +++ b/migrations/sqls/20210924151954-experience-title-character-utf8-up.sql @@ -0,0 +1,2 @@ +/* Replace with your SQL commands */ +ALTER TABLE `experiences` MODIFY `title` varchar(180) CHARACTER SET 'utf8'; \ No newline at end of file