supported apps domain + some refactor of data types redundancy

This commit is contained in:
user
2026-03-28 16:19:24 +02:00
parent 6639bcd799
commit 671a712b08
26 changed files with 2052 additions and 169 deletions

View File

@@ -3,4 +3,5 @@ export * from "./better.auth.schema";
export * from "./device.schema";
export * from "./general.schema";
export * from "./link.schema";
export * from "./supported-app.schema";
export * from "./task.schema";

View File

@@ -6,6 +6,7 @@ import {
timestamp,
varchar,
} from "drizzle-orm/pg-core";
import { supportedApp } from "./supported-app.schema";
import { device } from "./device.schema";
import { relations } from "drizzle-orm";
@@ -14,12 +15,14 @@ export const link = pgTable("link", {
token: text("token").notNull().unique(),
status: varchar("status", { length: 16 }).notNull().default("active"), // "active" | "inactive" | "expired" | "revoked"
appName: text("app_name").notNull(),
appPackage: text("app_package").notNull(),
linkedDeviceId: integer("linked_device_id").references(() => device.id, {
onDelete: "set null",
}),
supportedAppId: integer("supported_app_id")
.notNull()
.references(() => supportedApp.id, {
onDelete: "restrict",
}),
expiresAt: timestamp("expires_at"),
lastAccessedAt: timestamp("last_accessed_at"),
@@ -32,4 +35,8 @@ export const linkRelations = relations(link, ({ one }) => ({
fields: [link.linkedDeviceId],
references: [device.id],
}),
supportedApp: one(supportedApp, {
fields: [link.supportedAppId],
references: [supportedApp.id],
}),
}));

View File

@@ -0,0 +1,9 @@
import { pgTable, serial, text, timestamp } from "drizzle-orm/pg-core";
export const supportedApp = pgTable("supported_app", {
id: serial("id").primaryKey(),
title: text("title").notNull(),
packageName: text("package_name").notNull().unique(),
createdAt: timestamp("created_at").notNull(),
updatedAt: timestamp("updated_at").notNull(),
});