Add support for enum & expand vnf_catalogue schema 65/30465/1
authorKumar Rishabh <shailrishabh@gmail.com>
Tue, 14 Mar 2017 19:40:41 +0000 (01:10 +0530)
committerKumar Rishabh <shailrishabh@gmail.com>
Tue, 14 Mar 2017 19:42:14 +0000 (01:12 +0530)
Adds support for enum and expands the vnf_catalogue schema.

Change-Id: Ifa2be1a01ad8e12f5f34d6472976f2a862189d48
Signed-off-by: Kumar Rishabh <shailrishabh@gmail.com>
utils/test/vnfcatalogue/helpers/migrate.js
utils/test/vnfcatalogue/helpers/schema.js

index ec20905..63ee9c0 100644 (file)
@@ -28,6 +28,14 @@ function createTable(tableName) {
         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);
         }
index 2aaf99a..4a7559a 100644 (file)
@@ -31,10 +31,16 @@ var Schema = {
         lines_of_code: {type: 'integer', nullable: true, unsigned: true},
         versions: {type: 'integer', nullable: true, unsigned: true},
         no_of_developers: {type: 'integer', nullable: true, unsigned: true},
+        no_of_stars: {type: 'integer', nullable: true, unsigned: true},
+        license: {type: 'enum', nullable: false, values: ['MIT', 'GPL', 'GPL_V2', 'BSD', 'APACHE']},
+        opnfv_indicator: {type: 'enum', nullable: false, values: ['gold', 'silver', 'platinum']},
+        complexity: {type: 'enum', nullable: true, values: ['low', 'medium', 'high']},
+        activity: {type: 'enum', nullable: true, values: ['low', 'medium', 'high']},
+        last_updated: {type: 'dateTime', nullable: true},
     },
     tag: {
         tag_id: {type: 'increments', nullable: false, primary: true},
-        name: {type: 'string', maxlength: 150, nullable: false}
+        tag_name: {type: 'string', maxlength: 150, nullable: false}
     },
     vnf_tags: {
         vnf_tag_id: {type: 'increments', nullable: false, primary: true},