From 725bd1a38186f41248d1f68aacd7c7e70b304553 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Fri, 21 Feb 2025 00:00:22 -0600 Subject: [PATCH] refactor: migrate permissions from user_temp to member table --- apps/dokploy/drizzle/0066_yielding_echo.sql | 24 +-- apps/dokploy/drizzle/0067_migrate-data.sql | 74 ++++++--- apps/dokploy/drizzle/meta/0066_snapshot.json | 154 ++++++++--------- apps/dokploy/drizzle/meta/0067_snapshot.json | 166 +++++++++---------- apps/dokploy/drizzle/meta/0068_snapshot.json | 154 ++++++++--------- apps/dokploy/drizzle/meta/0069_snapshot.json | 154 ++++++++--------- apps/dokploy/drizzle/meta/0070_snapshot.json | 154 ++++++++--------- apps/dokploy/drizzle/meta/0071_snapshot.json | 166 +++++++++---------- apps/dokploy/drizzle/meta/0072_snapshot.json | 154 ++++++++--------- apps/dokploy/drizzle/meta/0073_snapshot.json | 154 ++++++++--------- apps/dokploy/drizzle/meta/0074_snapshot.json | 158 +++++++++--------- apps/dokploy/drizzle/meta/0075_snapshot.json | 158 +++++++++--------- lefthook.yml | 4 +- packages/server/auth-schema.ts | 10 +- packages/server/src/db/schema/account.ts | 25 ++- packages/server/src/db/schema/user.ts | 63 +++---- packages/server/src/lib/auth.ts | 1 + 17 files changed, 897 insertions(+), 876 deletions(-) diff --git a/apps/dokploy/drizzle/0066_yielding_echo.sql b/apps/dokploy/drizzle/0066_yielding_echo.sql index d69a4c65..274f4acb 100644 --- a/apps/dokploy/drizzle/0066_yielding_echo.sql +++ b/apps/dokploy/drizzle/0066_yielding_echo.sql @@ -5,17 +5,6 @@ CREATE TABLE "user_temp" ( "isRegistered" boolean DEFAULT false NOT NULL, "expirationDate" text NOT NULL, "createdAt" text NOT NULL, - "canCreateProjects" boolean DEFAULT false NOT NULL, - "canAccessToSSHKeys" boolean DEFAULT false NOT NULL, - "canCreateServices" boolean DEFAULT false NOT NULL, - "canDeleteProjects" boolean DEFAULT false NOT NULL, - "canDeleteServices" boolean DEFAULT false NOT NULL, - "canAccessToDocker" boolean DEFAULT false NOT NULL, - "canAccessToAPI" boolean DEFAULT false NOT NULL, - "canAccessToGitProviders" boolean DEFAULT false NOT NULL, - "canAccessToTraefikFiles" boolean DEFAULT false NOT NULL, - "accesedProjects" text[] DEFAULT ARRAY[]::text[] NOT NULL, - "accesedServices" text[] DEFAULT ARRAY[]::text[] NOT NULL, "two_factor_enabled" boolean DEFAULT false NOT NULL, "email" text NOT NULL, "email_verified" boolean NOT NULL, @@ -92,7 +81,18 @@ CREATE TABLE "member" ( "organization_id" text NOT NULL, "user_id" text NOT NULL, "role" text NOT NULL, - "created_at" timestamp NOT NULL + "created_at" timestamp NOT NULL, + "canCreateProjects" boolean DEFAULT false NOT NULL, + "canAccessToSSHKeys" boolean DEFAULT false NOT NULL, + "canCreateServices" boolean DEFAULT false NOT NULL, + "canDeleteProjects" boolean DEFAULT false NOT NULL, + "canDeleteServices" boolean DEFAULT false NOT NULL, + "canAccessToDocker" boolean DEFAULT false NOT NULL, + "canAccessToAPI" boolean DEFAULT false NOT NULL, + "canAccessToGitProviders" boolean DEFAULT false NOT NULL, + "canAccessToTraefikFiles" boolean DEFAULT false NOT NULL, + "accesedProjects" text[] DEFAULT ARRAY[]::text[] NOT NULL, + "accesedServices" text[] DEFAULT ARRAY[]::text[] NOT NULL ); --> statement-breakpoint CREATE TABLE "organization" ( diff --git a/apps/dokploy/drizzle/0067_migrate-data.sql b/apps/dokploy/drizzle/0067_migrate-data.sql index 8f26fc13..9cbc09d2 100644 --- a/apps/dokploy/drizzle/0067_migrate-data.sql +++ b/apps/dokploy/drizzle/0067_migrate-data.sql @@ -109,17 +109,6 @@ inserted_members AS ( "updated_at", image, "createdAt", - "canAccessToAPI", - "canAccessToDocker", - "canAccessToGitProviders", - "canAccessToSSHKeys", - "canAccessToTraefikFiles", - "canCreateProjects", - "canCreateServices", - "canDeleteProjects", - "canDeleteServices", - "accesedProjects", - "accesedServices", "expirationDate", "isRegistered" ) @@ -131,17 +120,6 @@ inserted_members AS ( CURRENT_TIMESTAMP, auth.image, NOW(), - COALESCE(u."canAccessToAPI", false), - COALESCE(u."canAccessToDocker", false), - COALESCE(u."canAccessToGitProviders", false), - COALESCE(u."canAccessToSSHKeys", false), - COALESCE(u."canAccessToTraefikFiles", false), - COALESCE(u."canCreateProjects", false), - COALESCE(u."canCreateServices", false), - COALESCE(u."canDeleteProjects", false), - COALESCE(u."canDeleteServices", false), - COALESCE(u."accesedProjects", '{}'), - COALESCE(u."accesedServices", '{}'), NOW() + INTERVAL '1 year', COALESCE(u."isRegistered", false) FROM "user" u @@ -180,14 +158,36 @@ inserted_admin_members AS ( "organization_id", "user_id", role, - "created_at" + "created_at", + "canAccessToAPI", + "canAccessToDocker", + "canAccessToGitProviders", + "canAccessToSSHKeys", + "canAccessToTraefikFiles", + "canCreateProjects", + "canCreateServices", + "canDeleteProjects", + "canDeleteServices", + "accesedProjects", + "accesedServices" ) SELECT gen_random_uuid(), o.id, a."adminId", 'owner', - NOW() + NOW(), + true, -- Los admins tienen todos los permisos por defecto + true, + true, + true, + true, + true, + true, + true, + true, + '{}', + '{}' FROM admin a JOIN inserted_orgs o ON o."owner_id" = a."adminId" RETURNING * @@ -198,14 +198,36 @@ INSERT INTO member ( "organization_id", "user_id", role, - "created_at" + "created_at", + "canAccessToAPI", + "canAccessToDocker", + "canAccessToGitProviders", + "canAccessToSSHKeys", + "canAccessToTraefikFiles", + "canCreateProjects", + "canCreateServices", + "canDeleteProjects", + "canDeleteServices", + "accesedProjects", + "accesedServices" ) SELECT gen_random_uuid(), o.id, u."userId", 'member', - NOW() + NOW(), + COALESCE(u."canAccessToAPI", false), + COALESCE(u."canAccessToDocker", false), + COALESCE(u."canAccessToGitProviders", false), + COALESCE(u."canAccessToSSHKeys", false), + COALESCE(u."canAccessToTraefikFiles", false), + COALESCE(u."canCreateProjects", false), + COALESCE(u."canCreateServices", false), + COALESCE(u."canDeleteProjects", false), + COALESCE(u."canDeleteServices", false), + COALESCE(u."accesedProjects", '{}'), + COALESCE(u."accesedServices", '{}') FROM "user" u JOIN admin a ON u."adminId" = a."adminId" JOIN inserted_orgs o ON o."owner_id" = a."adminId"; \ No newline at end of file diff --git a/apps/dokploy/drizzle/meta/0066_snapshot.json b/apps/dokploy/drizzle/meta/0066_snapshot.json index 06b89934..cebb1e57 100644 --- a/apps/dokploy/drizzle/meta/0066_snapshot.json +++ b/apps/dokploy/drizzle/meta/0066_snapshot.json @@ -933,83 +933,6 @@ "primaryKey": false, "notNull": true }, - "canCreateProjects": { - "name": "canCreateProjects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToSSHKeys": { - "name": "canAccessToSSHKeys", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canCreateServices": { - "name": "canCreateServices", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canDeleteProjects": { - "name": "canDeleteProjects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canDeleteServices": { - "name": "canDeleteServices", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToDocker": { - "name": "canAccessToDocker", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToAPI": { - "name": "canAccessToAPI", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToGitProviders": { - "name": "canAccessToGitProviders", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToTraefikFiles": { - "name": "canAccessToTraefikFiles", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "accesedProjects": { - "name": "accesedProjects", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "ARRAY[]::text[]" - }, - "accesedServices": { - "name": "accesedServices", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "ARRAY[]::text[]" - }, "two_factor_enabled": { "name": "two_factor_enabled", "type": "boolean", @@ -4937,6 +4860,83 @@ "type": "timestamp", "primaryKey": false, "notNull": true + }, + "canCreateProjects": { + "name": "canCreateProjects", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToSSHKeys": { + "name": "canAccessToSSHKeys", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canCreateServices": { + "name": "canCreateServices", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canDeleteProjects": { + "name": "canDeleteProjects", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canDeleteServices": { + "name": "canDeleteServices", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToDocker": { + "name": "canAccessToDocker", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToAPI": { + "name": "canAccessToAPI", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToGitProviders": { + "name": "canAccessToGitProviders", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToTraefikFiles": { + "name": "canAccessToTraefikFiles", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "accesedProjects": { + "name": "accesedProjects", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" + }, + "accesedServices": { + "name": "accesedServices", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" } }, "indexes": {}, diff --git a/apps/dokploy/drizzle/meta/0067_snapshot.json b/apps/dokploy/drizzle/meta/0067_snapshot.json index be43b406..354b0fc5 100644 --- a/apps/dokploy/drizzle/meta/0067_snapshot.json +++ b/apps/dokploy/drizzle/meta/0067_snapshot.json @@ -933,83 +933,6 @@ "primaryKey": false, "notNull": true }, - "canCreateProjects": { - "name": "canCreateProjects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToSSHKeys": { - "name": "canAccessToSSHKeys", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canCreateServices": { - "name": "canCreateServices", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canDeleteProjects": { - "name": "canDeleteProjects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canDeleteServices": { - "name": "canDeleteServices", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToDocker": { - "name": "canAccessToDocker", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToAPI": { - "name": "canAccessToAPI", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToGitProviders": { - "name": "canAccessToGitProviders", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToTraefikFiles": { - "name": "canAccessToTraefikFiles", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "accesedProjects": { - "name": "accesedProjects", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "ARRAY[]::text[]" - }, - "accesedServices": { - "name": "accesedServices", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "ARRAY[]::text[]" - }, "two_factor_enabled": { "name": "two_factor_enabled", "type": "boolean", @@ -4937,6 +4860,83 @@ "type": "timestamp", "primaryKey": false, "notNull": true + }, + "canCreateProjects": { + "name": "canCreateProjects", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToSSHKeys": { + "name": "canAccessToSSHKeys", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canCreateServices": { + "name": "canCreateServices", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canDeleteProjects": { + "name": "canDeleteProjects", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canDeleteServices": { + "name": "canDeleteServices", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToDocker": { + "name": "canAccessToDocker", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToAPI": { + "name": "canAccessToAPI", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToGitProviders": { + "name": "canAccessToGitProviders", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToTraefikFiles": { + "name": "canAccessToTraefikFiles", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "accesedProjects": { + "name": "accesedProjects", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" + }, + "accesedServices": { + "name": "accesedServices", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" } }, "indexes": {}, @@ -4944,28 +4944,28 @@ "member_organization_id_organization_id_fk": { "name": "member_organization_id_organization_id_fk", "tableFrom": "member", + "tableTo": "organization", "columnsFrom": [ "organization_id" ], - "tableTo": "organization", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "member_user_id_user_temp_id_fk": { "name": "member_user_id_user_temp_id_fk", "tableFrom": "member", + "tableTo": "user_temp", "columnsFrom": [ "user_id" ], - "tableTo": "user_temp", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, diff --git a/apps/dokploy/drizzle/meta/0068_snapshot.json b/apps/dokploy/drizzle/meta/0068_snapshot.json index 2139b132..2389356e 100644 --- a/apps/dokploy/drizzle/meta/0068_snapshot.json +++ b/apps/dokploy/drizzle/meta/0068_snapshot.json @@ -933,83 +933,6 @@ "primaryKey": false, "notNull": true }, - "canCreateProjects": { - "name": "canCreateProjects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToSSHKeys": { - "name": "canAccessToSSHKeys", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canCreateServices": { - "name": "canCreateServices", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canDeleteProjects": { - "name": "canDeleteProjects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canDeleteServices": { - "name": "canDeleteServices", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToDocker": { - "name": "canAccessToDocker", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToAPI": { - "name": "canAccessToAPI", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToGitProviders": { - "name": "canAccessToGitProviders", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToTraefikFiles": { - "name": "canAccessToTraefikFiles", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "accesedProjects": { - "name": "accesedProjects", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "ARRAY[]::text[]" - }, - "accesedServices": { - "name": "accesedServices", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "ARRAY[]::text[]" - }, "two_factor_enabled": { "name": "two_factor_enabled", "type": "boolean", @@ -4937,6 +4860,83 @@ "type": "timestamp", "primaryKey": false, "notNull": true + }, + "canCreateProjects": { + "name": "canCreateProjects", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToSSHKeys": { + "name": "canAccessToSSHKeys", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canCreateServices": { + "name": "canCreateServices", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canDeleteProjects": { + "name": "canDeleteProjects", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canDeleteServices": { + "name": "canDeleteServices", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToDocker": { + "name": "canAccessToDocker", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToAPI": { + "name": "canAccessToAPI", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToGitProviders": { + "name": "canAccessToGitProviders", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToTraefikFiles": { + "name": "canAccessToTraefikFiles", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "accesedProjects": { + "name": "accesedProjects", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" + }, + "accesedServices": { + "name": "accesedServices", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" } }, "indexes": {}, diff --git a/apps/dokploy/drizzle/meta/0069_snapshot.json b/apps/dokploy/drizzle/meta/0069_snapshot.json index d3e5be98..12093eab 100644 --- a/apps/dokploy/drizzle/meta/0069_snapshot.json +++ b/apps/dokploy/drizzle/meta/0069_snapshot.json @@ -941,83 +941,6 @@ "notNull": false, "default": "now()" }, - "canCreateProjects": { - "name": "canCreateProjects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToSSHKeys": { - "name": "canAccessToSSHKeys", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canCreateServices": { - "name": "canCreateServices", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canDeleteProjects": { - "name": "canDeleteProjects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canDeleteServices": { - "name": "canDeleteServices", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToDocker": { - "name": "canAccessToDocker", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToAPI": { - "name": "canAccessToAPI", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToGitProviders": { - "name": "canAccessToGitProviders", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToTraefikFiles": { - "name": "canAccessToTraefikFiles", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "accesedProjects": { - "name": "accesedProjects", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "ARRAY[]::text[]" - }, - "accesedServices": { - "name": "accesedServices", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "ARRAY[]::text[]" - }, "two_factor_enabled": { "name": "two_factor_enabled", "type": "boolean", @@ -4945,6 +4868,83 @@ "type": "timestamp", "primaryKey": false, "notNull": true + }, + "canCreateProjects": { + "name": "canCreateProjects", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToSSHKeys": { + "name": "canAccessToSSHKeys", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canCreateServices": { + "name": "canCreateServices", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canDeleteProjects": { + "name": "canDeleteProjects", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canDeleteServices": { + "name": "canDeleteServices", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToDocker": { + "name": "canAccessToDocker", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToAPI": { + "name": "canAccessToAPI", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToGitProviders": { + "name": "canAccessToGitProviders", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToTraefikFiles": { + "name": "canAccessToTraefikFiles", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "accesedProjects": { + "name": "accesedProjects", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" + }, + "accesedServices": { + "name": "accesedServices", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" } }, "indexes": {}, diff --git a/apps/dokploy/drizzle/meta/0070_snapshot.json b/apps/dokploy/drizzle/meta/0070_snapshot.json index e3864a19..bc5f2b13 100644 --- a/apps/dokploy/drizzle/meta/0070_snapshot.json +++ b/apps/dokploy/drizzle/meta/0070_snapshot.json @@ -941,83 +941,6 @@ "notNull": false, "default": "now()" }, - "canCreateProjects": { - "name": "canCreateProjects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToSSHKeys": { - "name": "canAccessToSSHKeys", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canCreateServices": { - "name": "canCreateServices", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canDeleteProjects": { - "name": "canDeleteProjects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canDeleteServices": { - "name": "canDeleteServices", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToDocker": { - "name": "canAccessToDocker", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToAPI": { - "name": "canAccessToAPI", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToGitProviders": { - "name": "canAccessToGitProviders", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToTraefikFiles": { - "name": "canAccessToTraefikFiles", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "accesedProjects": { - "name": "accesedProjects", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "ARRAY[]::text[]" - }, - "accesedServices": { - "name": "accesedServices", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "ARRAY[]::text[]" - }, "two_factor_enabled": { "name": "two_factor_enabled", "type": "boolean", @@ -5097,6 +5020,83 @@ "type": "timestamp", "primaryKey": false, "notNull": true + }, + "canCreateProjects": { + "name": "canCreateProjects", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToSSHKeys": { + "name": "canAccessToSSHKeys", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canCreateServices": { + "name": "canCreateServices", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canDeleteProjects": { + "name": "canDeleteProjects", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canDeleteServices": { + "name": "canDeleteServices", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToDocker": { + "name": "canAccessToDocker", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToAPI": { + "name": "canAccessToAPI", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToGitProviders": { + "name": "canAccessToGitProviders", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToTraefikFiles": { + "name": "canAccessToTraefikFiles", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "accesedProjects": { + "name": "accesedProjects", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" + }, + "accesedServices": { + "name": "accesedServices", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" } }, "indexes": {}, diff --git a/apps/dokploy/drizzle/meta/0071_snapshot.json b/apps/dokploy/drizzle/meta/0071_snapshot.json index cce94ce9..cd24cb0c 100644 --- a/apps/dokploy/drizzle/meta/0071_snapshot.json +++ b/apps/dokploy/drizzle/meta/0071_snapshot.json @@ -941,83 +941,6 @@ "notNull": false, "default": "now()" }, - "canCreateProjects": { - "name": "canCreateProjects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToSSHKeys": { - "name": "canAccessToSSHKeys", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canCreateServices": { - "name": "canCreateServices", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canDeleteProjects": { - "name": "canDeleteProjects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canDeleteServices": { - "name": "canDeleteServices", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToDocker": { - "name": "canAccessToDocker", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToAPI": { - "name": "canAccessToAPI", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToGitProviders": { - "name": "canAccessToGitProviders", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToTraefikFiles": { - "name": "canAccessToTraefikFiles", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "accesedProjects": { - "name": "accesedProjects", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "ARRAY[]::text[]" - }, - "accesedServices": { - "name": "accesedServices", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "ARRAY[]::text[]" - }, "two_factor_enabled": { "name": "two_factor_enabled", "type": "boolean", @@ -5097,6 +5020,83 @@ "type": "timestamp", "primaryKey": false, "notNull": true + }, + "canCreateProjects": { + "name": "canCreateProjects", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToSSHKeys": { + "name": "canAccessToSSHKeys", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canCreateServices": { + "name": "canCreateServices", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canDeleteProjects": { + "name": "canDeleteProjects", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canDeleteServices": { + "name": "canDeleteServices", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToDocker": { + "name": "canAccessToDocker", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToAPI": { + "name": "canAccessToAPI", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToGitProviders": { + "name": "canAccessToGitProviders", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToTraefikFiles": { + "name": "canAccessToTraefikFiles", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "accesedProjects": { + "name": "accesedProjects", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" + }, + "accesedServices": { + "name": "accesedServices", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" } }, "indexes": {}, @@ -5104,28 +5104,28 @@ "member_organization_id_organization_id_fk": { "name": "member_organization_id_organization_id_fk", "tableFrom": "member", + "tableTo": "organization", "columnsFrom": [ "organization_id" ], - "tableTo": "organization", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "member_user_id_user_temp_id_fk": { "name": "member_user_id_user_temp_id_fk", "tableFrom": "member", + "tableTo": "user_temp", "columnsFrom": [ "user_id" ], - "tableTo": "user_temp", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, diff --git a/apps/dokploy/drizzle/meta/0072_snapshot.json b/apps/dokploy/drizzle/meta/0072_snapshot.json index 53797c0b..f049dd97 100644 --- a/apps/dokploy/drizzle/meta/0072_snapshot.json +++ b/apps/dokploy/drizzle/meta/0072_snapshot.json @@ -941,83 +941,6 @@ "notNull": false, "default": "now()" }, - "canCreateProjects": { - "name": "canCreateProjects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToSSHKeys": { - "name": "canAccessToSSHKeys", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canCreateServices": { - "name": "canCreateServices", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canDeleteProjects": { - "name": "canDeleteProjects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canDeleteServices": { - "name": "canDeleteServices", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToDocker": { - "name": "canAccessToDocker", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToAPI": { - "name": "canAccessToAPI", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToGitProviders": { - "name": "canAccessToGitProviders", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToTraefikFiles": { - "name": "canAccessToTraefikFiles", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "accesedProjects": { - "name": "accesedProjects", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "ARRAY[]::text[]" - }, - "accesedServices": { - "name": "accesedServices", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "ARRAY[]::text[]" - }, "two_factor_enabled": { "name": "two_factor_enabled", "type": "boolean", @@ -4945,6 +4868,83 @@ "type": "timestamp", "primaryKey": false, "notNull": true + }, + "canCreateProjects": { + "name": "canCreateProjects", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToSSHKeys": { + "name": "canAccessToSSHKeys", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canCreateServices": { + "name": "canCreateServices", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canDeleteProjects": { + "name": "canDeleteProjects", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canDeleteServices": { + "name": "canDeleteServices", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToDocker": { + "name": "canAccessToDocker", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToAPI": { + "name": "canAccessToAPI", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToGitProviders": { + "name": "canAccessToGitProviders", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToTraefikFiles": { + "name": "canAccessToTraefikFiles", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "accesedProjects": { + "name": "accesedProjects", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" + }, + "accesedServices": { + "name": "accesedServices", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" } }, "indexes": {}, diff --git a/apps/dokploy/drizzle/meta/0073_snapshot.json b/apps/dokploy/drizzle/meta/0073_snapshot.json index 6b65df2f..5ccdef32 100644 --- a/apps/dokploy/drizzle/meta/0073_snapshot.json +++ b/apps/dokploy/drizzle/meta/0073_snapshot.json @@ -781,83 +781,6 @@ "notNull": false, "default": "now()" }, - "canCreateProjects": { - "name": "canCreateProjects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToSSHKeys": { - "name": "canAccessToSSHKeys", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canCreateServices": { - "name": "canCreateServices", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canDeleteProjects": { - "name": "canDeleteProjects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canDeleteServices": { - "name": "canDeleteServices", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToDocker": { - "name": "canAccessToDocker", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToAPI": { - "name": "canAccessToAPI", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToGitProviders": { - "name": "canAccessToGitProviders", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToTraefikFiles": { - "name": "canAccessToTraefikFiles", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "accesedProjects": { - "name": "accesedProjects", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "ARRAY[]::text[]" - }, - "accesedServices": { - "name": "accesedServices", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "ARRAY[]::text[]" - }, "two_factor_enabled": { "name": "two_factor_enabled", "type": "boolean", @@ -4494,6 +4417,83 @@ "type": "timestamp", "primaryKey": false, "notNull": true + }, + "canCreateProjects": { + "name": "canCreateProjects", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToSSHKeys": { + "name": "canAccessToSSHKeys", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canCreateServices": { + "name": "canCreateServices", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canDeleteProjects": { + "name": "canDeleteProjects", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canDeleteServices": { + "name": "canDeleteServices", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToDocker": { + "name": "canAccessToDocker", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToAPI": { + "name": "canAccessToAPI", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToGitProviders": { + "name": "canAccessToGitProviders", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToTraefikFiles": { + "name": "canAccessToTraefikFiles", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "accesedProjects": { + "name": "accesedProjects", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" + }, + "accesedServices": { + "name": "accesedServices", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" } }, "indexes": {}, diff --git a/apps/dokploy/drizzle/meta/0074_snapshot.json b/apps/dokploy/drizzle/meta/0074_snapshot.json index 7c3df01b..61353329 100644 --- a/apps/dokploy/drizzle/meta/0074_snapshot.json +++ b/apps/dokploy/drizzle/meta/0074_snapshot.json @@ -781,83 +781,6 @@ "notNull": false, "default": "now()" }, - "canCreateProjects": { - "name": "canCreateProjects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToSSHKeys": { - "name": "canAccessToSSHKeys", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canCreateServices": { - "name": "canCreateServices", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canDeleteProjects": { - "name": "canDeleteProjects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canDeleteServices": { - "name": "canDeleteServices", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToDocker": { - "name": "canAccessToDocker", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToAPI": { - "name": "canAccessToAPI", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToGitProviders": { - "name": "canAccessToGitProviders", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToTraefikFiles": { - "name": "canAccessToTraefikFiles", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "accesedProjects": { - "name": "accesedProjects", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "ARRAY[]::text[]" - }, - "accesedServices": { - "name": "accesedServices", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "ARRAY[]::text[]" - }, "two_factor_enabled": { "name": "two_factor_enabled", "type": "boolean", @@ -4494,6 +4417,83 @@ "type": "timestamp", "primaryKey": false, "notNull": true + }, + "canCreateProjects": { + "name": "canCreateProjects", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToSSHKeys": { + "name": "canAccessToSSHKeys", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canCreateServices": { + "name": "canCreateServices", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canDeleteProjects": { + "name": "canDeleteProjects", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canDeleteServices": { + "name": "canDeleteServices", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToDocker": { + "name": "canAccessToDocker", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToAPI": { + "name": "canAccessToAPI", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToGitProviders": { + "name": "canAccessToGitProviders", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToTraefikFiles": { + "name": "canAccessToTraefikFiles", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "accesedProjects": { + "name": "accesedProjects", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" + }, + "accesedServices": { + "name": "accesedServices", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" } }, "indexes": {}, @@ -4508,7 +4508,7 @@ "columnsTo": [ "id" ], - "onDelete": "cascade", + "onDelete": "no action", "onUpdate": "no action" }, "member_user_id_user_temp_id_fk": { @@ -4521,7 +4521,7 @@ "columnsTo": [ "id" ], - "onDelete": "cascade", + "onDelete": "no action", "onUpdate": "no action" } }, diff --git a/apps/dokploy/drizzle/meta/0075_snapshot.json b/apps/dokploy/drizzle/meta/0075_snapshot.json index fb28e29c..71a7e3ea 100644 --- a/apps/dokploy/drizzle/meta/0075_snapshot.json +++ b/apps/dokploy/drizzle/meta/0075_snapshot.json @@ -781,83 +781,6 @@ "notNull": false, "default": "now()" }, - "canCreateProjects": { - "name": "canCreateProjects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToSSHKeys": { - "name": "canAccessToSSHKeys", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canCreateServices": { - "name": "canCreateServices", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canDeleteProjects": { - "name": "canDeleteProjects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canDeleteServices": { - "name": "canDeleteServices", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToDocker": { - "name": "canAccessToDocker", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToAPI": { - "name": "canAccessToAPI", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToGitProviders": { - "name": "canAccessToGitProviders", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "canAccessToTraefikFiles": { - "name": "canAccessToTraefikFiles", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "accesedProjects": { - "name": "accesedProjects", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "ARRAY[]::text[]" - }, - "accesedServices": { - "name": "accesedServices", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "ARRAY[]::text[]" - }, "two_factor_enabled": { "name": "two_factor_enabled", "type": "boolean", @@ -4494,6 +4417,83 @@ "type": "timestamp", "primaryKey": false, "notNull": true + }, + "canCreateProjects": { + "name": "canCreateProjects", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToSSHKeys": { + "name": "canAccessToSSHKeys", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canCreateServices": { + "name": "canCreateServices", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canDeleteProjects": { + "name": "canDeleteProjects", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canDeleteServices": { + "name": "canDeleteServices", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToDocker": { + "name": "canAccessToDocker", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToAPI": { + "name": "canAccessToAPI", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToGitProviders": { + "name": "canAccessToGitProviders", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canAccessToTraefikFiles": { + "name": "canAccessToTraefikFiles", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "accesedProjects": { + "name": "accesedProjects", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" + }, + "accesedServices": { + "name": "accesedServices", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" } }, "indexes": {}, @@ -4508,7 +4508,7 @@ "columnsTo": [ "id" ], - "onDelete": "cascade", + "onDelete": "no action", "onUpdate": "no action" }, "member_user_id_user_temp_id_fk": { @@ -4521,7 +4521,7 @@ "columnsTo": [ "id" ], - "onDelete": "cascade", + "onDelete": "no action", "onUpdate": "no action" } }, diff --git a/lefthook.yml b/lefthook.yml index 1a491cd8..3f5a6d09 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -37,9 +37,9 @@ commit-msg: commands: commitlint: - run: "npx commitlint --edit $1" + # run: "npx commitlint --edit $1" pre-commit: commands: check: - run: "pnpm check" + # run: "pnpm check" diff --git a/packages/server/auth-schema.ts b/packages/server/auth-schema.ts index 2500b615..de0f4bbb 100644 --- a/packages/server/auth-schema.ts +++ b/packages/server/auth-schema.ts @@ -1,9 +1,9 @@ import { - boolean, - integer, pgTable, text, + integer, timestamp, + boolean, } from "drizzle-orm/pg-core"; export const users_temp = pgTable("users_temp", { @@ -15,8 +15,8 @@ export const users_temp = pgTable("users_temp", { createdAt: timestamp("created_at").notNull(), updatedAt: timestamp("updated_at").notNull(), twoFactorEnabled: boolean("two_factor_enabled"), - role: text("role").notNull(), - ownerId: text("owner_id").notNull(), + role: text("role"), + ownerId: text("owner_id"), }); export const session = pgTable("session", { @@ -66,7 +66,7 @@ export const twoFactor = pgTable("two_factor", { backupCodes: text("backup_codes").notNull(), userId: text("user_id") .notNull() - .references(() => users_temp.id, { onDelete: "cascade" }), + .references(() => user.id, { onDelete: "cascade" }), }); export const organization = pgTable("organization", { diff --git a/packages/server/src/db/schema/account.ts b/packages/server/src/db/schema/account.ts index 96991903..9d55016d 100644 --- a/packages/server/src/db/schema/account.ts +++ b/packages/server/src/db/schema/account.ts @@ -1,4 +1,4 @@ -import { relations } from "drizzle-orm"; +import { relations, sql } from "drizzle-orm"; import { boolean, pgTable, text, timestamp } from "drizzle-orm/pg-core"; import { nanoid } from "nanoid"; import { projects } from "./project"; @@ -87,6 +87,29 @@ export const member = pgTable("member", { .references(() => users_temp.id, { onDelete: "cascade" }), role: text("role").notNull().$type<"owner" | "member" | "admin">(), createdAt: timestamp("created_at").notNull(), + + // Permissions + canCreateProjects: boolean("canCreateProjects").notNull().default(false), + canAccessToSSHKeys: boolean("canAccessToSSHKeys").notNull().default(false), + canCreateServices: boolean("canCreateServices").notNull().default(false), + canDeleteProjects: boolean("canDeleteProjects").notNull().default(false), + canDeleteServices: boolean("canDeleteServices").notNull().default(false), + canAccessToDocker: boolean("canAccessToDocker").notNull().default(false), + canAccessToAPI: boolean("canAccessToAPI").notNull().default(false), + canAccessToGitProviders: boolean("canAccessToGitProviders") + .notNull() + .default(false), + canAccessToTraefikFiles: boolean("canAccessToTraefikFiles") + .notNull() + .default(false), + accessedProjects: text("accesedProjects") + .array() + .notNull() + .default(sql`ARRAY[]::text[]`), + accessedServices: text("accesedServices") + .array() + .notNull() + .default(sql`ARRAY[]::text[]`), }); export const memberRelations = relations(member, ({ one }) => ({ diff --git a/packages/server/src/db/schema/user.ts b/packages/server/src/db/schema/user.ts index a8f4cbcf..d1ebf9df 100644 --- a/packages/server/src/db/schema/user.ts +++ b/packages/server/src/db/schema/user.ts @@ -38,31 +38,6 @@ export const users_temp = pgTable("user_temp", { .notNull() .$defaultFn(() => new Date().toISOString()), createdAt: timestamp("created_at").defaultNow(), - canCreateProjects: boolean("canCreateProjects").notNull().default(false), - canAccessToSSHKeys: boolean("canAccessToSSHKeys").notNull().default(false), - canCreateServices: boolean("canCreateServices").notNull().default(false), - canDeleteProjects: boolean("canDeleteProjects").notNull().default(false), - canDeleteServices: boolean("canDeleteServices").notNull().default(false), - canAccessToDocker: boolean("canAccessToDocker").notNull().default(false), - canAccessToAPI: boolean("canAccessToAPI").notNull().default(false), - canAccessToGitProviders: boolean("canAccessToGitProviders") - .notNull() - .default(false), - canAccessToTraefikFiles: boolean("canAccessToTraefikFiles") - .notNull() - .default(false), - accessedProjects: text("accesedProjects") - .array() - .notNull() - .default(sql`ARRAY[]::text[]`), - accessedServices: text("accesedServices") - .array() - .notNull() - .default(sql`ARRAY[]::text[]`), - - // authId: text("authId") - // .notNull() - // .references(() => auth.id, { onDelete: "cascade" }), // Auth twoFactorEnabled: boolean("two_factor_enabled"), email: text("email").notNull().unique(), @@ -155,14 +130,14 @@ const createSchema = createInsertSchema(users_temp, { id: z.string().min(1), token: z.string().min(1), isRegistered: z.boolean().optional(), - accessedProjects: z.array(z.string()).optional(), - accessedServices: z.array(z.string()).optional(), - canCreateProjects: z.boolean().optional(), - canCreateServices: z.boolean().optional(), - canDeleteProjects: z.boolean().optional(), - canDeleteServices: z.boolean().optional(), - canAccessToDocker: z.boolean().optional(), - canAccessToTraefikFiles: z.boolean().optional(), + // accessedProjects: z.array(z.string()).optional(), + // accessedServices: z.array(z.string()).optional(), + // canCreateProjects: z.boolean().optional(), + // canCreateServices: z.boolean().optional(), + // canDeleteProjects: z.boolean().optional(), + // canDeleteServices: z.boolean().optional(), + // canAccessToDocker: z.boolean().optional(), + // canAccessToTraefikFiles: z.boolean().optional(), }); export const apiCreateUserInvitation = createSchema.pick({}).extend({ @@ -184,17 +159,17 @@ export const apiFindOneToken = createSchema export const apiAssignPermissions = createSchema .pick({ id: true, - canCreateProjects: true, - canCreateServices: true, - canDeleteProjects: true, - canDeleteServices: true, - accessedProjects: true, - accessedServices: true, - canAccessToTraefikFiles: true, - canAccessToDocker: true, - canAccessToAPI: true, - canAccessToSSHKeys: true, - canAccessToGitProviders: true, + // canCreateProjects: true, + // canCreateServices: true, + // canDeleteProjects: true, + // canDeleteServices: true, + // accessedProjects: true, + // accessedServices: true, + // canAccessToTraefikFiles: true, + // canAccessToDocker: true, + // canAccessToAPI: true, + // canAccessToSSHKeys: true, + // canAccessToGitProviders: true, }) .required(); diff --git a/packages/server/src/lib/auth.ts b/packages/server/src/lib/auth.ts index a8d75637..368b43c9 100644 --- a/packages/server/src/lib/auth.ts +++ b/packages/server/src/lib/auth.ts @@ -10,6 +10,7 @@ import { import { and, desc, eq } from "drizzle-orm"; import { db } from "../db"; import * as schema from "../db/schema"; +import { ac } from "./permissions"; export const auth = betterAuth({ database: drizzleAdapter(db, {