Add migration for movies table: create a new movies table with necessary fields, migrate existing data from the old movies table, and update database schema to reflect changes.

This commit is contained in:
Norbert Maciaszek
2025-08-11 23:52:04 +02:00
parent 96dd2b177c
commit 556bb38589
6 changed files with 201 additions and 12 deletions

View File

@@ -0,0 +1,25 @@
PRAGMA foreign_keys=OFF;--> statement-breakpoint
CREATE TABLE `__new_movies` (
`id` integer PRIMARY KEY NOT NULL,
`title` text NOT NULL,
`adult` integer NOT NULL,
`backdrop_path` text NOT NULL,
`genre_ids` text NOT NULL,
`original_language` text NOT NULL,
`original_title` text NOT NULL,
`overview` text NOT NULL,
`popularity` real NOT NULL,
`poster_path` text NOT NULL,
`release_date` text NOT NULL,
`video` integer NOT NULL,
`vote_average` real NOT NULL,
`vote_count` integer NOT NULL,
`seen` integer DEFAULT false,
`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
DROP TABLE `movies`;--> statement-breakpoint
ALTER TABLE `__new_movies` RENAME TO `movies`;--> statement-breakpoint
PRAGMA foreign_keys=ON;

View File

@@ -0,0 +1,142 @@
{
"version": "6",
"dialect": "sqlite",
"id": "c3b4d292-f58b-4df8-844c-6e534034c832",
"prevId": "19a2bad6-49be-485d-ac5e-291bd3d664ad",
"tables": {
"movies": {
"name": "movies",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"title": {
"name": "title",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"adult": {
"name": "adult",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"backdrop_path": {
"name": "backdrop_path",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"genre_ids": {
"name": "genre_ids",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"original_language": {
"name": "original_language",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"original_title": {
"name": "original_title",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"overview": {
"name": "overview",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"popularity": {
"name": "popularity",
"type": "real",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"poster_path": {
"name": "poster_path",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"release_date": {
"name": "release_date",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"video": {
"name": "video",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"vote_average": {
"name": "vote_average",
"type": "real",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"vote_count": {
"name": "vote_count",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"seen": {
"name": "seen",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": false
},
"favorite": {
"name": "favorite",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
}
},
"views": {},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}

View File

@@ -8,6 +8,13 @@
"when": 1754676538678,
"tag": "0000_breezy_lester",
"breakpoints": true
},
{
"idx": 1,
"version": "6",
"when": 1754948246595,
"tag": "0001_elite_odin",
"breakpoints": true
}
]
}