feat: create route to store FCM token
This commit is contained in:
@@ -6,11 +6,11 @@ import {
|
||||
text,
|
||||
} from "drizzle-orm/sqlite-core";
|
||||
|
||||
export const tokenTable = sqliteTable("token", {
|
||||
export const deviceTokensTable = sqliteTable("device_tokens", {
|
||||
deviceId: text("device_id").primaryKey(),
|
||||
token: text("token").notNull(),
|
||||
token: text("token").notNull().unique(),
|
||||
username: text("username"),
|
||||
/** Used to determine if a device hasn't been used in a while. Should start to ignore tokens where the device hasn't connected in about a month */
|
||||
/** Used to determine if a device hasn't been used in a while. Should start to ignore tokens where the device hasn't connected in about a month. */
|
||||
lastConnectedAt: text("last_connected_at").default(sql`(CURRENT_TIMESTAMP)`),
|
||||
});
|
||||
|
||||
@@ -19,7 +19,7 @@ export const watchStatusTable = sqliteTable(
|
||||
{
|
||||
deviceId: text("device_id")
|
||||
.notNull()
|
||||
.references(() => tokenTable.deviceId),
|
||||
.references(() => deviceTokensTable.deviceId),
|
||||
titleId: integer("title_id").notNull(),
|
||||
},
|
||||
(table) => ({
|
||||
@@ -27,4 +27,4 @@ export const watchStatusTable = sqliteTable(
|
||||
}),
|
||||
);
|
||||
|
||||
export const tables = [watchStatusTable, tokenTable];
|
||||
export const tables = [watchStatusTable, deviceTokensTable];
|
||||
|
||||
Reference in New Issue
Block a user