/*
  Warnings:

  - You are about to drop the `connectedAircraft` table. If the table is not empty, all the data it contains will be lost.

*/
-- DropForeignKey
ALTER TABLE "connectedAircraft" DROP CONSTRAINT "connectedAircraft_stationId_fkey";

-- DropForeignKey
ALTER TABLE "connectedAircraft" DROP CONSTRAINT "connectedAircraft_userId_fkey";

-- DropTable
DROP TABLE "connectedAircraft";

-- CreateTable
CREATE TABLE "ConnectedAircraft" (
    "id" SERIAL NOT NULL,
    "userId" TEXT NOT NULL,
    "publicUser" JSONB NOT NULL,
    "lastHeartbeat" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "stationId" INTEGER NOT NULL,
    "loginTime" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "esimatedLogoutTime" TIMESTAMP(3),
    "logoutTime" TIMESTAMP(3),
    "positionLogIds" INTEGER[] DEFAULT ARRAY[]::INTEGER[],

    CONSTRAINT "ConnectedAircraft_pkey" PRIMARY KEY ("id")
);

-- AddForeignKey
ALTER TABLE "ConnectedAircraft" ADD CONSTRAINT "ConnectedAircraft_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ConnectedAircraft" ADD CONSTRAINT "ConnectedAircraft_stationId_fkey" FOREIGN KEY ("stationId") REFERENCES "Station"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
