/*
  Warnings:

  - You are about to drop the column `key_id` on the `message` table. All the data in the column will be lost.

*/
-- AlterTable
ALTER TABLE "agent" ADD COLUMN     "created_at" TIMESTAMP(3),
ADD COLUMN     "updated_at" TIMESTAMP(3);

-- AlterTable
ALTER TABLE "chat" ADD COLUMN     "key_id" TEXT;

-- AlterTable
ALTER TABLE "message" DROP COLUMN "key_id";

-- AlterTable
ALTER TABLE "plugin" ADD COLUMN     "created_at" TIMESTAMP(3),
ADD COLUMN     "updated_at" TIMESTAMP(3);

-- AlterTable
ALTER TABLE "tool" ADD COLUMN     "created_at" TIMESTAMP(3),
ADD COLUMN     "updated_at" TIMESTAMP(3);

-- CreateTable
CREATE TABLE "account" (
    "id" TEXT NOT NULL,
    "email" TEXT,
    "twitter" TEXT,
    "github" TEXT,

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

-- CreateTable
CREATE TABLE "address" (
    "address" TEXT NOT NULL,
    "chain_type" TEXT NOT NULL,
    "account_id" TEXT NOT NULL,

    CONSTRAINT "address_pkey" PRIMARY KEY ("address","chain_type")
);

-- CreateTable
CREATE TABLE "connection" (
    "id" TEXT NOT NULL,
    "address" TEXT NOT NULL,
    "chain" TEXT NOT NULL,
    "connected_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateIndex
CREATE UNIQUE INDEX "address_address_key" ON "address"("address");

-- AddForeignKey
ALTER TABLE "address" ADD CONSTRAINT "address_account_id_fkey" FOREIGN KEY ("account_id") REFERENCES "account"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
