feat: create and delete api keys

This commit is contained in:
Henry
2025-05-31 23:59:48 +01:00
parent e61dd4e27e
commit 1d00aa78b4
11 changed files with 153 additions and 24 deletions

View File

@@ -1,3 +1,4 @@
import { relations } from "drizzle-orm";
import {
bigserial,
boolean,
@@ -50,7 +51,7 @@ export const verification = pgTable("verification", {
updatedAt: timestamp("updatedAt"),
}).enableRLS();
export const apiKey = pgTable("apiKey", {
export const apiKey = pgTable("apikey", {
id: bigserial("id", { mode: "number" }).primaryKey(),
name: text("name"),
start: text("start"),
@@ -75,3 +76,10 @@ export const apiKey = pgTable("apiKey", {
permissions: text("permissions"),
metadata: text("metadata"),
}).enableRLS();
export const apiKeyRelations = relations(apiKey, ({ one }) => ({
user: one(users, {
fields: [apiKey.userId],
references: [users.id],
}),
}));