/*
  Warnings:

  - You are about to drop the column `allocation_id` on the `partner_account_quota_credit` table. All the data in the column will be lost.
  - A unique constraint covering the columns `[economic_code,consumer_id]` on the table `business_activities` will be added. If there are existing duplicate values, this will fail.
  - A unique constraint covering the columns `[credit_id]` on the table `license_account_allocation` will be added. If there are existing duplicate values, this will fail.
  - Made the column `account_id` on table `poses` required. This step will fail if there are existing NULL values in that column.

*/
-- DropForeignKey
ALTER TABLE `license_renew` DROP FOREIGN KEY `license_renew_activation_id_fkey`;

-- DropForeignKey
ALTER TABLE `partner_account_quota_credit` DROP FOREIGN KEY `partner_account_quota_credit_allocation_id_fkey`;

-- DropForeignKey
ALTER TABLE `poses` DROP FOREIGN KEY `poses_account_id_fkey`;

-- DropIndex
DROP INDEX `business_activities_economic_code_key` ON `business_activities`;

-- DropIndex
DROP INDEX `license_renew_activation_id_fkey` ON `license_renew`;

-- DropIndex
DROP INDEX `partner_account_quota_credit_allocation_id_key` ON `partner_account_quota_credit`;

-- AlterTable
ALTER TABLE `license_account_allocation` ADD COLUMN `credit_id` VARCHAR(191) NULL;

-- AlterTable
ALTER TABLE `license_renew` MODIFY `activation_id` VARCHAR(191) NULL;

-- AlterTable
ALTER TABLE `partner_account_quota_credit` DROP COLUMN `allocation_id`;

-- AlterTable
ALTER TABLE `poses` MODIFY `account_id` VARCHAR(191) NOT NULL;

-- CreateIndex
CREATE UNIQUE INDEX `business_activities_economic_code_consumer_id_key` ON `business_activities`(`economic_code`, `consumer_id`);

-- CreateIndex
CREATE UNIQUE INDEX `license_account_allocation_credit_id_key` ON `license_account_allocation`(`credit_id`);

-- AddForeignKey
ALTER TABLE `poses` ADD CONSTRAINT `poses_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `license_renew` ADD CONSTRAINT `license_renew_activation_id_fkey` FOREIGN KEY (`activation_id`) REFERENCES `licenses_activated`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `license_account_allocation` ADD CONSTRAINT `license_account_allocation_credit_id_fkey` FOREIGN KEY (`credit_id`) REFERENCES `partner_account_quota_credit`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
