/* Warnings: - The primary key for the `Sales_Invoice_Payments` table will be changed. If it partially fails, the table could be left without primary key constraint. - You are about to drop the column `createdAt` on the `Sales_Invoice_Payments` table. All the data in the column will be lost. - You are about to drop the column `invoiceId` on the `Sales_Invoice_Payments` table. All the data in the column will be lost. - You are about to drop the column `paidAt` on the `Sales_Invoice_Payments` table. All the data in the column will be lost. - You are about to drop the column `paymentMethod` on the `Sales_Invoice_Payments` table. All the data in the column will be lost. - You are about to drop the `Customers` table. If the table is not empty, all the data it contains will be lost. - You are about to drop the `Good_categories` table. If the table is not empty, all the data it contains will be lost. - You are about to drop the `Goods` table. If the table is not empty, all the data it contains will be lost. - You are about to drop the `Sales_Invoice_Items` table. If the table is not empty, all the data it contains will be lost. - You are about to drop the `Sales_Invoices` table. If the table is not empty, all the data it contains will be lost. - You are about to drop the `Service_categories` table. If the table is not empty, all the data it contains will be lost. - You are about to drop the `Services` table. If the table is not empty, all the data it contains will be lost. - You are about to drop the `Trigger_Logs` table. If the table is not empty, all the data it contains will be lost. - Added the required column `invoice_id` to the `Sales_Invoice_Payments` table without a default value. This is not possible if the table is not empty. - Added the required column `paid_at` to the `Sales_Invoice_Payments` table without a default value. This is not possible if the table is not empty. - Added the required column `payment_method` to the `Sales_Invoice_Payments` table without a default value. This is not possible if the table is not empty. */ -- DropForeignKey ALTER TABLE `Goods` DROP FOREIGN KEY `Goods_categoryId_fkey`; -- DropForeignKey ALTER TABLE `Sales_Invoice_Items` DROP FOREIGN KEY `Sales_Invoice_Items_goodId_fkey`; -- DropForeignKey ALTER TABLE `Sales_Invoice_Items` DROP FOREIGN KEY `Sales_Invoice_Items_invoiceId_fkey`; -- DropForeignKey ALTER TABLE `Sales_Invoice_Items` DROP FOREIGN KEY `Sales_Invoice_Items_serviceId_fkey`; -- DropForeignKey ALTER TABLE `Sales_Invoice_Payments` DROP FOREIGN KEY `Sales_Invoice_Payments_invoiceId_fkey`; -- DropForeignKey ALTER TABLE `Sales_Invoices` DROP FOREIGN KEY `Sales_Invoices_customerId_fkey`; -- DropForeignKey ALTER TABLE `Services` DROP FOREIGN KEY `Services_categoryId_fkey`; -- DropIndex DROP INDEX `Sales_Invoice_Payments_invoiceId_idx` ON `Sales_Invoice_Payments`; -- AlterTable ALTER TABLE `Sales_Invoice_Payments` DROP PRIMARY KEY, DROP COLUMN `createdAt`, DROP COLUMN `invoiceId`, DROP COLUMN `paidAt`, DROP COLUMN `paymentMethod`, ADD COLUMN `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), ADD COLUMN `invoice_id` VARCHAR(191) NOT NULL, ADD COLUMN `paid_at` DATETIME(3) NOT NULL, ADD COLUMN `payment_method` ENUM('CASH', 'CARD', 'BANK', 'CHECK', 'OTHER') NOT NULL, MODIFY `id` VARCHAR(191) NOT NULL, ADD PRIMARY KEY (`id`); -- DropTable DROP TABLE `Customers`; -- DropTable DROP TABLE `Good_categories`; -- DropTable DROP TABLE `Goods`; -- DropTable DROP TABLE `Sales_Invoice_Items`; -- DropTable DROP TABLE `Sales_Invoices`; -- DropTable DROP TABLE `Service_categories`; -- DropTable DROP TABLE `Services`; -- DropTable DROP TABLE `Trigger_Logs`; -- CreateTable CREATE TABLE `customers` ( `id` VARCHAR(191) NOT NULL, `first_name` VARCHAR(255) NOT NULL, `last_name` VARCHAR(255) NOT NULL, `email` VARCHAR(255) NULL, `mobile_number` CHAR(11) NOT NULL, `address` TEXT NULL, `is_active` BOOLEAN NOT NULL DEFAULT true, `created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0), `updated_at` TIMESTAMP(0) NOT NULL, `deleted_at` TIMESTAMP(0) NULL, UNIQUE INDEX `customers_mobile_number_key`(`mobile_number`), PRIMARY KEY (`id`) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; -- CreateTable CREATE TABLE `devices` ( `account_id` VARCHAR(255) NULL, `app_version` VARCHAR(20) NOT NULL, `build_number` VARCHAR(20) NOT NULL, `device_id` VARCHAR(255) NOT NULL, `platform` VARCHAR(100) NOT NULL, `brand` VARCHAR(100) NOT NULL, `model` VARCHAR(100) NOT NULL, `device` VARCHAR(100) NOT NULL, `os_version` VARCHAR(20) NOT NULL, `sdk_version` VARCHAR(20) NOT NULL, `release_number` VARCHAR(20) NOT NULL, `browser_name` VARCHAR(100) NULL, PRIMARY KEY (`device_id`) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; -- CreateTable CREATE TABLE `goods` ( `id` VARCHAR(191) NOT NULL, `name` VARCHAR(255) NOT NULL, `description` TEXT NULL, `sku` VARCHAR(100) NOT NULL, `local_sku` VARCHAR(100) NOT NULL, `barcode` VARCHAR(100) NULL, `created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0), `updated_at` TIMESTAMP(0) NOT NULL, `deleted_at` TIMESTAMP(0) NULL, `category_id` VARCHAR(191) NULL, `base_sale_price` DECIMAL(15, 0) NOT NULL DEFAULT 0.00, UNIQUE INDEX `goods_local_sku_key`(`local_sku`), UNIQUE INDEX `goods_barcode_key`(`barcode`), INDEX `goods_category_id_idx`(`category_id`), PRIMARY KEY (`id`) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; -- CreateTable CREATE TABLE `good_categories` ( `id` VARCHAR(191) NOT NULL, `name` VARCHAR(100) NOT NULL, `description` TEXT NULL, `image_url` VARCHAR(255) NULL, `created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0), `updated_at` TIMESTAMP(0) NOT NULL, `deleted_at` TIMESTAMP(0) NULL, PRIMARY KEY (`id`) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; -- CreateTable CREATE TABLE `trigger_logs` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `message` TEXT NOT NULL, `createdAt` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0), `name` TEXT NOT NULL, PRIMARY KEY (`id`) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; -- CreateTable CREATE TABLE `sales_invoices` ( `id` VARCHAR(191) NOT NULL, `code` VARCHAR(100) NOT NULL, `total_amount` DECIMAL(15, 2) NOT NULL, `description` TEXT NULL, `created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0), `updated_at` TIMESTAMP(0) NOT NULL, `customer_id` VARCHAR(191) NULL, UNIQUE INDEX `sales_invoices_code_key`(`code`), INDEX `sales_invoices_customer_id_idx`(`customer_id`), PRIMARY KEY (`id`) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; -- CreateTable CREATE TABLE `sales_invoice_items` ( `id` VARCHAR(191) NOT NULL, `count` DECIMAL(10, 0) NOT NULL, `unit_price` DECIMAL(15, 2) NOT NULL DEFAULT 0.00, `total_amount` DECIMAL(15, 2) NOT NULL DEFAULT 0.00, `created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0), `invoice_id` VARCHAR(191) NOT NULL, `good_id` VARCHAR(191) NOT NULL, `service_id` VARCHAR(191) NOT NULL, INDEX `sales_invoice_items_invoice_id_good_id_idx`(`invoice_id`, `good_id`), PRIMARY KEY (`id`) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; -- CreateTable CREATE TABLE `services` ( `id` VARCHAR(191) NOT NULL, `name` VARCHAR(255) NOT NULL, `description` TEXT NULL, `sku` VARCHAR(100) NOT NULL, `barcode` VARCHAR(100) NULL, `createdAt` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0), `updatedAt` TIMESTAMP(0) NOT NULL, `deletedAt` TIMESTAMP(0) NULL, `categoryId` VARCHAR(191) NULL, `baseSalePrice` DECIMAL(15, 0) NOT NULL DEFAULT 0.00, UNIQUE INDEX `services_sku_key`(`sku`), UNIQUE INDEX `services_barcode_key`(`barcode`), INDEX `services_categoryId_idx`(`categoryId`), PRIMARY KEY (`id`) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; -- CreateTable CREATE TABLE `service_categories` ( `id` VARCHAR(191) NOT NULL, `name` VARCHAR(100) NOT NULL, `description` TEXT NULL, `imageUrl` VARCHAR(255) NULL, `createdAt` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0), `updatedAt` TIMESTAMP(0) NOT NULL, `deletedAt` TIMESTAMP(0) NULL, PRIMARY KEY (`id`) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; -- CreateIndex CREATE INDEX `Sales_Invoice_Payments_invoice_id_idx` ON `Sales_Invoice_Payments`(`invoice_id`); -- AddForeignKey ALTER TABLE `goods` ADD CONSTRAINT `goods_category_id_fkey` FOREIGN KEY (`category_id`) REFERENCES `good_categories`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE `sales_invoices` ADD CONSTRAINT `sales_invoices_customer_id_fkey` FOREIGN KEY (`customer_id`) REFERENCES `customers`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE `sales_invoice_items` ADD CONSTRAINT `sales_invoice_items_invoice_id_fkey` FOREIGN KEY (`invoice_id`) REFERENCES `sales_invoices`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE `sales_invoice_items` ADD CONSTRAINT `sales_invoice_items_good_id_fkey` FOREIGN KEY (`good_id`) REFERENCES `goods`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE `sales_invoice_items` ADD CONSTRAINT `sales_invoice_items_service_id_fkey` FOREIGN KEY (`service_id`) REFERENCES `services`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE `Sales_Invoice_Payments` ADD CONSTRAINT `Sales_Invoice_Payments_invoice_id_fkey` FOREIGN KEY (`invoice_id`) REFERENCES `sales_invoices`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE `services` ADD CONSTRAINT `services_categoryId_fkey` FOREIGN KEY (`categoryId`) REFERENCES `service_categories`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;