/*
  Warnings:

  - The primary key for the `message` table will be changed. If it partially fails, the table could be left without primary key constraint.
  - The primary key for the `transaction` table will be changed. If it partially fails, the table could be left without primary key constraint.
  - Added the required column `message_index` to the `message` table without a default value. This is not possible if the table is not empty.

*/
-- DropForeignKey
ALTER TABLE "transaction" DROP CONSTRAINT "transaction_message_id_chat_id_fkey";

-- AlterTable
ALTER TABLE "message" DROP CONSTRAINT "message_pkey",
ADD COLUMN     "message_index" INTEGER NOT NULL,
ALTER COLUMN "message_id" SET DATA TYPE TEXT,
ADD CONSTRAINT "message_pkey" PRIMARY KEY ("chat_id", "message_id");

-- AlterTable
ALTER TABLE "transaction" DROP CONSTRAINT "transaction_pkey",
ALTER COLUMN "message_id" SET DATA TYPE TEXT,
ADD CONSTRAINT "transaction_pkey" PRIMARY KEY ("chat_id", "message_id");

-- AddForeignKey
ALTER TABLE "transaction" ADD CONSTRAINT "transaction_message_id_chat_id_fkey" FOREIGN KEY ("message_id", "chat_id") REFERENCES "message"("message_id", "chat_id") ON DELETE RESTRICT ON UPDATE CASCADE;
