a782d61890
- Implemented CreateProductVariantDto and UpdateProductVariantDto for product variant data transfer. - Developed ProductVariantsController to handle CRUD operations for product variants. - Created ProductVariantsService to interact with the database using Prisma. - Added ProductVariantsModule to encapsulate the product variant feature. - Included response mapping for consistent API responses.
84 lines
3.8 KiB
SQL
84 lines
3.8 KiB
SQL
/*
|
|
Warnings:
|
|
|
|
- You are about to drop the column `alertQuantity` on the `Products` table. All the data in the column will be lost.
|
|
- You are about to drop the column `attachmentId` on the `Products` table. All the data in the column will be lost.
|
|
- You are about to drop the column `discount` on the `Products` table. All the data in the column will be lost.
|
|
- You are about to drop the column `imageUrl` on the `Products` table. All the data in the column will be lost.
|
|
- You are about to drop the column `isActive` on the `Products` table. All the data in the column will be lost.
|
|
- You are about to drop the column `isFeatured` on the `Products` table. All the data in the column will be lost.
|
|
- You are about to drop the column `productInfoId` on the `Products` table. All the data in the column will be lost.
|
|
- You are about to drop the column `quantity` on the `Products` table. All the data in the column will be lost.
|
|
- You are about to drop the column `unit` on the `Products` table. All the data in the column will be lost.
|
|
- You are about to drop the `Product_info` table. If the table is not empty, all the data it contains will be lost.
|
|
- Made the column `createdAt` on table `Products` required. This step will fail if there are existing NULL values in that column.
|
|
- Made the column `updatedAt` on table `Products` required. This step will fail if there are existing NULL values in that column.
|
|
|
|
*/
|
|
-- DropForeignKey
|
|
ALTER TABLE `Product_info` DROP FOREIGN KEY `Product_info_brandId_fkey`;
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE `Product_info` DROP FOREIGN KEY `Product_info_categoryId_fkey`;
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE `Product_info` DROP FOREIGN KEY `Product_info_supplierId_fkey`;
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE `Products` DROP FOREIGN KEY `Products_productInfoId_fkey`;
|
|
|
|
-- DropIndex
|
|
DROP INDEX `Products_productInfoId_fkey` ON `Products`;
|
|
|
|
-- AlterTable
|
|
ALTER TABLE `Products` DROP COLUMN `alertQuantity`,
|
|
DROP COLUMN `attachmentId`,
|
|
DROP COLUMN `discount`,
|
|
DROP COLUMN `imageUrl`,
|
|
DROP COLUMN `isActive`,
|
|
DROP COLUMN `isFeatured`,
|
|
DROP COLUMN `productInfoId`,
|
|
DROP COLUMN `quantity`,
|
|
DROP COLUMN `unit`,
|
|
ADD COLUMN `brandId` INTEGER NULL,
|
|
ADD COLUMN `categoryId` INTEGER NULL,
|
|
ADD COLUMN `metaData` JSON NULL,
|
|
ADD COLUMN `productType` VARCHAR(50) NULL DEFAULT 'simple',
|
|
MODIFY `createdAt` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
|
MODIFY `updatedAt` TIMESTAMP(0) NOT NULL;
|
|
|
|
-- DropTable
|
|
DROP TABLE `Product_info`;
|
|
|
|
-- CreateTable
|
|
CREATE TABLE `Product_Variants` (
|
|
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
|
`name` VARCHAR(255) NOT NULL,
|
|
`basePrice` DECIMAL(10, 2) NOT NULL,
|
|
`salePrice` DECIMAL(10, 2) NOT NULL,
|
|
`description` TEXT NULL,
|
|
`barcode` VARCHAR(100) NULL,
|
|
`imageUrl` VARCHAR(255) NULL,
|
|
`unit` VARCHAR(10) NULL,
|
|
`quantity` DECIMAL(10, 2) NULL DEFAULT 0.00,
|
|
`alertQuantity` DECIMAL(10, 2) NULL DEFAULT 5.00,
|
|
`isActive` BOOLEAN NOT NULL DEFAULT true,
|
|
`isFeatured` BOOLEAN NOT NULL DEFAULT false,
|
|
`createdAt` TIMESTAMP(0) NULL,
|
|
`updatedAt` TIMESTAMP(0) NULL,
|
|
`deletedAt` TIMESTAMP(0) NULL,
|
|
`productId` INTEGER NOT NULL,
|
|
|
|
UNIQUE INDEX `products_barcode_unique`(`barcode`),
|
|
PRIMARY KEY (`id`)
|
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE `Product_Variants` ADD CONSTRAINT `Product_Variants_productId_fkey` FOREIGN KEY (`productId`) REFERENCES `Products`(`id`) ON DELETE RESTRICT ON UPDATE NO ACTION;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE `Products` ADD CONSTRAINT `Products_brandId_fkey` FOREIGN KEY (`brandId`) REFERENCES `Product_brands`(`id`) ON DELETE SET NULL ON UPDATE NO ACTION;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE `Products` ADD CONSTRAINT `Products_categoryId_fkey` FOREIGN KEY (`categoryId`) REFERENCES `Product_categories`(`id`) ON DELETE SET NULL ON UPDATE NO ACTION;
|