Files
psp_api/prisma/migrations/20260416100419_init/migration.sql
T

79 lines
3.7 KiB
SQL
Raw Normal View History

/*
Warnings:
- You are about to drop the column `consumer_id` on the `licenses` table. All the data in the column will be lost.
- You are about to drop the column `expires_at` on the `licenses` table. All the data in the column will be lost.
- You are about to drop the column `starts_at` on the `licenses` table. All the data in the column will be lost.
- You are about to drop the column `status` on the `licenses` table. All the data in the column will be lost.
- A unique constraint covering the columns `[activated_license_id]` on the table `consumers` will be added. If there are existing duplicate values, this will fail.
- Added the required column `activation_expires_at` to the `licenses` table without a default value. This is not possible if the table is not empty.
- Added the required column `charged_license_transaction_id` to the `licenses` table without a default value. This is not possible if the table is not empty.
- Made the column `partner_id` on table `licenses` required. This step will fail if there are existing NULL values in that column.
*/
-- DropForeignKey
ALTER TABLE `licenses` DROP FOREIGN KEY `licenses_consumer_id_fkey`;
-- DropForeignKey
ALTER TABLE `licenses` DROP FOREIGN KEY `licenses_partner_id_fkey`;
-- DropIndex
DROP INDEX `licenses_consumer_id_key` ON `licenses`;
-- DropIndex
DROP INDEX `licenses_partner_id_fkey` ON `licenses`;
-- AlterTable
ALTER TABLE `consumers` ADD COLUMN `activated_license_id` VARCHAR(191) NULL;
-- AlterTable
ALTER TABLE `licenses` DROP COLUMN `consumer_id`,
DROP COLUMN `expires_at`,
DROP COLUMN `starts_at`,
DROP COLUMN `status`,
ADD COLUMN `activation_expires_at` DATETIME(3) NOT NULL,
ADD COLUMN `charged_license_transaction_id` VARCHAR(191) NOT NULL,
MODIFY `partner_id` VARCHAR(191) NOT NULL;
-- CreateTable
CREATE TABLE `activated_licenses` (
`id` VARCHAR(191) NOT NULL,
`starts_at` DATETIME(3) NOT NULL,
`expires_at` DATETIME(3) NOT NULL,
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
`updated_at` TIMESTAMP(0) NOT NULL,
`license_id` VARCHAR(191) NOT NULL,
UNIQUE INDEX `activated_licenses_id_key`(`id`),
UNIQUE INDEX `activated_licenses_license_id_key`(`license_id`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `charged_license_transactions` (
`id` VARCHAR(191) NOT NULL,
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
`updated_at` TIMESTAMP(0) NOT NULL,
`partner_id` VARCHAR(191) NOT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateIndex
CREATE UNIQUE INDEX `consumers_activated_license_id_key` ON `consumers`(`activated_license_id`);
-- AddForeignKey
ALTER TABLE `consumers` ADD CONSTRAINT `consumers_activated_license_id_fkey` FOREIGN KEY (`activated_license_id`) REFERENCES `activated_licenses`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `licenses` ADD CONSTRAINT `licenses_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `licenses` ADD CONSTRAINT `licenses_charged_license_transaction_id_fkey` FOREIGN KEY (`charged_license_transaction_id`) REFERENCES `charged_license_transactions`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `activated_licenses` ADD CONSTRAINT `activated_licenses_license_id_fkey` FOREIGN KEY (`license_id`) REFERENCES `licenses`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `charged_license_transactions` ADD CONSTRAINT `charged_license_transactions_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;