From 0af6859c98349dde72cca61e4271c56b9d8015aa Mon Sep 17 00:00:00 2001 From: rahulsps Date: Fri, 23 Jul 2021 13:53:39 +0530 Subject: [PATCH 1/3] add migration --- config/aws.json | 39 ++++++++++++++++++++++++++++ config/config.json | 16 ++++++++++++ migrations/20210723082011-shop.js | 42 +++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 config/aws.json create mode 100644 config/config.json create mode 100644 migrations/20210723082011-shop.js diff --git a/config/aws.json b/config/aws.json new file mode 100644 index 0000000..dc998bd --- /dev/null +++ b/config/aws.json @@ -0,0 +1,39 @@ +{ + "app_route": "http://localhost:3000/", + "bot_account": "rahulsps", + "google_analytics": "", + "db": { + "database": "ebdb", + "username": "nodeskeletonU", + "password": "node_skeletonPwD3$", + "options": { + "timezone": "+05:30", + "dialect": "mysql", + "dialectOptions": { + "decimalNumbers": true + }, + "port": 3306, + "pool": { + "max": 50, + "min": 0, + "idle": 500 + }, + "replication": { + "write": { + "username": "root", + "password": "root", + "host": "localhost", + "port": 3306 + }, + "read": [ + { + "username": "root", + "password": "root", + "host": "localhost", + "port": 3306 + } + ] + } + } + } +} diff --git a/config/config.json b/config/config.json new file mode 100644 index 0000000..d5c32de --- /dev/null +++ b/config/config.json @@ -0,0 +1,16 @@ +{ + "dev": { + "username": "root", + "password": "root", + "database": "node_skeleton", + "host": "127.0.0.1", + "dialect": "mysql" + }, + "aws": { + "username": "nodeskeletonU", + "password": "node_skeletonPwD3", + "database": "ebdb", + "host": "", + "dialect": "mysql" + } +} diff --git a/migrations/20210723082011-shop.js b/migrations/20210723082011-shop.js new file mode 100644 index 0000000..993d9c6 --- /dev/null +++ b/migrations/20210723082011-shop.js @@ -0,0 +1,42 @@ +'use strict'; + +module.exports = { + up: (queryInterface, Sequelize) => { + return queryInterface.createTable('shops', + { + id: { + type: Sequelize.INTEGER(20), + unique: true, + allowNull: false, + primaryKey: true, + autoIncrement: true, + unsigned: true + }, + shop_name: { + type: Sequelize.STRING(255), + unique: true, + allowNull: false + }, + shop_url: { + type: Sequelize.STRING(255), + unique: true, + allowNull: true + }, + access_token: { + type: Sequelize.STRING(255), + unique: true, + allowNull: true + } + }, + { + engine: 'InnoDB', // default: 'InnoDB' + schema: '', // default: public, PostgreSQL only. + comment: 'shops table', // comment for table + collate: 'utf8_bin' // collation, MYSQL only + } + ); + + }, + + down: (queryInterface, Sequelize) => {} +}; From 86abfb134a4d4572859166f4e545544c2adb7137 Mon Sep 17 00:00:00 2001 From: rahulsps Date: Fri, 23 Jul 2021 14:07:27 +0530 Subject: [PATCH 2/3] aws connection --- config/aws.json | 22 +++++++++++----------- config/config.json | 7 ++++--- config/dev.json | 2 -- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/config/aws.json b/config/aws.json index dc998bd..3c6d282 100644 --- a/config/aws.json +++ b/config/aws.json @@ -1,11 +1,11 @@ { - "app_route": "http://localhost:3000/", - "bot_account": "rahulsps", - "google_analytics": "", + "app_route": "http://nodeskeleton-env.eba-xdbkk62b.us-east-1.elasticbeanstalk.com/", "db": { "database": "ebdb", "username": "nodeskeletonU", "password": "node_skeletonPwD3$", + "host": "aa1wa97ei75c1y9.cvd3esvflamb.us-east-1.rds.amazonaws.com", + "port": 3306, "options": { "timezone": "+05:30", "dialect": "mysql", @@ -20,17 +20,17 @@ }, "replication": { "write": { - "username": "root", - "password": "root", - "host": "localhost", - "port": 3306 + "username": "nodeskeletonU", + "password": "node_skeletonPwD3$", + "host": "aa1wa97ei75c1y9.cvd3esvflamb.us-east-1.rds.amazonaws.com", + "port": 3306 }, "read": [ { - "username": "root", - "password": "root", - "host": "localhost", - "port": 3306 + "username": "nodeskeletonU", + "password": "node_skeletonPwD3$", + "host": "aa1wa97ei75c1y9.cvd3esvflamb.us-east-1.rds.amazonaws.com", + "port": 3306 } ] } diff --git a/config/config.json b/config/config.json index d5c32de..63bbe82 100644 --- a/config/config.json +++ b/config/config.json @@ -7,10 +7,11 @@ "dialect": "mysql" }, "aws": { - "username": "nodeskeletonU", - "password": "node_skeletonPwD3", "database": "ebdb", - "host": "", + "username": "nodeskeletonU", + "password": "node_skeletonPwD3$", + "host": "aa1wa97ei75c1y9.cvd3esvflamb.us-east-1.rds.amazonaws.com", + "port": 3306, "dialect": "mysql" } } diff --git a/config/dev.json b/config/dev.json index d0b8be4..9fa1b67 100755 --- a/config/dev.json +++ b/config/dev.json @@ -1,7 +1,5 @@ { "app_route": "http://localhost:3000/", - "bot_account": "rahulsps", - "google_analytics": "", "db": { "database": "node_skeleton", "username": "root", From ee639be96fdbc8bd52006ac8fa43b54a0e608ef5 Mon Sep 17 00:00:00 2001 From: Rahul Bhola <20718757+rahulsps@users.noreply.github.com> Date: Fri, 23 Jul 2021 14:11:42 +0530 Subject: [PATCH 3/3] Update README.md --- README.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3327e79..3ec72de 100644 --- a/README.md +++ b/README.md @@ -1 +1,20 @@ -# node_skeleton \ No newline at end of file +# node_skeleton +
+Add env credentials in config/config.json + + 1. Genrate new migrations
+ - `sequelize migration:generate --name `
+ + 2. Run migrations
+ - `sequelize db:migrate --env `
+ 3. Undo migrations
+ - `sequelize db:migrate:undo`
+ - `sequelize db:migrate:undo:all`
+ 4. Genrate new seeder
+ - `sequelize seed:generate`
+ 5. Run seeders
+ - `sequelize db:seed --seed `
+ - `sequelize db:seed:all` + 6. Undo seeders
+ - `sequelize db:seed:undo`
+ - `sequelize db:seed:undo:all`