const config = require('../../config');
const providers = config.providers;
const crypto = require('crypto');
const bcrypt = require('bcrypt');
const moment = require('moment');

module.exports = function(sequelize, DataTypes) {
  const song_metadata = sequelize.define(
    'song_metadata',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },

isrc: {
        type: DataTypes.TEXT,
      
      

      },

upc: {
        type: DataTypes.TEXT,
      
      

      },

release_title: {
        type: DataTypes.TEXT,
      
      

      },

release_date: {
        type: DataTypes.DATE,
      
      

      },

label_name: {
        type: DataTypes.TEXT,
      
      

      },

publisher: {
        type: DataTypes.TEXT,
      
      

      },

copyright_notice: {
        type: DataTypes.TEXT,
      
      

      },

distribution_status: {
        type: DataTypes.ENUM,
      
      

        values: [

"not_set",


"ready",


"submitted",


"distributed"

        ],

      },

      importHash: {
        type: DataTypes.STRING(255),
        allowNull: true,
        unique: true,
      },
    },
    {
      timestamps: true,
      paranoid: true,
      freezeTableName: true,
    },
  );

  song_metadata.associate = (db) => {


/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity





























//end loop



    db.song_metadata.belongsTo(db.songs, {
      as: 'song',
      foreignKey: {
        name: 'songId',
      },
      constraints: false,
    });

    db.song_metadata.belongsTo(db.organizations, {
      as: 'organizations',
      foreignKey: {
        name: 'organizationsId',
      },
      constraints: false,
    });




    db.song_metadata.belongsTo(db.users, {
      as: 'createdBy',
    });

    db.song_metadata.belongsTo(db.users, {
      as: 'updatedBy',
    });
  };



  return song_metadata;
};


