making strides in the device and link domain setup
This commit is contained in:
25
packages/db/schema/device.schema.ts
Normal file
25
packages/db/schema/device.schema.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import {
|
||||
boolean,
|
||||
pgTable,
|
||||
serial,
|
||||
text,
|
||||
timestamp,
|
||||
varchar,
|
||||
} from "drizzle-orm/pg-core";
|
||||
|
||||
export const device = pgTable("device", {
|
||||
id: serial("id").primaryKey(),
|
||||
|
||||
title: text("title").notNull(),
|
||||
version: text("version").notNull(), // Docker image / Android version tag
|
||||
|
||||
status: varchar("status", { length: 16 }).notNull().default("offline"), // "online" | "offline" | "busy" | "error"
|
||||
isActive: boolean("is_active").notNull().default(false),
|
||||
|
||||
containerId: text("container_id"), // Docker container ID on the VPS
|
||||
host: text("host").notNull(), // VPS hostname or IP
|
||||
wsPort: text("ws_port"), // ws-scrcpy WebSocket port
|
||||
|
||||
createdAt: timestamp("created_at").notNull(),
|
||||
updatedAt: timestamp("updated_at").notNull(),
|
||||
});
|
||||
@@ -1,4 +1,6 @@
|
||||
export * from "./auth.schema";
|
||||
export * from "./better.auth.schema";
|
||||
export * from "./device.schema";
|
||||
export * from "./general.schema";
|
||||
export * from "./link.schema";
|
||||
export * from "./task.schema";
|
||||
|
||||
26
packages/db/schema/link.schema.ts
Normal file
26
packages/db/schema/link.schema.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { integer, pgTable, serial, text, timestamp, varchar } from "drizzle-orm/pg-core";
|
||||
import { device } from "./device.schema";
|
||||
import { relations } from "drizzle-orm";
|
||||
|
||||
export const link = pgTable("link", {
|
||||
id: serial("id").primaryKey(),
|
||||
|
||||
token: text("token").notNull().unique(),
|
||||
status: varchar("status", { length: 16 }).notNull().default("active"), // "active" | "inactive" | "expired" | "revoked"
|
||||
|
||||
linkedDeviceId: integer("linked_device_id").references(() => device.id, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
|
||||
expiresAt: timestamp("expires_at"),
|
||||
lastAccessedAt: timestamp("last_accessed_at"),
|
||||
createdAt: timestamp("created_at").notNull(),
|
||||
updatedAt: timestamp("updated_at").notNull(),
|
||||
});
|
||||
|
||||
export const linkRelations = relations(link, ({ one }) => ({
|
||||
device: one(device, {
|
||||
fields: [link.linkedDeviceId],
|
||||
references: [device.id],
|
||||
}),
|
||||
}));
|
||||
Reference in New Issue
Block a user