'use strict';

/** @type {import('sequelize-cli').Migration} */
module.exports = {
	async up(queryInterface, Sequelize) {
		await queryInterface.createTable('activities', {
			id: {
				type: Sequelize.UUID,
				defaultValue: Sequelize.UUIDV4,
				allowNull: false,
				primaryKey: true,
			},
			type: {
				type: Sequelize.STRING,
				allowNull: false,
			},
			title: {
				type: Sequelize.STRING,
				allowNull: false,
			},
			description: {
				type: Sequelize.TEXT('long'),
				allowNull: false,
			},
			latitude: {
				type: Sequelize.DECIMAL(10, 8),
				allowNull: true,
			},
			longitude: {
				type: Sequelize.DECIMAL(11, 8),
				allowNull: true,
			},
			location: {
				type: Sequelize.STRING,
				allowNull: true,
			},
			about: {
				type: Sequelize.JSON,
				allowNull: true,
			},
			highlights: {
				type: Sequelize.TEXT('long'),
				allowNull: true,
			},
			full_description: {
				type: Sequelize.TEXT('long'),
				allowNull: true,
			},
			includes: {
				type: Sequelize.TEXT('long'),
				allowNull: true,
			},
			not_suitable_for: {
				type: Sequelize.TEXT('long'),
				allowNull: true,
			},
			important_information: {
				type: Sequelize.TEXT('long'),
				allowNull: true,
			},
			created_at: {
				type: Sequelize.DATE,
				allowNull: false,
				defaultValue: Sequelize.NOW,
			},
		});

		await queryInterface.createTable('activity_images', {
			id: {
				type: Sequelize.UUID,
				defaultValue: Sequelize.UUIDV4,
				allowNull: false,
				primaryKey: true,
			},
			activity_id: {
				type: Sequelize.UUID,
				allowNull: false,
			},
			image: {
				type: Sequelize.STRING,
				allowNull: false,
			},
		});

		await queryInterface.createTable('activity_images', {
			id: {
				type: Sequelize.UUID,
				defaultValue: Sequelize.UUIDV4,
				allowNull: false,
				primaryKey: true,
			},
			activity_id: {
				type: Sequelize.UUID,
				allowNull: false,
			},
			image: {
				type: Sequelize.STRING,
				allowNull: false,
			},
		});

		await queryInterface.createTable('activity_likes', {
			id: {
				type: Sequelize.UUID,
				defaultValue: Sequelize.UUIDV4,
				allowNull: false,
				primaryKey: true,
			},
			activity_id: {
				type: Sequelize.UUID,
				allowNull: false,
			},
			member_id: {
				type: Sequelize.UUID,
				allowNull: false,
			},
			created_at: {
				type: Sequelize.DATE,
				allowNull: false,
				defaultValue: Sequelize.NOW,
			},
		});

		await queryInterface.createTable('activity_reviews', {
			id: {
				type: Sequelize.UUID,
				defaultValue: Sequelize.UUIDV4,
				allowNull: false,
				primaryKey: true,
			},
			activity_id: {
				type: Sequelize.UUID,
				allowNull: false,
			},
			member_id: {
				type: Sequelize.UUID,
				allowNull: false,
			},
			rating: {
				type: Sequelize.INTEGER,
				allowNull: false,
			},
			review: {
				type: Sequelize.TEXT,
				allowNull: true,
			},
			created_at: {
				type: Sequelize.DATE,
				allowNull: false,
				defaultValue: Sequelize.NOW,
			},
		});
		await queryInterface.createTable('activity_review_images', {
			id: {
				type: Sequelize.UUID,
				defaultValue: Sequelize.UUIDV4,
				allowNull: false,
				primaryKey: true,
			},
			activity_review_id: {
				type: Sequelize.UUID,
				allowNull: false,
			},
			image: {
				type: Sequelize.STRING,
				allowNull: false,
			},
		});

		await queryInterface.createTable('activity_itineraries', {
			id: {
				type: Sequelize.UUID,
				defaultValue: Sequelize.UUIDV4,
				allowNull: false,
				primaryKey: true,
			},
			activity_id: {
				type: Sequelize.UUID,
				allowNull: false,
			},
			title: {
				type: Sequelize.STRING,
				allowNull: false,
			},
			description: {
				type: Sequelize.TEXT,
				allowNull: true,
			},
			longitude: {
				type: Sequelize.DECIMAL(11, 8),
				allowNull: true,
			},
			latitude: {
				type: Sequelize.DECIMAL(10, 8),
				allowNull: true,
			},
			icon: {
				type: Sequelize.STRING,
				allowNull: true,
			},
			order: {
				type: Sequelize.INTEGER,
				allowNull: false,
			},
		});
	},

	async down(queryInterface, Sequelize) {
		await queryInterface.dropTable('activity_itineraries');
		await queryInterface.dropTable('activity_review_images');
		await queryInterface.dropTable('activity_reviews');
		await queryInterface.dropTable('activity_likes');
		await queryInterface.dropTable('activity_images');
		await queryInterface.dropTable('activities');
	},
};
