@devx-commerce/plugin-product-reviews
Version:
Product Reviews Plugin for Medusa
25 lines • 3.97 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Migration20250430123125 = void 0;
const migrations_1 = require("@mikro-orm/migrations");
class Migration20250430123125 extends migrations_1.Migration {
async up() {
this.addSql(`alter table if exists "product_review_config" drop constraint if exists "product_review_config_key_unique";`);
this.addSql(`create table if not exists "product_review_config" ("id" text not null, "key" text not null, "value" boolean not null default false, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "product_review_config_pkey" primary key ("id"));`);
this.addSql(`CREATE UNIQUE INDEX IF NOT EXISTS "IDX_product_review_config_key_unique" ON "product_review_config" (key) WHERE deleted_at IS NULL;`);
this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_product_review_config_deleted_at" ON "product_review_config" (deleted_at) WHERE deleted_at IS NULL;`);
this.addSql(`alter table if exists "product_review_response" drop constraint if exists "product_review_response_product_review_id_foreign";`);
this.addSql(`alter table if exists "review_associated_media" drop constraint if exists "review_associated_media_product_review_id_foreign";`);
this.addSql(`alter table if exists "product_review_response" add constraint "product_review_response_product_review_id_foreign" foreign key ("product_review_id") references "product_review" ("id") on update cascade on delete cascade;`);
this.addSql(`alter table if exists "review_associated_media" add constraint "review_associated_media_product_review_id_foreign" foreign key ("product_review_id") references "product_review" ("id") on update cascade on delete cascade;`);
}
async down() {
this.addSql(`drop table if exists "product_review_config" cascade;`);
this.addSql(`alter table if exists "product_review_response" drop constraint if exists "product_review_response_product_review_id_foreign";`);
this.addSql(`alter table if exists "review_associated_media" drop constraint if exists "review_associated_media_product_review_id_foreign";`);
this.addSql(`alter table if exists "product_review_response" add constraint "product_review_response_product_review_id_foreign" foreign key ("product_review_id") references "product_review" ("id") on update cascade;`);
this.addSql(`alter table if exists "review_associated_media" add constraint "review_associated_media_product_review_id_foreign" foreign key ("product_review_id") references "product_review" ("id") on update cascade;`);
}
}
exports.Migration20250430123125 = Migration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