medusa-plugin-reviews-and-ratings
Version:
Medusa plugin to add product reviews and ratings functionality in the project.
40 lines (39 loc) • 1.8 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CreateProductReview1701772415870 = void 0;
class CreateProductReview1701772415870 {
async up(queryRunner) {
await queryRunner.query(`
CREATE TABLE IF NOT EXISTS product_review (
id VARCHAR(36) NOT NULL PRIMARY KEY,
product_id VARCHAR(36) NOT NULL,
customer_id VARCHAR(36) NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT,
rating FLOAT NOT NULL,
deleted_at TIMESTAMP,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT FK_ProductReview_Product FOREIGN KEY (product_id) REFERENCES product(id),
CONSTRAINT FK_ProductReview_Customer FOREIGN KEY (customer_id) REFERENCES customer(id)
)
`);
await queryRunner.query(`
CREATE TABLE IF NOT EXISTS product_review_images (
product_review_id VARCHAR(36) NOT NULL,
image_id VARCHAR(36) NOT NULL,
CONSTRAINT FK_ProductReviewImages_ProductReview FOREIGN KEY (product_review_id) REFERENCES product_review(id) ON DELETE CASCADE,
CONSTRAINT FK_ProductReviewImages_Image FOREIGN KEY (image_id) REFERENCES image(id) ON DELETE CASCADE
)
`);
}
async down(queryRunner) {
await queryRunner.query(`
DROP TABLE IF EXISTS product_review_images
`);
await queryRunner.query(`
DROP TABLE IF EXISTS product_review
`);
}
}
exports.CreateProductReview1701772415870 = CreateProductReview1701772415870;