const { DATEONLY } = require('sequelize');

module.exports = (sequelize, DataTypes) => {
  const { UUID, UUIDV4, STRING, DATE } = DataTypes;
  const PaymentMethods = sequelize.define(
    'PaymentMethods',
    {
      id: {
        type: UUID,
        defaultValue: UUIDV4,
        primaryKey: true,
        allowNull: false,
      },
      customer_id: {
        type: UUID,
        allowNull: true,
      },
      type: {
        type: STRING,
        allowNull: true,
      },
      card_number: {
        type: STRING,
        allowNull: true,
      },
      expiration: {
        type: DATEONLY,
        allowNull: true,
      },
      cvv: {
        type: STRING,
        allowNull: true,
      },
      name_of_card: {
        type: STRING,
        allowNull: true,
      },
      name: {
        type: STRING,
        allowNull: true,
      },
      phone: {
        type: STRING,
        allowNull: true,
      },
      email: {
        type: STRING,
        allowNull: true,
      },
    },
    {
      tableName: 'payment_methods',
      timestamps: false,
    },
  );

  return PaymentMethods;
};
