mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: migration
This commit is contained in:
parent
c04bf3c7e0
commit
fafc238e70
@ -90,7 +90,8 @@ UPDATE "user" SET token = '' WHERE token IS NULL;
|
||||
UPDATE "user" SET "expirationDate" = CURRENT_TIMESTAMP + INTERVAL '1 year' WHERE "expirationDate" IS NULL;
|
||||
UPDATE "user" SET "createdAt" = to_char(CURRENT_TIMESTAMP, 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"') WHERE "createdAt" IS NULL;
|
||||
UPDATE "user" SET "name" = '' WHERE "name" IS NULL;
|
||||
UPDATE "user" SET "email" = COALESCE("email", '') WHERE true;
|
||||
-- Generar emails únicos para registros vacíos
|
||||
UPDATE "user" SET "email" = CONCAT('user_', id, '@dokploy.local') WHERE "email" = '' OR "email" IS NULL;
|
||||
UPDATE "user" SET "email_verified" = COALESCE("email_verified", false) WHERE true;
|
||||
UPDATE "user" SET "role" = COALESCE("role", 'user') WHERE true;
|
||||
UPDATE "user" SET "banned" = COALESCE("banned", false) WHERE true;
|
||||
@ -128,6 +129,28 @@ SELECT
|
||||
CAST("createdAt" AS timestamp) as updated_at
|
||||
FROM "auth";
|
||||
|
||||
-- Migrar datos de auth a account
|
||||
INSERT INTO "account" (
|
||||
id,
|
||||
account_id,
|
||||
provider_id,
|
||||
user_id,
|
||||
password,
|
||||
"is2FAEnabled",
|
||||
created_at,
|
||||
updated_at
|
||||
)
|
||||
SELECT
|
||||
id as id,
|
||||
id as account_id,
|
||||
'credentials' as provider_id,
|
||||
id as user_id,
|
||||
password,
|
||||
"is2FAEnabled",
|
||||
CAST("createdAt" AS timestamp) as created_at,
|
||||
CAST("createdAt" AS timestamp) as updated_at
|
||||
FROM "auth";
|
||||
|
||||
-- Migrar datos de admin a user
|
||||
UPDATE "user" u
|
||||
SET
|
||||
|
@ -35,7 +35,7 @@
|
||||
"test": "vitest --config __test__/vitest.config.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"better-auth":"1.1.16",
|
||||
"better-auth": "1.1.16",
|
||||
"bl": "6.0.11",
|
||||
"rotating-file-stream": "3.2.3",
|
||||
"qrcode": "^1.5.3",
|
||||
|
@ -13,6 +13,7 @@ import {
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { authClient } from "@/lib/auth";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { api } from "@/utils/api";
|
||||
import { IS_CLOUD, isAdminPresent, validateRequest } from "@dokploy/server";
|
||||
@ -65,8 +66,8 @@ export default function Home({ IS_CLOUD }: Props) {
|
||||
const router = useRouter();
|
||||
const form = useForm<Login>({
|
||||
defaultValues: {
|
||||
email: "",
|
||||
password: "",
|
||||
email: "siumauricio@hotmail.com",
|
||||
password: "Password1234",
|
||||
},
|
||||
resolver: zodResolver(loginSchema),
|
||||
});
|
||||
@ -76,25 +77,31 @@ export default function Home({ IS_CLOUD }: Props) {
|
||||
}, [form, form.reset, form.formState.isSubmitSuccessful]);
|
||||
|
||||
const onSubmit = async (values: Login) => {
|
||||
await mutateAsync({
|
||||
email: values.email.toLowerCase(),
|
||||
const { data, error } = await authClient.signIn.email({
|
||||
email: values.email,
|
||||
password: values.password,
|
||||
})
|
||||
.then((data) => {
|
||||
if (data.is2FAEnabled) {
|
||||
setTemp(data);
|
||||
} else {
|
||||
toast.success("Successfully signed in", {
|
||||
duration: 2000,
|
||||
});
|
||||
router.push("/dashboard/projects");
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
toast.error("Signin failed", {
|
||||
duration: 2000,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
console.log(data, error);
|
||||
// await mutateAsync({
|
||||
// email: values.email.toLowerCase(),
|
||||
// password: values.password,
|
||||
// })
|
||||
// .then((data) => {
|
||||
// if (data.is2FAEnabled) {
|
||||
// setTemp(data);
|
||||
// } else {
|
||||
// toast.success("Successfully signed in", {
|
||||
// duration: 2000,
|
||||
// });
|
||||
// router.push("/dashboard/projects");
|
||||
// }
|
||||
// })
|
||||
// .catch(() => {
|
||||
// toast.error("Signin failed", {
|
||||
// duration: 2000,
|
||||
// });
|
||||
// });
|
||||
};
|
||||
return (
|
||||
<>
|
||||
|
@ -17,6 +17,7 @@ import {
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { authClient } from "@/lib/auth";
|
||||
import { api } from "@/utils/api";
|
||||
import { IS_CLOUD, isAdminPresent, validateRequest } from "@dokploy/server";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
@ -79,9 +80,9 @@ const Register = ({ isCloud }: Props) => {
|
||||
|
||||
const form = useForm<Register>({
|
||||
defaultValues: {
|
||||
email: "",
|
||||
password: "",
|
||||
confirmPassword: "",
|
||||
email: "user5@yopmail.com",
|
||||
password: "Password1234",
|
||||
confirmPassword: "Password1234",
|
||||
},
|
||||
resolver: zodResolver(registerSchema),
|
||||
});
|
||||
@ -91,19 +92,24 @@ const Register = ({ isCloud }: Props) => {
|
||||
}, [form, form.reset, form.formState.isSubmitSuccessful]);
|
||||
|
||||
const onSubmit = async (values: Register) => {
|
||||
await mutateAsync({
|
||||
email: values.email.toLowerCase(),
|
||||
const { data, error } = await authClient.signUp.email({
|
||||
email: values.email,
|
||||
password: values.password,
|
||||
})
|
||||
.then(() => {
|
||||
toast.success("User registered successfuly", {
|
||||
duration: 2000,
|
||||
});
|
||||
if (!isCloud) {
|
||||
router.push("/");
|
||||
}
|
||||
})
|
||||
.catch((e) => e);
|
||||
name: "Mauricio Siu",
|
||||
});
|
||||
// await mutateAsync({
|
||||
// email: values.email.toLowerCase(),
|
||||
// password: values.password,
|
||||
// })
|
||||
// .then(() => {
|
||||
// toast.success("User registered successfuly", {
|
||||
// duration: 2000,
|
||||
// });
|
||||
// if (!isCloud) {
|
||||
// router.push("/");
|
||||
// }
|
||||
// })
|
||||
// .catch((e) => e);
|
||||
};
|
||||
return (
|
||||
<div className="">
|
||||
|
@ -6,7 +6,7 @@ import {
|
||||
apiRemoveUser,
|
||||
apiUpdateAdmin,
|
||||
apiUpdateWebServerMonitoring,
|
||||
users,
|
||||
user,
|
||||
} from "@/server/db/schema";
|
||||
import {
|
||||
IS_CLOUD,
|
||||
|
@ -1,9 +1,9 @@
|
||||
import {
|
||||
boolean,
|
||||
integer,
|
||||
pgTable,
|
||||
text,
|
||||
integer,
|
||||
timestamp,
|
||||
boolean,
|
||||
} from "drizzle-orm/pg-core";
|
||||
|
||||
export const user = pgTable("user", {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { boolean, pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
||||
import { users } from "./user";
|
||||
import { user } from "./user";
|
||||
|
||||
export const account = pgTable("account", {
|
||||
id: text("id").primaryKey(),
|
||||
@ -7,7 +7,7 @@ export const account = pgTable("account", {
|
||||
providerId: text("provider_id").notNull(),
|
||||
userId: text("user_id")
|
||||
.notNull()
|
||||
.references(() => users.id),
|
||||
.references(() => user.id),
|
||||
accessToken: text("access_token"),
|
||||
refreshToken: text("refresh_token"),
|
||||
idToken: text("id_token"),
|
||||
|
@ -5,7 +5,7 @@ import { createInsertSchema } from "drizzle-zod";
|
||||
import { nanoid } from "nanoid";
|
||||
import { z } from "zod";
|
||||
// import { admins } from "./admin";
|
||||
import { users } from "./user";
|
||||
import { user } from "./user";
|
||||
|
||||
const randomImages = [
|
||||
"/avatars/avatar-1.png",
|
||||
@ -56,7 +56,7 @@ export const auth = pgTable("auth", {
|
||||
|
||||
export const authRelations = relations(auth, ({ many }) => ({
|
||||
// admins: many(admins),
|
||||
users: many(users),
|
||||
users: many(user),
|
||||
}));
|
||||
const createSchema = createInsertSchema(auth, {
|
||||
email: z.string().email(),
|
||||
|
@ -4,8 +4,8 @@ import { createInsertSchema } from "drizzle-zod";
|
||||
import { nanoid } from "nanoid";
|
||||
import { z } from "zod";
|
||||
import { server } from "./server";
|
||||
import { user } from "./user";
|
||||
import { generateAppName } from "./utils";
|
||||
import { users } from "./user";
|
||||
|
||||
export const certificates = pgTable("certificate", {
|
||||
certificateId: text("certificateId")
|
||||
@ -20,7 +20,7 @@ export const certificates = pgTable("certificate", {
|
||||
.$defaultFn(() => generateAppName("certificate"))
|
||||
.unique(),
|
||||
autoRenew: boolean("autoRenew"),
|
||||
userId: text("userId").references(() => users.id, {
|
||||
userId: text("userId").references(() => user.id, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
serverId: text("serverId").references(() => server.serverId, {
|
||||
@ -35,9 +35,9 @@ export const certificatesRelations = relations(
|
||||
fields: [certificates.serverId],
|
||||
references: [server.serverId],
|
||||
}),
|
||||
user: one(users, {
|
||||
user: one(user, {
|
||||
fields: [certificates.userId],
|
||||
references: [users.id],
|
||||
references: [user.id],
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
@ -5,7 +5,7 @@ import { nanoid } from "nanoid";
|
||||
import { z } from "zod";
|
||||
import { admins } from "./admin";
|
||||
import { backups } from "./backups";
|
||||
import { users } from "./user";
|
||||
import { user } from "./user";
|
||||
|
||||
export const destinations = pgTable("destination", {
|
||||
destinationId: text("destinationId")
|
||||
@ -22,16 +22,16 @@ export const destinations = pgTable("destination", {
|
||||
endpoint: text("endpoint").notNull(),
|
||||
userId: text("userId")
|
||||
.notNull()
|
||||
.references(() => users.id, { onDelete: "cascade" }),
|
||||
.references(() => user.id, { onDelete: "cascade" }),
|
||||
});
|
||||
|
||||
export const destinationsRelations = relations(
|
||||
destinations,
|
||||
({ many, one }) => ({
|
||||
backups: many(backups),
|
||||
user: one(users, {
|
||||
user: one(user, {
|
||||
fields: [destinations.userId],
|
||||
references: [users.id],
|
||||
references: [user.id],
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
@ -7,7 +7,7 @@ import { admins } from "./admin";
|
||||
import { bitbucket } from "./bitbucket";
|
||||
import { github } from "./github";
|
||||
import { gitlab } from "./gitlab";
|
||||
import { users } from "./user";
|
||||
import { user } from "./user";
|
||||
|
||||
export const gitProviderType = pgEnum("gitProviderType", [
|
||||
"github",
|
||||
@ -25,7 +25,7 @@ export const gitProvider = pgTable("git_provider", {
|
||||
createdAt: text("createdAt")
|
||||
.notNull()
|
||||
.$defaultFn(() => new Date().toISOString()),
|
||||
userId: text("userId").references(() => users.id, {
|
||||
userId: text("userId").references(() => user.id, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
});
|
||||
@ -43,9 +43,9 @@ export const gitProviderRelations = relations(gitProvider, ({ one, many }) => ({
|
||||
fields: [gitProvider.gitProviderId],
|
||||
references: [bitbucket.gitProviderId],
|
||||
}),
|
||||
user: one(users, {
|
||||
user: one(user, {
|
||||
fields: [gitProvider.userId],
|
||||
references: [users.id],
|
||||
references: [user.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
|
@ -4,7 +4,7 @@ import { createInsertSchema } from "drizzle-zod";
|
||||
import { nanoid } from "nanoid";
|
||||
import { z } from "zod";
|
||||
import { admins } from "./admin";
|
||||
import { users } from "./user";
|
||||
import { user } from "./user";
|
||||
|
||||
export const notificationType = pgEnum("notificationType", [
|
||||
"slack",
|
||||
@ -45,7 +45,7 @@ export const notifications = pgTable("notification", {
|
||||
gotifyId: text("gotifyId").references(() => gotify.gotifyId, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
userId: text("userId").references(() => users.id, {
|
||||
userId: text("userId").references(() => user.id, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
});
|
||||
@ -122,9 +122,9 @@ export const notificationsRelations = relations(notifications, ({ one }) => ({
|
||||
fields: [notifications.gotifyId],
|
||||
references: [gotify.gotifyId],
|
||||
}),
|
||||
user: one(users, {
|
||||
user: one(user, {
|
||||
fields: [notifications.userId],
|
||||
references: [users.id],
|
||||
references: [user.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
|
@ -12,7 +12,7 @@ import { mongo } from "./mongo";
|
||||
import { mysql } from "./mysql";
|
||||
import { postgres } from "./postgres";
|
||||
import { redis } from "./redis";
|
||||
import { users } from "./user";
|
||||
import { user } from "./user";
|
||||
|
||||
export const projects = pgTable("project", {
|
||||
projectId: text("projectId")
|
||||
@ -26,7 +26,7 @@ export const projects = pgTable("project", {
|
||||
.$defaultFn(() => new Date().toISOString()),
|
||||
userId: text("userId")
|
||||
.notNull()
|
||||
.references(() => users.id, { onDelete: "cascade" }),
|
||||
.references(() => user.id, { onDelete: "cascade" }),
|
||||
env: text("env").notNull().default(""),
|
||||
});
|
||||
|
||||
@ -38,9 +38,9 @@ export const projectRelations = relations(projects, ({ many, one }) => ({
|
||||
mongo: many(mongo),
|
||||
redis: many(redis),
|
||||
compose: many(compose),
|
||||
user: one(users, {
|
||||
user: one(user, {
|
||||
fields: [projects.userId],
|
||||
references: [users.id],
|
||||
references: [user.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
|
@ -5,7 +5,7 @@ import { nanoid } from "nanoid";
|
||||
import { z } from "zod";
|
||||
import { admins } from "./admin";
|
||||
import { applications } from "./application";
|
||||
import { users } from "./user";
|
||||
import { user } from "./user";
|
||||
/**
|
||||
* This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same
|
||||
* database instance for multiple projects.
|
||||
@ -30,13 +30,13 @@ export const registry = pgTable("registry", {
|
||||
registryType: registryType("selfHosted").notNull().default("cloud"),
|
||||
userId: text("userId")
|
||||
.notNull()
|
||||
.references(() => users.id, { onDelete: "cascade" }),
|
||||
.references(() => user.id, { onDelete: "cascade" }),
|
||||
});
|
||||
|
||||
export const registryRelations = relations(registry, ({ one, many }) => ({
|
||||
user: one(users, {
|
||||
user: one(user, {
|
||||
fields: [registry.userId],
|
||||
references: [users.id],
|
||||
references: [user.id],
|
||||
}),
|
||||
applications: many(applications),
|
||||
}));
|
||||
|
@ -22,8 +22,8 @@ import { mysql } from "./mysql";
|
||||
import { postgres } from "./postgres";
|
||||
import { redis } from "./redis";
|
||||
import { sshKeys } from "./ssh-key";
|
||||
import { user } from "./user";
|
||||
import { generateAppName } from "./utils";
|
||||
import { users } from "./user";
|
||||
|
||||
export const serverStatus = pgEnum("serverStatus", ["active", "inactive"]);
|
||||
|
||||
@ -46,7 +46,7 @@ export const server = pgTable("server", {
|
||||
.$defaultFn(() => new Date().toISOString()),
|
||||
userId: text("userId")
|
||||
.notNull()
|
||||
.references(() => users.id, { onDelete: "cascade" }),
|
||||
.references(() => user.id, { onDelete: "cascade" }),
|
||||
serverStatus: serverStatus("serverStatus").notNull().default("active"),
|
||||
command: text("command").notNull().default(""),
|
||||
sshKeyId: text("sshKeyId").references(() => sshKeys.sshKeyId, {
|
||||
@ -101,9 +101,9 @@ export const server = pgTable("server", {
|
||||
});
|
||||
|
||||
export const serverRelations = relations(server, ({ one, many }) => ({
|
||||
user: one(users, {
|
||||
user: one(user, {
|
||||
fields: [server.userId],
|
||||
references: [users.id],
|
||||
references: [user.id],
|
||||
}),
|
||||
deployments: many(deployments),
|
||||
sshKey: one(sshKeys, {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
||||
import { users } from "./user";
|
||||
import { user } from "./user";
|
||||
|
||||
// OLD TABLE
|
||||
export const sessionTable = pgTable("session", {
|
||||
@ -12,6 +12,6 @@ export const sessionTable = pgTable("session", {
|
||||
userAgent: text("user_agent"),
|
||||
userId: text("user_id")
|
||||
.notNull()
|
||||
.references(() => users.id),
|
||||
.references(() => user.id),
|
||||
impersonatedBy: text("impersonated_by"),
|
||||
});
|
||||
|
@ -7,7 +7,7 @@ import { admins } from "./admin";
|
||||
import { applications } from "./application";
|
||||
import { compose } from "./compose";
|
||||
import { server } from "./server";
|
||||
import { users } from "./user";
|
||||
import { user } from "./user";
|
||||
|
||||
export const sshKeys = pgTable("ssh-key", {
|
||||
sshKeyId: text("sshKeyId")
|
||||
@ -22,7 +22,7 @@ export const sshKeys = pgTable("ssh-key", {
|
||||
.notNull()
|
||||
.$defaultFn(() => new Date().toISOString()),
|
||||
lastUsedAt: text("lastUsedAt"),
|
||||
userId: text("userId").references(() => users.id, {
|
||||
userId: text("userId").references(() => user.id, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
});
|
||||
@ -31,9 +31,9 @@ export const sshKeysRelations = relations(sshKeys, ({ many, one }) => ({
|
||||
applications: many(applications),
|
||||
compose: many(compose),
|
||||
servers: many(server),
|
||||
user: one(users, {
|
||||
user: one(user, {
|
||||
fields: [sshKeys.userId],
|
||||
references: [users.id],
|
||||
references: [user.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
|
@ -14,7 +14,7 @@ import { certificateType } from "./shared";
|
||||
*/
|
||||
|
||||
// OLD TABLE
|
||||
export const users = pgTable("user", {
|
||||
export const user = pgTable("user", {
|
||||
id: text("id")
|
||||
.notNull()
|
||||
.primaryKey()
|
||||
@ -129,7 +129,7 @@ export const users = pgTable("user", {
|
||||
.default(false),
|
||||
});
|
||||
|
||||
export const usersRelations = relations(users, ({ one }) => ({
|
||||
export const usersRelations = relations(user, ({ one }) => ({
|
||||
// auth: one(auth, {
|
||||
// fields: [users.authId],
|
||||
// references: [auth.id],
|
||||
@ -140,7 +140,7 @@ export const usersRelations = relations(users, ({ one }) => ({
|
||||
// }),
|
||||
}));
|
||||
|
||||
const createSchema = createInsertSchema(users, {
|
||||
const createSchema = createInsertSchema(user, {
|
||||
id: z.string().min(1),
|
||||
// authId: z.string().min(1),
|
||||
token: z.string().min(1),
|
||||
|
@ -2,10 +2,11 @@ import { betterAuth } from "better-auth";
|
||||
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
||||
import { admin } from "better-auth/plugins";
|
||||
import { db } from "../db";
|
||||
|
||||
import * as schema from "../db/schema";
|
||||
export const auth = betterAuth({
|
||||
database: drizzleAdapter(db, {
|
||||
provider: "pg",
|
||||
schema: schema,
|
||||
}),
|
||||
emailAndPassword: {
|
||||
enabled: true,
|
||||
|
@ -4,7 +4,7 @@ import {
|
||||
admins,
|
||||
type apiCreateUserInvitation,
|
||||
auth,
|
||||
users,
|
||||
user,
|
||||
} from "@dokploy/server/db/schema";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import * as bcrypt from "bcrypt";
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
type apiCreateAdmin,
|
||||
type apiCreateUser,
|
||||
auth,
|
||||
users,
|
||||
user,
|
||||
} from "@dokploy/server/db/schema";
|
||||
import { getPublicIpWithFallback } from "@dokploy/server/wss/utils";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
|
@ -1,15 +1,15 @@
|
||||
import { db } from "@dokploy/server/db";
|
||||
import { users } from "@dokploy/server/db/schema";
|
||||
import { user } from "@dokploy/server/db/schema";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq } from "drizzle-orm";
|
||||
|
||||
export type User = typeof users.$inferSelect;
|
||||
export type User = typeof user.$inferSelect;
|
||||
|
||||
export const findUserById = async (userId: string) => {
|
||||
const user = await db.query.users.findFirst({
|
||||
where: eq(users.userId, userId),
|
||||
const userR = await db.query.user.findFirst({
|
||||
where: eq(user.userId, userId),
|
||||
});
|
||||
if (!user) {
|
||||
if (!userR) {
|
||||
throw new TRPCError({
|
||||
code: "NOT_FOUND",
|
||||
message: "User not found",
|
||||
@ -19,8 +19,8 @@ export const findUserById = async (userId: string) => {
|
||||
};
|
||||
|
||||
export const findUserByAuthId = async (authId: string) => {
|
||||
const user = await db.query.users.findFirst({
|
||||
where: eq(users.authId, authId),
|
||||
const userR = await db.query.user.findFirst({
|
||||
where: eq(user.authId, authId),
|
||||
with: {
|
||||
auth: true,
|
||||
},
|
||||
@ -35,8 +35,8 @@ export const findUserByAuthId = async (authId: string) => {
|
||||
};
|
||||
|
||||
export const findUsers = async (adminId: string) => {
|
||||
const currentUsers = await db.query.users.findMany({
|
||||
where: eq(users.adminId, adminId),
|
||||
const currentUsers = await db.query.user.findMany({
|
||||
where: eq(user.adminId, adminId),
|
||||
with: {
|
||||
auth: {
|
||||
columns: {
|
||||
@ -49,24 +49,24 @@ export const findUsers = async (adminId: string) => {
|
||||
};
|
||||
|
||||
export const addNewProject = async (authId: string, projectId: string) => {
|
||||
const user = await findUserByAuthId(authId);
|
||||
const userR = await findUserByAuthId(authId);
|
||||
|
||||
await db
|
||||
.update(users)
|
||||
.update(user)
|
||||
.set({
|
||||
accessedProjects: [...user.accessedProjects, projectId],
|
||||
accessedProjects: [...userR.accessedProjects, projectId],
|
||||
})
|
||||
.where(eq(users.authId, authId));
|
||||
.where(eq(user.authId, authId));
|
||||
};
|
||||
|
||||
export const addNewService = async (authId: string, serviceId: string) => {
|
||||
const user = await findUserByAuthId(authId);
|
||||
const userR = await findUserByAuthId(authId);
|
||||
await db
|
||||
.update(users)
|
||||
.update(user)
|
||||
.set({
|
||||
accessedServices: [...user.accessedServices, serviceId],
|
||||
accessedServices: [...userR.accessedServices, serviceId],
|
||||
})
|
||||
.where(eq(users.authId, authId));
|
||||
.where(eq(user.authId, authId));
|
||||
};
|
||||
|
||||
export const canPerformCreationService = async (
|
||||
|
Loading…
Reference in New Issue
Block a user