8000 fix: keep semaphore table by grutt · Pull Request #553 · hatchet-dev/hatchet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: keep semaphore table #553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions internal/repository/prisma/dbsqlc/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions internal/repository/prisma/dbsqlc/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,12 @@ CREATE TABLE "Worker" (
CONSTRAINT "Worker_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "WorkerSemaphore" (
"workerId" UUID NOT NULL,
"slots" INTEGER NOT NULL
);

-- CreateTable
CREATE TABLE "WorkerSemaphoreSlot" (
"id" UUID NOT NULL,
Expand Down Expand Up @@ -955,6 +961,9 @@ CREATE UNIQUE INDEX "UserSession_id_key" ON "UserSession"("id" ASC);
-- CreateIndex
CREATE UNIQUE INDEX "Worker_id_key" ON "Worker"("id" ASC);

-- CreateIndex
CREATE UNIQUE INDEX "WorkerSemaphore_workerId_key" ON "WorkerSemaphore"("workerId" ASC);

-- CreateIndex
CREATE UNIQUE INDEX "WorkerSemaphoreSlot_id_key" ON "WorkerSemaphoreSlot"("id" ASC);

Expand Down Expand Up @@ -1243,6 +1252,9 @@ ALTER TABLE "Worker" ADD CONSTRAINT "Worker_dispatcherId_fkey" FOREIGN KEY ("dis
-- AddForeignKey
ALTER TABLE "Worker" ADD CONSTRAINT "Worker_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "Tenant"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "WorkerSemaphore" ADD CONSTRAINT "WorkerSemaphore_workerId_fkey" FOREIGN KEY ("workerId") REFERENCES "Worker"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "WorkerSemaphoreSlot" ADD CONSTRAINT "WorkerSemaphoreSlot_stepRunId_fkey" FOREIGN KEY ("stepRunId") REFERENCES "StepRun"("id") ON DELETE CASCADE ON UPDATE CASCADE;

Expand Down
5 changes: 0 additions & 5 deletions prisma/migrations/20240531200418_v0_30_1/migration.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
- Made the column `maxRuns` on table `Worker` required. This step will fail if there are existing NULL values in that column.
*/

-- DropForeignKey
ALTER TABLE "WorkerSemaphore" DROP CONSTRAINT IF EXISTS "WorkerSemaphore_workerId_fkey";

-- Update existing workers with NULL maxRuns to have a default value
UPDATE "Worker" SET "maxRuns" = 100 WHERE "maxRuns" IS NULL;
Expand All @@ -13,9 +11,6 @@ UPDATE "Worker" SET "maxRuns" = 100 WHERE "maxRuns" IS NULL;
ALTER TABLE "Worker" ALTER COLUMN "maxRuns" SET NOT NULL,
ALTER COLUMN "maxRuns" SET DEFAULT 100;

-- DropTable
DROP TABLE IF EXISTS "WorkerSemaphore";

-- CreateTable
CREATE TABLE IF NOT EXISTS "WorkerSemaphoreSlot" (
"id" UUID NOT NULL,
Expand Down
13 changes: 13 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,19 @@ model Worker {
groupKeyRuns GetGroupKeyRun[]

slots WorkerSemaphoreSlot[]

// DEPRECATED in v_0_30_1, replaced with slots and will be removed in a future release
semaphore WorkerSemaphore? // FIXME remove this in a few releases from v_0_30_1
}

// DEPRECATED in v_0_30_1, replaced with slots and will be removed in a future release
// FIXME remove in a future release
model WorkerSemaphore {
// the parent worker
worker Worker @relation(fields: [workerId], references: [id], onDelete: Cascade, onUpdate: Cascade)
workerId String @unique @db.Uuid
// keeps track of maxRuns - runningRuns on the worker
slots Int
}

model WorkerSemaphoreSlot {
Expand Down
Loading
0