Update movies migration: enhance the new movies table schema by adding additional fields such as adult, backdrop_path, genre_ids, original_language, original_title, video, vote_average, and vote_count, and migrate existing data accordingly.

This commit is contained in:
Norbert Maciaszek 2025-08-11 23:55:47 +02:00
parent 488b79e4b5
commit e189770473
1 changed files with 19 additions and 2 deletions

View File

@ -18,8 +18,25 @@ CREATE TABLE `__new_movies` (
`favorite` integer DEFAULT false
);
--> statement-breakpoint
INSERT INTO `__new_movies`("id", "title", "overview", "popularity", "poster_path", "release_date", "seen", "favorite")
SELECT "id", "title", "overview", "popularity", "poster_path", "release_date", "seen", "favorite" FROM `movies`;--> statement-breakpoint
INSERT INTO `__new_movies`("id", "title", "overview", "popularity", "poster_path", "release_date", "seen", "favorite", "adult", "backdrop_path", "genre_ids", "original_language", "original_title", "video", "vote_average", "vote_count")
SELECT
"id",
"title",
"overview",
"popularity",
"poster_path",
"release_date",
"seen",
"favorite",
0 as "adult", -- wartość domyślna
'' as "backdrop_path", -- wartość domyślna
'[]' as "genre_ids", -- wartość domyślna (pusta tablica JSON)
'pl-PL' as "original_language", -- wartość domyślna
"title" as "original_title", -- kopiuj z title
0 as "video", -- wartość domyślna
0.0 as "vote_average", -- wartość domyślna
0 as "vote_count" -- wartość domyślna
FROM `movies`;--> statement-breakpoint
DROP TABLE `movies`;--> statement-breakpoint
ALTER TABLE `__new_movies` RENAME TO `movies`;--> statement-breakpoint
PRAGMA foreign_keys=ON;