Skip to content

Commit

Permalink
commit for version 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vamsee committed Apr 30, 2020
2 parents cd7ac4d + 5a5c633 commit 33b02ae
Show file tree
Hide file tree
Showing 15 changed files with 469 additions and 487 deletions.
13 changes: 7 additions & 6 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/client/
/coverage/
/node_modules/
server/dropdb.js
/lib/expression-language/expression-syntax-parser.js
/test/
build/
client/
coverage/
node_modules/
test/
drop.js
Gruntfile.js
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"no-undefined": 1, // http://eslint.org/docs/rules/no-undefined
"no-with": 2, // http://eslint.org/docs/rules/no-with
"handle-callback-err": 1, // http://eslint.org/docs/rules/handle-callback-err
"radix": 2, // http://eslint.org/docs/rules/radix
"radix": 0, // http://eslint.org/docs/rules/radix
"wrap-iife": [2, "any"], // http://eslint.org/docs/rules/wrap-iife
"yoda": 2, // http://eslint.org/docs/rules/yoda

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ test/extracts/
test/tmp/
test/db/
package-lock.json
oracle-user.sh
36 changes: 0 additions & 36 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,6 @@ module.exports = function GruntConfig(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

mkdir: {
all: {
options: {
create: ['dist']
}
}
},

copy: {
main: {
files: [
// includes files within path and its sub-directories
{
expand: true,
src: ['**', '!node_modules/**', '!coverage/**'],
dest: 'dist/'
}
]
}
},

mochaTest: {
test: {
options: {
quiet: false,
clearRequireCache: true,
timeout: 100000
},
src: ['test/test.js']
}
},

clean: {
coverage: {
src: ['coverage/']
Expand Down Expand Up @@ -72,12 +40,8 @@ module.exports = function GruntConfig(grunt) {
});

// Add the grunt-mocha-test tasks.
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-mocha-istanbul');
grunt.loadNpmTasks('grunt-contrib-clean');

grunt.loadNpmTasks('grunt-mkdir');
grunt.loadNpmTasks('grunt-contrib-copy');

grunt.registerTask('test-with-coverage', ['clean:coverage', 'mocha_istanbul']);
};
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [Setup](#Setup)<BR>
- [Usage](#Usage)<BR>
- [Migration from Command-Line](#Migration from Command-Line)<BR>
- [Running Custom JS files](#Running Custom JS files)<BR>
- [Downloading zip file of DB data](#Downloading zip file of DB data)<BR>
- [Uploading zip file for migration](#Uploading zip file for migration)<BR>
- [Configuration](#Configuration)
Expand Down Expand Up @@ -246,6 +247,33 @@ An example of MigrationLogs is shown below:
The `server/migrate.js` can be executed repeatedly with/without additional data in the `<server>/db` folder.
<a name="Running Custom JS files"></a>
### Running Custom JS files
In cases where migration needs additional complex logic to be executed, you can wrap the `migrate` call in custom javascript module callback.
```javascript
var app = require('oe-cloud');
var preMigrate = require('some/path/pre-migrate.js');
var postMigrate = require('some/path/post-migrate.js');
app.boot(__dirname, function (err) {
if (err) { console.log(err); process.exit(1); }

var m = require('oe-migration');
preMigrate('arguments', function(err, data) {
if(err) process.exit(1);
m.migrate(function(err, oldDbVersion, migratedVersions) {
if(err) process.exit(1);
postMigrate('arguments', function(err, data){
if(err) process.exit(1); else process.exit(0);
}
});
}
});
```
You must ensure the rerunnability of your custom javascript code for a rerunnable migration.
<a name="bookmark3"></a>
<a name="Downloading zip file of DB data"></a>
### Downloading zip file of DB data
Expand Down
4 changes: 3 additions & 1 deletion lib/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ function migrateFromPath(migrationPath, cb) {
});
// eslint-disable-next-line no-inner-declarations
function updateStructure() {
var ds = Model.getDataSource();
var opts = { ctx: {} };
opts.ctx = (meta.contexts && modelDefSettings.migrationCtxId && meta.contexts[modelDefSettings.migrationCtxId]) || {};
var ds = Model.getDataSource(opts);
var settings = {};
settings.base = modelDefSettings.base;
settings.description = modelDefSettings.description;
Expand Down
11 changes: 3 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oe-migration",
"version": "2.1.0",
"version": "2.2.0",
"description": "This module is an app-list module for oe-Cloud based applications. It provides the ability to perform data migration and/or data seeding into the app db from json files",
"engines": {
"node": ">=6"
Expand All @@ -20,23 +20,18 @@
"devDependencies": {
"babel-eslint": "7.2.3",
"chai": "3.4.1",
"chai-datetime": "1.4.0",
"chai-things": "0.2.0",
"chalk": "1.1.1",
"eslint": "4.10.0",
"grunt": "1.0.4",
"grunt-banner": "0.6.0",
"grunt-cli": "1.3.2",
"grunt-contrib-clean": "2.0.0",
"grunt-contrib-copy": "1.0.0",
"grunt-jsbeautifier": "0.2.13",
"grunt-mkdir": "1.0.0",
"grunt-mocha-istanbul": "5.0.2",
"grunt-mocha-test": "0.13.3",
"istanbul": "0.4.5",
"mocha": "5.2.0",
"oe-cloud": "^2.0.0",
"loopback-connector-mongodb": "3.9.2",
"oe-connector-mongodb": "^2.0.0",
"oe-connector-oracle": "^2.0.0",
"oe-connector-postgresql": "^2.0.0",
"oe-multi-tenancy": "^2.0.0",
"superagent-defaults": "0.1.14",
Expand Down
3 changes: 1 addition & 2 deletions test/datasources.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
"name": "transient",
"connector": "transient"
},

"db": {
"host": "localhost",
"port": 27017,
"url": "mongodb://localhost:27017/oe-migration",
"database": "oe-migration",
"password": "admin",
"name": "db",
"connector": "mongodb",
"connector": "oe-connector-mongodb",
"user": "admin",
"connectionTimeout": 500000,
"connectTimeoutMS": 500000,
Expand Down
41 changes: 19 additions & 22 deletions test/datasources.mongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,24 @@
*
*/
var mongoHost = process.env.MONGO_HOST || 'localhost';
var mongoPort = process.env.MONGO_PORT ? parseInt(process.env.MONGO_PORT) : 27017;
var dbName = process.env.DB_NAME || 'oe-migration-test';
module.exports =
{
"memdb": {
"name": "memdb",
"connector": "memory"
},
"transient": {
"name": "transient",
"connector": "transient"
},
"db": {
"host": mongoHost,
"port": 27017,
"url": "mongodb://" + mongoHost + ":27017/" + dbName,
"database": dbName,
"password": "admin",
"name": "db",
"connector": "mongodb",
"user": "admin",
"connectionTimeout": 500000
}
module.exports = {
'memdb': {
'name': 'memdb',
'connector': 'memory'
},
'transient': {
'name': 'transient',
'connector': 'transient'
},
'db': {
'host': mongoHost,
'port': mongoPort,
'url': 'mongodb://' + mongoHost + ':' + mongoPort + '/' + dbName,
'database': dbName,
'name': 'db',
'connector': 'oe-connector-mongodb',
'connectionTimeout': 500000
}
};

44 changes: 19 additions & 25 deletions test/datasources.oracle.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,31 @@
* Bangalore, India. All Rights Reserved.
*
*/
/**
**
** ©2016-2017 EdgeVerve Systems Limited (a fully owned Infosys subsidiary),
** Bangalore, India. All Rights Reserved.
**
**/

var oracleSID = process.env.ORACLE_SID || 'orclpdb.ad.infosys.com';
var oracleSID = process.env.ORACLE_SID || 'ORCLCDB';
var oracleHost = process.env.ORACLE_HOST || 'localhost';
var oraclePort = process.env.ORACLE_PORT || 1521;
var oraclePort = process.env.ORACLE_PORT ? parseInt(process.env.ORACLE_PORT) : 1521;
var oracleUserName = process.env.ORACLE_USERNAME || 'oeadmin';
var oracleUserPassword = process.env.ORACLE_PASSWORD || 'oeadmin';

module.exports = {
'nullsrc': {
'name': 'nullsrc',
'connector': 'memory'
},
'transient': {
'name': 'transient',
'connector': 'transient'
},
'db': {
'name': 'db',
'connector': 'oe-connector-oracle',
'database': oracleSID,
'host': oracleHost,
'port': oraclePort,
'password': oracleUserPassword,
'user': oracleUserName
}
'nullsrc': {
'name': 'nullsrc',
'connector': 'memory'
},
'transient': {
'name': 'transient',
'connector': 'transient'
},
'db': {
'name': 'db',
'connector': 'oe-connector-oracle',
'database': oracleSID,
'host': oracleHost,
'port': oraclePort,
'password': oracleUserPassword,
'user': oracleUserName
}
};


43 changes: 22 additions & 21 deletions test/datasources.postgres.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,30 @@
*
*/
var postgresHost = process.env.POSTGRES_HOST || 'localhost';
var postgresPort = process.env.POSTGRES_PORT ? parseInt(process.env.POSTGRES_PORT) : 5432;
var dbName = process.env.DB_NAME || 'oe-migration-test';
module.exports =
module.exports =
{
"memdb": {
"name": "memdb",
"connector": "memory"
},
"transient": {
"name": "transient",
"connector": "transient"
},
'memdb': {
'name': 'memdb',
'connector': 'memory'
},
'transient': {
'name': 'transient',
'connector': 'transient'
},

"db": {
"host": postgresHost,
"port": 5432,
"url": "postgres://postgres:postgres@" + postgresHost + ":5432/" + dbName,
"database": dbName,
"password": "postgres",
"name": "db",
"connector": "oe-connector-postgresql",
"user": "postgres",
"max": 50,
"connectionTimeout": 50000
}
'db': {
'host': postgresHost,
'port': postgresPort,
'url': 'postgres://postgres:postgres@' + postgresHost + ':' + postgresPort + '/' + dbName,
'database': dbName,
'password': 'postgres',
'name': 'db',
'connector': 'oe-connector-postgresql',
'user': 'postgres',
'max': 50,
'connectionTimeout': 50000
}
};

3 changes: 2 additions & 1 deletion test/db1/25.0.0/ddl/migration-test1.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
"autoscope" : ["tenantId"],
"validations": [],
"relations": {},
"methods": {}
"methods": {},
"migrationCtxId": "/default/tenant1"
}
Loading

0 comments on commit 33b02ae

Please sign in to comment.