/*
  Warnings:

  - You are about to drop the column `tax_id` on the `complexes` table. All the data in the column will be lost.
  - A unique constraint covering the columns `[economic_code]` on the table `business_activities` will be added. If there are existing duplicate values, this will fail.
  - A unique constraint covering the columns `[mobile_number,national_code,partner_id]` on the table `consumers` will be added. If there are existing duplicate values, this will fail.
  - Added the required column `economic_code` to the `business_activities` table without a default value. This is not possible if the table is not empty.
  - Added the required column `national_code` to the `consumers` table without a default value. This is not possible if the table is not empty.
  - Added the required column `partner_id` to the `consumers` table without a default value. This is not possible if the table is not empty.

*/
-- DropIndex
DROP INDEX `consumers_mobile_number_key` ON `consumers`;

-- AlterTable
ALTER TABLE `business_activities` ADD COLUMN `economic_code` VARCHAR(191) NOT NULL;

-- AlterTable
ALTER TABLE `complexes` DROP COLUMN `tax_id`;

-- AlterTable
ALTER TABLE `consumers` ADD COLUMN `national_code` VARCHAR(191) NOT NULL,
    ADD COLUMN `partner_id` VARCHAR(191) NOT NULL;

-- AlterTable
ALTER TABLE `licenses` ADD COLUMN `accounts_limit` INTEGER NOT NULL DEFAULT 3;

-- CreateIndex
CREATE UNIQUE INDEX `business_activities_economic_code_key` ON `business_activities`(`economic_code`);

-- CreateIndex
CREATE UNIQUE INDEX `consumers_mobile_number_national_code_partner_id_key` ON `consumers`(`mobile_number`, `national_code`, `partner_id`);

-- AddForeignKey
ALTER TABLE `consumers` ADD CONSTRAINT `consumers_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
