/*
 #
 # Copyright (c) 2018 nexB Inc. and others. All rights reserved.
 # https://nexb.com and https://github.com/nexB/scancode-toolkit/
 # The ScanCode software is licensed under the Apache License version 2.0.
 # AboutCode is a trademark of nexB Inc.
 #
 # You may not use this software except in compliance with the License.
 # You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0
 # Unless required by applicable law or agreed to in writing, software distributed
 # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 # CONDITIONS OF ANY KIND, either express or implied. See the License for the
 # specific language governing permissions and limitations under the License.
 #
 */

const {jsonDataType} = require('./databaseUtils');

module.exports = function(sequelize, DataTypes) {
  return sequelize.define(
    'packages',
    {
      type: DataTypes.STRING,
      name: DataTypes.STRING,
      version: DataTypes.STRING,
      primary_language: DataTypes.STRING,
      packaging: DataTypes.STRING,
      summary: DataTypes.STRING,
      description: DataTypes.STRING,
      payload_type: DataTypes.STRING,
      size: DataTypes.INTEGER,
      release_date: DataTypes.STRING,
      authors: jsonDataType('authors'),
      maintainers: jsonDataType('maintainers'),
      contributors: jsonDataType('contributors'),
      owners: jsonDataType('owners'),
      packagers: jsonDataType('packagers'),
      distributors: jsonDataType('distributors'),
      vendors: jsonDataType('vendors'),
      keywords: jsonDataType('keywords'),
      keywords_doc_url: DataTypes.STRING,
      metafile_locations: jsonDataType('metafile_locations'),
      metafile_urls: jsonDataType('metafile_urls'),
      homepage_url: DataTypes.STRING,
      notes: DataTypes.STRING,
      download_urls: jsonDataType('download_urls'),
      download_sha1: DataTypes.STRING,
      download_sha256: DataTypes.STRING,
      download_md5: DataTypes.STRING,
      bug_tracking_url: DataTypes.STRING,
      support_contacts: jsonDataType('support_contacts'),
      code_view_url: DataTypes.STRING,
      vcs_tool: DataTypes.STRING,
      vcs_repository: DataTypes.STRING,
      vcs_revision: DataTypes.STRING,
      copyright_top_level: DataTypes.STRING,
      copyrights: jsonDataType('copyrights'),
      asserted_licenses: jsonDataType('asserted_licenses'),
      legal_file_locations: jsonDataType('legal_file_locations'),
      license_expression: DataTypes.STRING,
      license_texts: jsonDataType('license_texts'),
      notice_texts: jsonDataType('notice_texts'),
      dependencies: jsonDataType('dependencies'),
      related_packages: jsonDataType('related_packages')
    },
    {
      timestamps: false
    });
};
@@ -907,24 +907,59 @@
 pes.STRING,%0A
+      namespace: DataTypes.STRING,%0A
       name: 
@@ -1019,59 +1019,18 @@
     
-primary_language: DataTypes.STRING,%0A      packaging
+qualifiers
 : Da
@@ -1057,13 +1057,13 @@
   su
-mmary
+bpath
 : Da
@@ -1088,19 +1088,24 @@
     
-description
+primary_language
 : Da
@@ -1130,15 +1130,12 @@
     
-payload
+code
 _typ
@@ -1165,12 +1165,19 @@
     
-size
+description
 : Da
@@ -1188,23 +1188,22 @@
 pes.
-INTEGER
+STRING
 ,%0A      
 rele
@@ -1202,19 +1202,11 @@
     
-release_dat
+siz
 e: D
@@ -1214,30 +1214,31 @@
 taTypes.
-STRING
+INTEGER
 ,%0A      
 authors:
@@ -1233,176 +1233,38 @@
     
-authors: jsonDataType('authors'),%0A      maintainers: jsonDataType('maintainers'),%0A      contributors: jsonDataType('contributors'),%0A      owners: jsonDataType('owners')
+release_date: DataTypes.STRING
 ,%0A  
@@ -1269,22 +1269,20 @@
       pa
-ckager
+rtie
 s: jsonD
@@ -1296,104 +1296,12 @@
 ('pa
-ckagers'),%0A      distributors: jsonDataType('distributors'),%0A      vendors: jsonDataType('vendor
+rtie
 s'),
@@ -1353,20 +1353,16 @@
     
-keywords_doc
+homepage
 _url
@@ -1391,165 +1391,20 @@
     
-metafile_locations: jsonDataType('metafile_locations'),%0A      metafile_urls: jsonDataType('metafile_urls'),%0A      homepage_url: DataTypes.STRING,%0A      notes
+download_url
 : Da
@@ -1434,19 +1434,24 @@
 ownload_
-url
+checksum
 s: jsonD
@@ -1472,232 +1472,61 @@
 oad_
-urls'),%0A      download_sha1: DataTypes.STRING,%0A      download_sha256: DataTypes.STRING,%0A      download_md5: DataTypes.STRING,%0A      bug_tracking_url: DataTypes.STRING,%0A      support_contacts: jsonDataType('support_contacts')
+checksums'),%0A      bug_tracking_url: DataTypes.STRING
 ,%0A  
@@ -1693,18 +1693,8 @@
 ight
-_top_level
 : Da
@@ -1719,268 +1719,88 @@
     
-copyrights: jsonDataType('copyrights'),%0A      asserted_licenses: jsonDataType('asserted_licenses'),%0A      legal_file_locations: jsonDataType('legal_file_locations'),%0A      license_expression: DataTypes.STRING,%0A      license_texts: jsonDataType('license_texts')
+license_expression: DataTypes.STRING,%0A      declared_licensing: DataTypes.STRING
 ,%0A  
@@ -1814,31 +1814,26 @@
 ice_text
-s
 : 
-json
 DataType
 ('notice
@@ -1828,24 +1828,16 @@
 Type
-('notice_texts')
+s.STRING
 ,%0A  
@@ -1988,8 +1988,9 @@
   %7D);%0A%7D;
+%0A

Update Package model