'use strict';

/** @type {import('sequelize-cli').Migration} */
module.exports = {
	async up(queryInterface, Sequelize) {
		await queryInterface.changeColumn('product_purchases', 'status', {
			type: Sequelize.ENUM('Unpaid', 'Successful', 'Failed'),
			allowNull: true,
			defaultValue: 'Unpaid',
		});

		await queryInterface.changeColumn('product_purchases', 'payment', {
			type: Sequelize.DECIMAL(10, 2),
			allowNull: true,
			defaultValue: 0.0,
		});
		await queryInterface.changeColumn('product_purchases', 'payment_method', {
			type: Sequelize.STRING,
			allowNull: true,
		});
		await queryInterface.changeColumn('product_purchases', 'service_fee', {
			type: Sequelize.DECIMAL(10, 2),
			allowNull: true,
			defaultValue: 0.0,
		});
		await queryInterface.changeColumn('product_purchases', 'taxes', {
			type: Sequelize.DECIMAL(10, 2),
			allowNull: true,
			defaultValue: 0.0,
		});
		await queryInterface.changeColumn('product_purchases', 'total', {
			type: Sequelize.DECIMAL(10, 2),
			allowNull: true,
			defaultValue: 0.0,
		});
		await queryInterface.addColumn('product_purchases', 'payment_status', {
			type: Sequelize.ENUM('Paid', 'Partially Paid', 'Unpaid'),
			allowNull: false,
			defaultValue: 'Unpaid',
		});
	},

	async down(queryInterface, Sequelize) {
		await queryInterface.removeColumn('product_purchases', 'payment_status');
		await queryInterface.changeColumn('product_purchases', 'status', {
			type: Sequelize.ENUM('Unpaid', 'Successful', 'Failed'),
			allowNull: false,
			defaultValue: 'Unpaid',
		});

		await queryInterface.changeColumn('product_purchases', 'payment', {
			type: Sequelize.DECIMAL(10, 2),
			allowNull: false,
			defaultValue: 0.0,
		});
		await queryInterface.changeColumn('product_purchases', 'payment_method', {
			type: Sequelize.STRING,
			allowNull: false,
		});
		await queryInterface.changeColumn('product_purchases', 'service_fee', {
			type: Sequelize.DECIMAL(10, 2),
			allowNull: false,
			defaultValue: 0.0,
		});
		await queryInterface.changeColumn('product_purchases', 'taxes', {
			type: Sequelize.DECIMAL(10, 2),
			allowNull: false,
			defaultValue: 0.0,
		});
		await queryInterface.changeColumn('product_purchases', 'total', {
			type: Sequelize.DECIMAL(10, 2),
			allowNull: false,
			defaultValue: 0.0,
		});
	},
};
