/* Warnings: - You are about to drop the column `fiscal_switch_type` on the `partners` table. All the data in the column will be lost. - The values [CHECK] on the enum `sales_invoice_payments_payment_method` will be removed. If these variants are still used in the database, this will fail. - You are about to drop the `sale_invoice_fiscal_attempts` table. If the table is not empty, all the data it contains will be lost. - You are about to drop the `sale_invoice_fiscals` table. If the table is not empty, all the data it contains will be lost. - Made the column `good_snapshot` on table `sales_invoice_items` required. This step will fail if there are existing NULL values in that column. - Made the column `good_id` on table `sales_invoice_items` required. This step will fail if there are existing NULL values in that column. */ -- DropForeignKey ALTER TABLE `sale_invoice_fiscal_attempts` DROP FOREIGN KEY `sale_invoice_fiscal_attempts_fiscal_id_fkey`; -- DropForeignKey ALTER TABLE `sale_invoice_fiscals` DROP FOREIGN KEY `sale_invoice_fiscals_invoice_id_fkey`; -- DropForeignKey ALTER TABLE `sales_invoice_items` DROP FOREIGN KEY `sales_invoice_items_good_id_fkey`; -- DropIndex DROP INDEX `sales_invoice_items_good_id_fkey` ON `sales_invoice_items`; -- AlterTable ALTER TABLE `business_activities` ADD COLUMN `invoice_number_sequence` VARCHAR(191) NOT NULL DEFAULT '1'; -- AlterTable ALTER TABLE `partners` DROP COLUMN `fiscal_switch_type`, ADD COLUMN `tsp_provider` ENUM('NAMA', 'SUN') NOT NULL DEFAULT 'NAMA'; -- AlterTable ALTER TABLE `sales_invoice_items` MODIFY `good_snapshot` JSON NOT NULL, MODIFY `good_id` VARCHAR(191) NOT NULL; -- AlterTable ALTER TABLE `sales_invoice_payments` MODIFY `payment_method` ENUM('CHEQUE', 'SET_OFF', 'CASH', 'TERMINAL', 'PAYMENT_GATEWAY', 'CARD', 'BANK', 'OTHER') NOT NULL; -- DropTable DROP TABLE `sale_invoice_fiscal_attempts`; -- DropTable DROP TABLE `sale_invoice_fiscals`; -- CreateTable CREATE TABLE `sale_invoice_tsp_attempts` ( `id` VARCHAR(191) NOT NULL, `attempt_no` INTEGER NOT NULL, `status` ENUM('SUCCESS', 'FAILURE', 'NOT_SEND', 'QUEUED') NOT NULL, `tax_id` VARCHAR(191) NULL, `type` ENUM('MAIN', 'UPDATE', 'REVOKE', 'REMOVE') NOT NULL, `request_payload` JSON NULL, `response_payload` JSON NULL, `error_message` TEXT NULL, `sent_at` TIMESTAMP(0) NULL, `received_at` TIMESTAMP(0) NULL, `created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0), `invoice_id` VARCHAR(191) NOT NULL, UNIQUE INDEX `sale_invoice_tsp_attempts_tax_id_key`(`tax_id`), UNIQUE INDEX `sale_invoice_tsp_attempts_invoice_id_key`(`invoice_id`), INDEX `sale_invoice_tsp_attempts_status_idx`(`status`), INDEX `sale_invoice_tsp_attempts_tax_id_idx`(`tax_id`), INDEX `sale_invoice_tsp_attempts_invoice_id_idx`(`invoice_id`), UNIQUE INDEX `sale_invoice_tsp_attempts_invoice_id_attempt_no_key`(`invoice_id`, `attempt_no`), PRIMARY KEY (`id`) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; -- 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 `sale_invoice_tsp_attempts` ADD CONSTRAINT `sale_invoice_tsp_attempts_invoice_id_fkey` FOREIGN KEY (`invoice_id`) REFERENCES `sales_invoices`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;