76 lines
3.7 KiB
SQL
76 lines
3.7 KiB
SQL
|
|
/*
|
||
|
|
Warnings:
|
||
|
|
|
||
|
|
- You are about to drop the column `complex_id` on the `customer_individuals` table. All the data in the column will be lost.
|
||
|
|
- You are about to drop the column `complex_id` on the `customer_legal` table. All the data in the column will be lost.
|
||
|
|
- You are about to drop the column `unknown_customer` on the `customers` table. All the data in the column will be lost.
|
||
|
|
- You are about to drop the column `complex_id` on the `goods` table. All the data in the column will be lost.
|
||
|
|
- A unique constraint covering the columns `[business_activity_id,national_id]` on the table `customer_individuals` will be added. If there are existing duplicate values, this will fail.
|
||
|
|
- A unique constraint covering the columns `[business_activity_id,economic_code]` on the table `customer_legal` will be added. If there are existing duplicate values, this will fail.
|
||
|
|
- Added the required column `business_activity_id` to the `customer_individuals` table without a default value. This is not possible if the table is not empty.
|
||
|
|
- Added the required column `mobile_number` to the `customer_individuals` table without a default value. This is not possible if the table is not empty.
|
||
|
|
- Added the required column `business_activity_id` to the `customer_legal` table without a default value. This is not possible if the table is not empty.
|
||
|
|
|
||
|
|
*/
|
||
|
|
-- DropForeignKey
|
||
|
|
ALTER TABLE `customer_individuals` DROP FOREIGN KEY `customer_individuals_complex_id_fkey`;
|
||
|
|
|
||
|
|
-- DropForeignKey
|
||
|
|
ALTER TABLE `customer_legal` DROP FOREIGN KEY `customer_legal_complex_id_fkey`;
|
||
|
|
|
||
|
|
-- DropForeignKey
|
||
|
|
ALTER TABLE `goods` DROP FOREIGN KEY `goods_complex_id_fkey`;
|
||
|
|
|
||
|
|
-- DropIndex
|
||
|
|
DROP INDEX `customer_individuals_complex_id_idx` ON `customer_individuals`;
|
||
|
|
|
||
|
|
-- DropIndex
|
||
|
|
DROP INDEX `customer_individuals_complex_id_national_id_key` ON `customer_individuals`;
|
||
|
|
|
||
|
|
-- DropIndex
|
||
|
|
DROP INDEX `customer_legal_complex_id_idx` ON `customer_legal`;
|
||
|
|
|
||
|
|
-- DropIndex
|
||
|
|
DROP INDEX `customer_legal_complex_id_registration_number_key` ON `customer_legal`;
|
||
|
|
|
||
|
|
-- DropIndex
|
||
|
|
DROP INDEX `goods_complex_id_fkey` ON `goods`;
|
||
|
|
|
||
|
|
-- AlterTable
|
||
|
|
ALTER TABLE `customer_individuals` DROP COLUMN `complex_id`,
|
||
|
|
ADD COLUMN `business_activity_id` VARCHAR(191) NOT NULL,
|
||
|
|
ADD COLUMN `mobile_number` CHAR(15) NOT NULL;
|
||
|
|
|
||
|
|
-- AlterTable
|
||
|
|
ALTER TABLE `customer_legal` DROP COLUMN `complex_id`,
|
||
|
|
ADD COLUMN `business_activity_id` VARCHAR(191) NOT NULL,
|
||
|
|
MODIFY `registration_number` CHAR(20) NULL;
|
||
|
|
|
||
|
|
-- AlterTable
|
||
|
|
ALTER TABLE `customers` DROP COLUMN `unknown_customer`;
|
||
|
|
|
||
|
|
-- AlterTable
|
||
|
|
ALTER TABLE `goods` DROP COLUMN `complex_id`,
|
||
|
|
ADD COLUMN `business_activity_id` VARCHAR(191) NULL;
|
||
|
|
|
||
|
|
-- CreateIndex
|
||
|
|
CREATE INDEX `customer_individuals_business_activity_id_idx` ON `customer_individuals`(`business_activity_id`);
|
||
|
|
|
||
|
|
-- CreateIndex
|
||
|
|
CREATE UNIQUE INDEX `customer_individuals_business_activity_id_national_id_key` ON `customer_individuals`(`business_activity_id`, `national_id`);
|
||
|
|
|
||
|
|
-- CreateIndex
|
||
|
|
CREATE INDEX `customer_legal_business_activity_id_idx` ON `customer_legal`(`business_activity_id`);
|
||
|
|
|
||
|
|
-- CreateIndex
|
||
|
|
CREATE UNIQUE INDEX `customer_legal_business_activity_id_economic_code_key` ON `customer_legal`(`business_activity_id`, `economic_code`);
|
||
|
|
|
||
|
|
-- AddForeignKey
|
||
|
|
ALTER TABLE `customer_individuals` ADD CONSTRAINT `customer_individuals_business_activity_id_fkey` FOREIGN KEY (`business_activity_id`) REFERENCES `business_activities`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||
|
|
|
||
|
|
-- AddForeignKey
|
||
|
|
ALTER TABLE `customer_legal` ADD CONSTRAINT `customer_legal_business_activity_id_fkey` FOREIGN KEY (`business_activity_id`) REFERENCES `business_activities`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||
|
|
|
||
|
|
-- AddForeignKey
|
||
|
|
ALTER TABLE `goods` ADD CONSTRAINT `goods_business_activity_id_fkey` FOREIGN KEY (`business_activity_id`) REFERENCES `business_activities`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|