/*
  Warnings:

  - Added the required column `plan_id` to the `subscriptions` table without a default value. This is not possible if the table is not empty.

*/
-- DropForeignKey
ALTER TABLE "subscriptions" DROP CONSTRAINT "subscriptions_payment_id_fkey";

-- DropForeignKey
ALTER TABLE "trading_wallets" DROP CONSTRAINT "trading_wallets_trading_account_id_fkey";

-- AlterTable
ALTER TABLE "subscriptions" ADD COLUMN     "plan_id" TEXT NOT NULL;

-- AlterTable
ALTER TABLE "trades" ALTER COLUMN "trading_system_id" DROP NOT NULL;

-- AddForeignKey
ALTER TABLE "trading_wallets" ADD CONSTRAINT "trading_wallets_trading_account_id_fkey" FOREIGN KEY ("trading_account_id") REFERENCES "trading_accounts"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "subscriptions" ADD CONSTRAINT "subscriptions_plan_id_fkey" FOREIGN KEY ("plan_id") REFERENCES "plans"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "subscriptions" ADD CONSTRAINT "subscriptions_payment_id_fkey" FOREIGN KEY ("payment_id") REFERENCES "payments"("id") ON DELETE CASCADE ON UPDATE SET NULL;
