Adjust sudo mode on the roles to full for use of ssh

This commit is contained in:
Owen
2026-08-17 17:24:16 -04:00
parent 7a61b182e0
commit aa8d339d35
2 changed files with 32 additions and 0 deletions
+18
View File
@@ -1,3 +1,4 @@
import { build } from "@server/build";
import { db } from "@server/db/pg/driver";
import { APP_PATH } from "@server/lib/consts";
import { sql } from "drizzle-orm";
@@ -201,6 +202,23 @@ export default async function migration() {
await db.execute(
sql`ALTER TABLE "roles" ALTER COLUMN "sshSudoMode" SET DEFAULT 'full';`
);
const licenseKeyCountQuery = await db.execute(
sql`SELECT COUNT(*)::int as count FROM "licenseKey";`
);
const licenseKeyCount = licenseKeyCountQuery.rows[0] as {
count: number;
};
if (
build === "oss" ||
(build === "enterprise" && licenseKeyCount.count === 0)
) {
await db.execute(
sql`UPDATE "roles" SET "sshSudoMode" = 'full' WHERE "sshSudoMode" = 'none';`
);
}
await db.execute(
sql`ALTER TABLE "targets" ALTER COLUMN "resourceId" DROP NOT NULL;`
);
+14
View File
@@ -1,3 +1,4 @@
import { build } from "@server/build";
import { APP_PATH } from "@server/lib/consts";
import Database from "better-sqlite3";
import fs from "fs";
@@ -343,6 +344,19 @@ export default async function migration() {
`ALTER TABLE 'roles' RENAME COLUMN "sshSudoModeNew" TO "sshSudoMode";`
).run();
const licenseKeyCount = db
.prepare(`SELECT COUNT(*) as count FROM 'licenseKey';`)
.get() as { count: number };
if (
build === "oss" ||
(build === "enterprise" && licenseKeyCount.count === 0)
) {
db.prepare(
`UPDATE 'roles' SET "sshSudoMode" = 'full' WHERE "sshSudoMode" = 'none';`
).run();
}
db.prepare(
`
CREATE TABLE '__new_targets' (