happy-server/prisma/migrations/20250812092041_add_machine_model/migration.sql
Kirill Dubovitskiy a4bc4d34e8 feat: Add machine persistence to database
• Add Machine model to Prisma schema
• Create /v1/machines endpoints for CRUD operations
• Persist machine metadata and track active status
• Update socket handlers for machine-scoped connections
• Convert ephemeral machine status to database persistence

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-12 03:30:23 -07:00

24 lines
829 B
SQL

-- CreateTable
CREATE TABLE "Machine" (
"id" TEXT NOT NULL,
"accountId" TEXT NOT NULL,
"metadata" TEXT NOT NULL,
"metadataVersion" INTEGER NOT NULL DEFAULT 0,
"seq" INTEGER NOT NULL DEFAULT 0,
"active" BOOLEAN NOT NULL DEFAULT true,
"lastActiveAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "Machine_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "Machine_accountId_idx" ON "Machine"("accountId");
-- CreateIndex
CREATE UNIQUE INDEX "Machine_accountId_id_key" ON "Machine"("accountId", "id");
-- AddForeignKey
ALTER TABLE "Machine" ADD CONSTRAINT "Machine_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "Account"("id") ON DELETE RESTRICT ON UPDATE CASCADE;