Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database Migration to Manage App #197

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ Jenkinsfile
*.swp
*.iml

# env
.env

1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM mhart/alpine-node:10 as builder
RUN apk add --no-cache make gcc g++ python
COPY ./package*.json ./
RUN npm install --production
RUN npm install -g db-migrate

FROM mhart/alpine-node:10

Expand Down
1 change: 1 addition & 0 deletions Dockerfile_slim
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ WORKDIR /usr/src/app
# Installation
ADD . .
RUN npm install
RUN npm install -g db-migrate

EXPOSE 5001
CMD [ "npm", "start" ]
4 changes: 4 additions & 0 deletions database.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"default": "postgree",
"postgree": {"ENV": "POSTGRESURL"}
}
53 changes: 53 additions & 0 deletions migrations/20190516204615-add-sequences.js
Original file line number Diff line number Diff line change
@@ -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', '20190516204615-add-sequences-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', '20190516204615-add-sequences-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
};
53 changes: 53 additions & 0 deletions migrations/20190516212600-add-core-tables.js
Original file line number Diff line number Diff line change
@@ -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', '20190516212600-add-core-tables-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', '20190516212600-add-core-tables-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
};
53 changes: 53 additions & 0 deletions migrations/20190516214209-add-core-views.js
Original file line number Diff line number Diff line change
@@ -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', '20190516214209-add-core-views-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', '20190516214209-add-core-views-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
};
53 changes: 53 additions & 0 deletions migrations/20190516220917-v232-add-log-correspondence-tables.js
Original file line number Diff line number Diff line change
@@ -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', '20190516220917-v232-add-log-correspondence-tables-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', '20190516220917-v232-add-log-correspondence-tables-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
};
43 changes: 43 additions & 0 deletions migrations/sqls/20190516204615-add-sequences-down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* Sequences */

DROP SEQUENCE agentidgen;

DROP SEQUENCE agents_agent_id_seq;

DROP SEQUENCE entities_entity_id_seq;

DROP SEQUENCE entityidgen;

DROP SEQUENCE expressionidgen;

DROP SEQUENCE expressions_expression_id_seq;

DROP SEQUENCE intentidgen;

DROP SEQUENCE intents_intent_id_seq;

DROP SEQUENCE actions_action_id_seq;

DROP SEQUENCE nlu_log_log_id_seq;

DROP SEQUENCE parse_log_parse_log_id_seq;

DROP SEQUENCE core_parse_log_core_parse_log_id_seq;

DROP SEQUENCE messages_messages_id_seq;

DROP SEQUENCE parameteridgen;

DROP SEQUENCE parameters_parameter_id_seq;

DROP SEQUENCE responseidgen;

DROP SEQUENCE responses_response_id_seq;

DROP SEQUENCE response_type_response_type_id_seq;

DROP SEQUENCE synonym_variant_synonym_id_seq;

DROP SEQUENCE synonyms_synonym_id_seq;

DROP SEQUENCE regex_id_seq;
Loading