feat(sqlite): implement movie and review management with migrations
- Added SQL migrations for movies and reviews tables. - Implemented SqliteMovieRepository with methods for upserting movies, saving reviews, and querying diary entries. - Introduced models for database rows and conversion to domain models. - Integrated async migration handling in the repository. - Updated Cargo.toml files to include necessary dependencies for async operations and HTTP handling.
This commit is contained in:
24
crates/adapters/sqlite/migrations/0001_initial.sql
Normal file
24
crates/adapters/sqlite/migrations/0001_initial.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
CREATE TABLE IF NOT EXISTS movies (
|
||||
id TEXT PRIMARY KEY NOT NULL,
|
||||
external_metadata_id TEXT UNIQUE,
|
||||
title TEXT NOT NULL,
|
||||
release_year INTEGER NOT NULL,
|
||||
director TEXT,
|
||||
poster_path TEXT
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_movies_title_year
|
||||
ON movies (title, release_year);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS reviews (
|
||||
id TEXT PRIMARY KEY NOT NULL,
|
||||
movie_id TEXT NOT NULL REFERENCES movies(id),
|
||||
user_id TEXT NOT NULL,
|
||||
rating INTEGER NOT NULL,
|
||||
comment TEXT,
|
||||
watched_at TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_reviews_movie_id ON reviews (movie_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_reviews_watched_at ON reviews (watched_at);
|
||||
Reference in New Issue
Block a user