summaryrefslogtreecommitdiffstats
path: root/utils/test/vnfcatalogue/helpers/migrate.js
diff options
context:
space:
mode:
authorMorgan Richomme <morgan.richomme@orange.com>2017-09-08 08:43:19 +0200
committerMorgan Richomme <morgan.richomme@orange.com>2017-09-08 08:43:19 +0200
commitf237c7b95134621c0a32eda31f186c53bfcd2e46 (patch)
treec4ddda472a696c35a7a06daf7bd8fa3a68177115 /utils/test/vnfcatalogue/helpers/migrate.js
parent25d99dbc0c41217abd369a48fce1f69d636b7134 (diff)
Remove VNF catalogue from releng
It has been transfered to sample vnf repo [1] [1]: https://git.opnfv.org/samplevnf/tree/VNF_Catalogue Change-Id: I418151bd24517efeb66fc0ae76cb9e091bd130f6 Signed-off-by: Morgan Richomme <morgan.richomme@orange.com>
Diffstat (limited to 'utils/test/vnfcatalogue/helpers/migrate.js')
-rw-r--r--utils/test/vnfcatalogue/helpers/migrate.js86
1 files changed, 0 insertions, 86 deletions
diff --git a/utils/test/vnfcatalogue/helpers/migrate.js b/utils/test/vnfcatalogue/helpers/migrate.js
deleted file mode 100644
index 3f4d892dc..000000000
--- a/utils/test/vnfcatalogue/helpers/migrate.js
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 Kumar Rishabh(penguinRaider) and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Apache License, Version 2.0
- * which accompanies this distribution, and is available at
- * http://www.apache.org/licenses/LICENSE-2.0
- *******************************************************************************/
-
-var knex = require('knex')({
- client: 'mysql',
- connection: {
- host : process.env.DB_HOST,
- user : process.env.DB_USER,
- password : process.env.DB_PASSWORD,
- database : process.env.DB_DATABASE,
- charset : 'utf8'
- }
-});
-var Schema = require('./schema');
-var sequence = require('when/sequence');
-var _ = require('lodash');
-function createTable(tableName) {
- return knex.schema.createTable(tableName, function (table) {
- var column;
- var columnKeys = _.keys(Schema[tableName]);
- _.each(columnKeys, function (key) {
- if (Schema[tableName][key].type === 'text' && Schema[tableName][key].hasOwnProperty('fieldtype')) {
- column = table[Schema[tableName][key].type](key, Schema[tableName][key].fieldtype);
- }
- else if (Schema[tableName][key].type === 'enum' && Schema[tableName][key].hasOwnProperty('values') && Schema[tableName][key].nullable === true) {
- console.log(Schema[tableName][key].values);
- column = table[Schema[tableName][key].type](key, Schema[tableName][key].values).nullable();
- }
- else if (Schema[tableName][key].type === 'enum' && Schema[tableName][key].hasOwnProperty('values')) {
- console.log(Schema[tableName][key].values);
- column = table[Schema[tableName][key].type](key, Schema[tableName][key].values).notNullable();
- }
- else if (Schema[tableName][key].type === 'string' && Schema[tableName][key].hasOwnProperty('maxlength')) {
- column = table[Schema[tableName][key].type](key, Schema[tableName][key].maxlength);
- }
- else {
- column = table[Schema[tableName][key].type](key);
- }
- if (Schema[tableName][key].hasOwnProperty('nullable') && Schema[tableName][key].nullable === true) {
- column.nullable();
- }
- else {
- column.notNullable();
- }
- if (Schema[tableName][key].hasOwnProperty('primary') && Schema[tableName][key].primary === true) {
- column.primary();
- }
- if (Schema[tableName][key].hasOwnProperty('unique') && Schema[tableName][key].unique) {
- column.unique();
- }
- if (Schema[tableName][key].hasOwnProperty('unsigned') && Schema[tableName][key].unsigned) {
- column.unsigned();
- }
- if (Schema[tableName][key].hasOwnProperty('references')) {
- column.references(Schema[tableName][key].references);
- }
- if (Schema[tableName][key].hasOwnProperty('defaultTo')) {
- column.defaultTo(Schema[tableName][key].defaultTo);
- }
- });
- });
-}
-function createTables () {
- var tables = [];
- var tableNames = _.keys(Schema);
- tables = _.map(tableNames, function (tableName) {
- return function () {
- return createTable(tableName);
- };
- });
- return sequence(tables);
-}
-createTables()
-.then(function() {
- console.log('Tables created!!');
- process.exit(0);
-})
-.catch(function (error) {
- throw error;
-});