- Implemented user preferences management with a new API for GET and PUT requests. - Added user document progress tracking with a new API for retrieving and updating progress. - Introduced database schema changes for user preferences and document progress. - Enhanced EPUB and TTS contexts to support syncing user preferences and document progress. - Added functions to handle transferring user preferences and progress during account linking. - Updated client-side logic to schedule syncing of user preferences and document progress.
21 lines
829 B
SQL
21 lines
829 B
SQL
CREATE TABLE "user_document_progress" (
|
|
"user_id" text NOT NULL,
|
|
"document_id" text NOT NULL,
|
|
"reader_type" text NOT NULL,
|
|
"location" text NOT NULL,
|
|
"progress" real,
|
|
"client_updated_at_ms" bigint DEFAULT 0 NOT NULL,
|
|
"created_at" timestamp DEFAULT now(),
|
|
"updated_at" timestamp DEFAULT now(),
|
|
CONSTRAINT "user_document_progress_user_id_document_id_pk" PRIMARY KEY("user_id","document_id")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "user_preferences" (
|
|
"user_id" text PRIMARY KEY NOT NULL,
|
|
"data_json" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"client_updated_at_ms" bigint DEFAULT 0 NOT NULL,
|
|
"created_at" timestamp DEFAULT now(),
|
|
"updated_at" timestamp DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE INDEX "idx_user_document_progress_user_id_updated_at" ON "user_document_progress" USING btree ("user_id","updated_at");
|