/*
  Warnings:

  - You are about to alter the column `ir` on the `invoices` table. The data in that column could be lost. The data in that column will be cast from `Decimal(10,0)` to `Decimal`.
  - You are about to alter the column `cofins` on the `invoices` table. The data in that column could be lost. The data in that column will be cast from `Decimal(10,0)` to `Decimal`.
  - You are about to alter the column `pis` on the `invoices` table. The data in that column could be lost. The data in that column will be cast from `Decimal(10,0)` to `Decimal`.
  - You are about to alter the column `csll` on the `invoices` table. The data in that column could be lost. The data in that column will be cast from `Decimal(10,0)` to `Decimal`.
  - You are about to alter the column `iss` on the `invoices` table. The data in that column could be lost. The data in that column will be cast from `Decimal(10,0)` to `Decimal`.

*/
-- DropForeignKey
ALTER TABLE `companies` DROP FOREIGN KEY `companies_accounting_company_fkey`;

-- AlterTable
ALTER TABLE `companies` ADD COLUMN `serviceTakerId` INTEGER NULL;

-- AlterTable
ALTER TABLE `invoices` MODIFY `ir` DECIMAL NOT NULL,
    MODIFY `cofins` DECIMAL NOT NULL,
    MODIFY `pis` DECIMAL NOT NULL,
    MODIFY `csll` DECIMAL NOT NULL,
    MODIFY `iss` DECIMAL NOT NULL;

-- AddForeignKey
ALTER TABLE `companies` ADD CONSTRAINT `companies_accounting_company_fkey` FOREIGN KEY (`accounting_company`) REFERENCES `providers`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `companies` ADD CONSTRAINT `companies_serviceTakerId_fkey` FOREIGN KEY (`serviceTakerId`) REFERENCES `service_takers`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
