'use strict';

/** @type {import('sequelize-cli').Migration} */
module.exports = {
	async up(queryInterface, Sequelize) {
		await queryInterface.createTable('events', {
			id: {
				type: Sequelize.UUID,
				defaultValue: Sequelize.UUIDV4,
				allowNull: false,
				primaryKey: true,
			},
			event_type: {
				type: Sequelize.ENUM('Free', 'Requires Payment'),
				allowNull: false,
				defaultValue: 'Requires Payment',
			},
			organizer: {
				type: Sequelize.STRING,
				allowNull: false,
			},
			title: {
				type: Sequelize.STRING,
				allowNull: false,
			},
			description: {
				type: Sequelize.TEXT('long'),
				allowNull: false,
			},
			location: {
				type: Sequelize.STRING,
				allowNull: false,
			},
			start_date: {
				type: Sequelize.DATEONLY,
				allowNull: false,
			},
			end_date: {
				type: Sequelize.DATEONLY,
				allowNull: false,
			},
			start_time: {
				type: Sequelize.TIME,
				allowNull: false,
			},
			end_time: {
				type: Sequelize.TIME,
				allowNull: false,
			},
			max_participants: {
				type: Sequelize.INTEGER,
				allowNull: false,
			},
			current_participants: {
				type: Sequelize.INTEGER,
				defaultValue: 0,
			},
			spots_left: {
				type: Sequelize.INTEGER,
				allowNull: false,
			},
			price: {
				type: Sequelize.DECIMAL(10, 2),
				defaultValue: 0.0,
			},
			status: {
				type: Sequelize.ENUM('Upcoming', 'Ongoing', 'Done', 'Cancelled'),
				defaultValue: 'Upcoming',
			},
			image: {
				type: Sequelize.STRING,
				allowNull: false,
			},
			longitude: {
				type: Sequelize.DECIMAL(11, 8),
				allowNull: false,
			},
			latitude: {
				type: Sequelize.DECIMAL(10, 8),
				allowNull: false,
			},
			createdAt: {
				type: Sequelize.DATE,
				allowNull: false,
				defaultValue: Sequelize.NOW,
			},
			updatedAt: {
				type: Sequelize.DATE,
				allowNull: false,
				defaultValue: Sequelize.NOW,
			},
		});
	},

	async down(queryInterface, Sequelize) {
		await queryInterface.dropTable('events');
	},
};
