feat: create route to store FCM token
This commit is contained in:
1
drizzle/0002_public_whistler.sql
Normal file
1
drizzle/0002_public_whistler.sql
Normal file
@@ -0,0 +1 @@
|
||||
CREATE UNIQUE INDEX `token_token_unique` ON `token` (`token`);
|
||||
20
drizzle/0003_puzzling_nightmare.sql
Normal file
20
drizzle/0003_puzzling_nightmare.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
-- Custom SQL migration file, put you code below! --
|
||||
DROP TABLE `watch_status`;
|
||||
--> statement-breakpoint
|
||||
DROP TABLE `token`;
|
||||
--> statement-breakpoint
|
||||
|
||||
CREATE TABLE `token` (
|
||||
`device_id` text NOT NULL,
|
||||
`token` text NOT NULL UNIQUE ON CONFLICT FAIL,
|
||||
`username` text,
|
||||
`last_connected_at` text DEFAULT (CURRENT_TIMESTAMP),
|
||||
PRIMARY KEY(`device_id`) ON CONFLICT REPLACE
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `watch_status` (
|
||||
`device_id` text NOT NULL,
|
||||
`title_id` integer NOT NULL,
|
||||
PRIMARY KEY(`device_id`, `title_id`),
|
||||
FOREIGN KEY (`device_id`) REFERENCES `token`(`device_id`) ON UPDATE no action ON DELETE no action
|
||||
);
|
||||
20
drizzle/0004_jittery_black_knight.sql
Normal file
20
drizzle/0004_jittery_black_knight.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
-- Custom SQL migration file, put you code below! --
|
||||
DROP TABLE `watch_status`;
|
||||
--> statement-breakpoint
|
||||
DROP TABLE `token`;
|
||||
--> statement-breakpoint
|
||||
|
||||
CREATE TABLE `device_tokens` (
|
||||
`device_id` text NOT NULL,
|
||||
`token` text NOT NULL UNIQUE ON CONFLICT FAIL,
|
||||
`username` text,
|
||||
`last_connected_at` text DEFAULT (CURRENT_TIMESTAMP),
|
||||
PRIMARY KEY(`device_id`) ON CONFLICT REPLACE
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `watch_status` (
|
||||
`device_id` text NOT NULL,
|
||||
`title_id` integer NOT NULL,
|
||||
PRIMARY KEY(`device_id`, `title_id`),
|
||||
FOREIGN KEY (`device_id`) REFERENCES `device_tokens`(`device_id`) ON UPDATE no action ON DELETE no action
|
||||
);
|
||||
99
drizzle/meta/0002_snapshot.json
Normal file
99
drizzle/meta/0002_snapshot.json
Normal file
@@ -0,0 +1,99 @@
|
||||
{
|
||||
"version": "6",
|
||||
"dialect": "sqlite",
|
||||
"id": "548c249b-15e5-4a6a-a3e4-c539d8774728",
|
||||
"prevId": "d5b8fe62-fa26-4e9b-94eb-d3d38701f620",
|
||||
"tables": {
|
||||
"token": {
|
||||
"name": "token",
|
||||
"columns": {
|
||||
"device_id": {
|
||||
"name": "device_id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"token": {
|
||||
"name": "token",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"username": {
|
||||
"name": "username",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"last_connected_at": {
|
||||
"name": "last_connected_at",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false,
|
||||
"default": "(CURRENT_TIMESTAMP)"
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"token_token_unique": {
|
||||
"name": "token_token_unique",
|
||||
"columns": ["token"],
|
||||
"isUnique": true
|
||||
}
|
||||
},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {}
|
||||
},
|
||||
"watch_status": {
|
||||
"name": "watch_status",
|
||||
"columns": {
|
||||
"device_id": {
|
||||
"name": "device_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"title_id": {
|
||||
"name": "title_id",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"watch_status_device_id_token_device_id_fk": {
|
||||
"name": "watch_status_device_id_token_device_id_fk",
|
||||
"tableFrom": "watch_status",
|
||||
"tableTo": "token",
|
||||
"columnsFrom": ["device_id"],
|
||||
"columnsTo": ["device_id"],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {
|
||||
"watch_status_device_id_title_id_pk": {
|
||||
"columns": ["device_id", "title_id"],
|
||||
"name": "watch_status_device_id_title_id_pk"
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {}
|
||||
}
|
||||
},
|
||||
"enums": {},
|
||||
"_meta": {
|
||||
"schemas": {},
|
||||
"tables": {},
|
||||
"columns": {}
|
||||
},
|
||||
"internal": {
|
||||
"indexes": {}
|
||||
}
|
||||
}
|
||||
99
drizzle/meta/0003_snapshot.json
Normal file
99
drizzle/meta/0003_snapshot.json
Normal file
@@ -0,0 +1,99 @@
|
||||
{
|
||||
"id": "3c96b576-9b17-42f7-9dd3-908a83c2a94b",
|
||||
"prevId": "548c249b-15e5-4a6a-a3e4-c539d8774728",
|
||||
"version": "6",
|
||||
"dialect": "sqlite",
|
||||
"tables": {
|
||||
"token": {
|
||||
"name": "token",
|
||||
"columns": {
|
||||
"device_id": {
|
||||
"name": "device_id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"token": {
|
||||
"name": "token",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"username": {
|
||||
"name": "username",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"last_connected_at": {
|
||||
"name": "last_connected_at",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false,
|
||||
"default": "(CURRENT_TIMESTAMP)"
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"token_token_unique": {
|
||||
"name": "token_token_unique",
|
||||
"columns": ["token"],
|
||||
"isUnique": true
|
||||
}
|
||||
},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {}
|
||||
},
|
||||
"watch_status": {
|
||||
"name": "watch_status",
|
||||
"columns": {
|
||||
"device_id": {
|
||||
"name": "device_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"title_id": {
|
||||
"name": "title_id",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"watch_status_device_id_token_device_id_fk": {
|
||||
"name": "watch_status_device_id_token_device_id_fk",
|
||||
"tableFrom": "watch_status",
|
||||
"columnsFrom": ["device_id"],
|
||||
"tableTo": "token",
|
||||
"columnsTo": ["device_id"],
|
||||
"onUpdate": "no action",
|
||||
"onDelete": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {
|
||||
"watch_status_device_id_title_id_pk": {
|
||||
"columns": ["device_id", "title_id"],
|
||||
"name": "watch_status_device_id_title_id_pk"
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {}
|
||||
}
|
||||
},
|
||||
"enums": {},
|
||||
"_meta": {
|
||||
"columns": {},
|
||||
"schemas": {},
|
||||
"tables": {}
|
||||
},
|
||||
"internal": {
|
||||
"indexes": {}
|
||||
}
|
||||
}
|
||||
101
drizzle/meta/0004_snapshot.json
Normal file
101
drizzle/meta/0004_snapshot.json
Normal file
@@ -0,0 +1,101 @@
|
||||
{
|
||||
"version": "6",
|
||||
"dialect": "sqlite",
|
||||
"id": "223cc621-0232-4499-973a-9013d134b1f9",
|
||||
"prevId": "3c96b576-9b17-42f7-9dd3-908a83c2a94b",
|
||||
"tables": {
|
||||
"device_tokens": {
|
||||
"name": "device_tokens",
|
||||
"columns": {
|
||||
"device_id": {
|
||||
"name": "device_id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"token": {
|
||||
"name": "token",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"username": {
|
||||
"name": "username",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"last_connected_at": {
|
||||
"name": "last_connected_at",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false,
|
||||
"default": "(CURRENT_TIMESTAMP)"
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"device_tokens_token_unique": {
|
||||
"name": "device_tokens_token_unique",
|
||||
"columns": ["token"],
|
||||
"isUnique": true
|
||||
}
|
||||
},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {}
|
||||
},
|
||||
"watch_status": {
|
||||
"name": "watch_status",
|
||||
"columns": {
|
||||
"device_id": {
|
||||
"name": "device_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"title_id": {
|
||||
"name": "title_id",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"watch_status_device_id_device_tokens_device_id_fk": {
|
||||
"name": "watch_status_device_id_device_tokens_device_id_fk",
|
||||
"tableFrom": "watch_status",
|
||||
"tableTo": "device_tokens",
|
||||
"columnsFrom": ["device_id"],
|
||||
"columnsTo": ["device_id"],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {
|
||||
"watch_status_device_id_title_id_pk": {
|
||||
"columns": ["device_id", "title_id"],
|
||||
"name": "watch_status_device_id_title_id_pk"
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {}
|
||||
}
|
||||
},
|
||||
"enums": {},
|
||||
"_meta": {
|
||||
"schemas": {},
|
||||
"tables": {
|
||||
"\"token\"": "\"device_tokens\""
|
||||
},
|
||||
"columns": {}
|
||||
},
|
||||
"internal": {
|
||||
"indexes": {}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,27 @@
|
||||
"when": 1718107695989,
|
||||
"tag": "0001_purple_franklin_richards",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 2,
|
||||
"version": "6",
|
||||
"when": 1718281079139,
|
||||
"tag": "0002_public_whistler",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 3,
|
||||
"version": "6",
|
||||
"when": 1718394970979,
|
||||
"tag": "0003_puzzling_nightmare",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 4,
|
||||
"version": "6",
|
||||
"when": 1718402777422,
|
||||
"tag": "0004_jittery_black_knight",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user