feat: create route to store FCM token

This commit is contained in:
2024-06-14 18:14:10 -04:00
parent 4d3c34579d
commit 231ed4bde4
16 changed files with 650 additions and 14 deletions

View File

@@ -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];