71 lines
1.6 KiB
JavaScript
71 lines
1.6 KiB
JavaScript
"use strict";
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
await queryInterface.createTable("ConditionChecks", {
|
|
id: {
|
|
type: Sequelize.UUID,
|
|
defaultValue: Sequelize.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
rentalId: {
|
|
type: Sequelize.UUID,
|
|
allowNull: false,
|
|
references: {
|
|
model: "Rentals",
|
|
key: "id",
|
|
},
|
|
onUpdate: "CASCADE",
|
|
onDelete: "CASCADE",
|
|
},
|
|
submittedBy: {
|
|
type: Sequelize.UUID,
|
|
allowNull: false,
|
|
references: {
|
|
model: "Users",
|
|
key: "id",
|
|
},
|
|
onUpdate: "CASCADE",
|
|
onDelete: "CASCADE",
|
|
},
|
|
checkType: {
|
|
type: Sequelize.ENUM(
|
|
"pre_rental_owner",
|
|
"rental_start_renter",
|
|
"rental_end_renter",
|
|
"post_rental_owner"
|
|
),
|
|
allowNull: false,
|
|
},
|
|
photos: {
|
|
type: Sequelize.ARRAY(Sequelize.STRING),
|
|
defaultValue: [],
|
|
},
|
|
notes: {
|
|
type: Sequelize.TEXT,
|
|
},
|
|
submittedAt: {
|
|
type: Sequelize.DATE,
|
|
allowNull: false,
|
|
defaultValue: Sequelize.NOW,
|
|
},
|
|
createdAt: {
|
|
type: Sequelize.DATE,
|
|
allowNull: false,
|
|
},
|
|
updatedAt: {
|
|
type: Sequelize.DATE,
|
|
allowNull: false,
|
|
},
|
|
});
|
|
|
|
// Add indexes
|
|
await queryInterface.addIndex("ConditionChecks", ["rentalId"]);
|
|
await queryInterface.addIndex("ConditionChecks", ["submittedBy"]);
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
await queryInterface.dropTable("ConditionChecks");
|
|
},
|
|
};
|