Skip to content

Commit 6132011

Browse files
committed
Fix sql crash on migration
1 parent 2bab8d9 commit 6132011

File tree

8 files changed

+93
-228
lines changed

8 files changed

+93
-228
lines changed

app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupEpisode.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,8 @@ val backupEpisodeMapper = {
6060
url: String,
6161
name: String,
6262
scanlator: String?,
63-
summary: String?,
64-
previewUrl: String?,
6563
seen: Boolean,
6664
bookmark: Boolean,
67-
fillermark: Boolean,
6865
lastSecondSeen: Long,
6966
totalSeconds: Long,
7067
episodeNumber: Double,
@@ -74,6 +71,9 @@ val backupEpisodeMapper = {
7471
lastModifiedAt: Long,
7572
version: Long,
7673
_: Long,
74+
summary: String?,
75+
previewUrl: String?,
76+
fillermark: Boolean,
7777
->
7878
BackupEpisode(
7979
url = url,

app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/restorers/AnimeRestorer.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ class AnimeRestorer(
131131
title = anime.title,
132132
status = anime.status,
133133
thumbnailUrl = anime.thumbnailUrl,
134-
backgroundUrl = anime.backgroundUrl,
135134
favorite = anime.favorite,
136135
lastUpdate = anime.lastUpdate,
137136
nextUpdate = null,
@@ -140,7 +139,6 @@ class AnimeRestorer(
140139
viewer = anime.viewerFlags,
141140
episodeFlags = anime.episodeFlags,
142141
coverLastModified = anime.coverLastModified,
143-
backgroundLastModified = anime.backgroundLastModified,
144142
dateAdded = anime.dateAdded,
145143
animeId = anime.id,
146144
updateStrategy = anime.updateStrategy.let(AnimeUpdateStrategyColumnAdapter::encode),
@@ -151,6 +149,8 @@ class AnimeRestorer(
151149
seasonFlags = anime.seasonFlags,
152150
seasonNumber = anime.seasonNumber,
153151
seasonSourceOrder = anime.seasonSourceOrder,
152+
backgroundUrl = anime.backgroundUrl,
153+
backgroundLastModified = anime.backgroundLastModified,
154154
)
155155
}
156156
return anime
@@ -220,18 +220,18 @@ class AnimeRestorer(
220220
episode.url,
221221
episode.name,
222222
episode.scanlator,
223-
episode.summary,
224-
episode.previewUrl,
225223
episode.seen,
226224
episode.bookmark,
227-
episode.fillermark,
228225
episode.lastSecondSeen,
229226
episode.totalSeconds,
230227
episode.episodeNumber,
231228
episode.sourceOrder,
232229
episode.dateFetch,
233230
episode.dateUpload,
234231
episode.version,
232+
episode.summary,
233+
episode.previewUrl,
234+
episode.fillermark,
235235
)
236236
}
237237
}
@@ -281,7 +281,6 @@ class AnimeRestorer(
281281
title = anime.title,
282282
status = anime.status,
283283
thumbnailUrl = anime.thumbnailUrl,
284-
backgroundUrl = anime.backgroundUrl,
285284
favorite = anime.favorite,
286285
lastUpdate = anime.lastUpdate,
287286
nextUpdate = 0L,
@@ -290,7 +289,6 @@ class AnimeRestorer(
290289
viewerFlags = anime.viewerFlags,
291290
episodeFlags = anime.episodeFlags,
292291
coverLastModified = anime.coverLastModified,
293-
backgroundLastModified = anime.backgroundLastModified,
294292
dateAdded = anime.dateAdded,
295293
updateStrategy = anime.updateStrategy,
296294
version = anime.version,
@@ -299,6 +297,8 @@ class AnimeRestorer(
299297
seasonFlags = anime.seasonFlags,
300298
seasonNumber = anime.seasonNumber,
301299
seasonSourceOrder = anime.seasonSourceOrder,
300+
backgroundUrl = anime.backgroundUrl,
301+
backgroundLastModified = anime.backgroundLastModified,
302302
)
303303
animesQueries.selectLastInsertedRowId()
304304
}

data/src/main/java/tachiyomi/data/entries/anime/AnimeMapper.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@ object AnimeMapper {
1919
title: String,
2020
status: Long,
2121
thumbnailUrl: String?,
22-
backgroundUrl: String?,
2322
favorite: Boolean,
2423
lastUpdate: Long?,
2524
nextUpdate: Long?,
2625
initialized: Boolean,
2726
viewerFlags: Long,
2827
chapterFlags: Long,
2928
coverLastModified: Long,
30-
backgroundLastModified: Long,
3129
dateAdded: Long,
3230
updateStrategy: AnimeUpdateStrategy,
3331
calculateInterval: Long,
@@ -41,6 +39,8 @@ object AnimeMapper {
4139
seasonFlags: Long,
4240
seasonNumber: Double,
4341
seasonSourceOrder: Long,
42+
backgroundUrl: String?,
43+
backgroundLastModified: Long,
4444
): Anime = Anime(
4545
id = id,
4646
source = source,
@@ -85,15 +85,13 @@ object AnimeMapper {
8585
title: String,
8686
status: Long,
8787
thumbnailUrl: String?,
88-
backgroundUrl: String?,
8988
favorite: Boolean,
9089
lastUpdate: Long?,
9190
nextUpdate: Long?,
9291
initialized: Boolean,
9392
viewerFlags: Long,
9493
chapterFlags: Long,
9594
coverLastModified: Long,
96-
backgroundLastModified: Long,
9795
dateAdded: Long,
9896
updateStrategy: AnimeUpdateStrategy,
9997
calculateInterval: Long,
@@ -106,6 +104,8 @@ object AnimeMapper {
106104
seasonFlags: Long,
107105
seasonNumber: Double,
108106
seasonSourceOrder: Long,
107+
backgroundUrl: String?,
108+
backgroundLastModified: Long,
109109
totalCount: Long,
110110
seenCount: Double,
111111
latestUpload: Long,
@@ -126,15 +126,13 @@ object AnimeMapper {
126126
title,
127127
status,
128128
thumbnailUrl,
129-
backgroundUrl,
130129
favorite,
131130
lastUpdate,
132131
nextUpdate,
133132
initialized,
134133
viewerFlags,
135134
chapterFlags,
136135
coverLastModified,
137-
backgroundLastModified,
138136
dateAdded,
139137
updateStrategy,
140138
calculateInterval,
@@ -147,6 +145,8 @@ object AnimeMapper {
147145
seasonFlags,
148146
seasonNumber,
149147
seasonSourceOrder,
148+
backgroundUrl,
149+
backgroundLastModified,
150150
),
151151
category = category,
152152
totalCount = totalCount,
@@ -169,15 +169,13 @@ object AnimeMapper {
169169
title: String,
170170
status: Long,
171171
thumbnailUrl: String?,
172-
backgroundUrl: String?,
173172
favorite: Boolean,
174173
lastUpdate: Long?,
175174
nextUpdate: Long?,
176175
initialized: Boolean,
177176
viewerFlags: Long,
178177
chapterFlags: Long,
179178
coverLastModified: Long,
180-
backgroundLastModified: Long,
181179
dateAdded: Long,
182180
updateStrategy: AnimeUpdateStrategy,
183181
calculateInterval: Long,
@@ -190,6 +188,8 @@ object AnimeMapper {
190188
seasonFlags: Long,
191189
seasonNumber: Double,
192190
seasonSourceOrder: Long,
191+
backgroundUrl: String?,
192+
backgroundLastModified: Long,
193193
totalCount: Long,
194194
seenCount: Double,
195195
latestUpload: Long,
@@ -209,15 +209,13 @@ object AnimeMapper {
209209
title,
210210
status,
211211
thumbnailUrl,
212-
backgroundUrl,
213212
favorite,
214213
lastUpdate,
215214
nextUpdate,
216215
initialized,
217216
viewerFlags,
218217
chapterFlags,
219218
coverLastModified,
220-
backgroundLastModified,
221219
dateAdded,
222220
updateStrategy,
223221
calculateInterval,
@@ -230,6 +228,8 @@ object AnimeMapper {
230228
seasonFlags,
231229
seasonNumber,
232230
seasonSourceOrder,
231+
backgroundUrl,
232+
backgroundLastModified,
233233
),
234234
totalCount = totalCount,
235235
seenCount = seenCount.toLong(),

data/src/main/java/tachiyomi/data/items/episode/EpisodeRepositoryImpl.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ class EpisodeRepositoryImpl(
2121
episode.url,
2222
episode.name,
2323
episode.scanlator,
24-
episode.summary,
25-
episode.previewUrl,
2624
episode.seen,
2725
episode.bookmark,
28-
episode.fillermark,
2926
episode.lastSecondSeen,
3027
episode.totalSeconds,
3128
episode.episodeNumber,
3229
episode.sourceOrder,
3330
episode.dateFetch,
3431
episode.dateUpload,
3532
episode.version,
33+
episode.summary,
34+
episode.previewUrl,
35+
episode.fillermark,
3636
)
3737
val lastInsertId = episodesQueries.selectLastInsertedRowId().executeAsOne()
3838
episode.copy(id = lastInsertId)
@@ -60,11 +60,8 @@ class EpisodeRepositoryImpl(
6060
url = episodeUpdate.url,
6161
name = episodeUpdate.name,
6262
scanlator = episodeUpdate.scanlator,
63-
summary = episodeUpdate.summary,
64-
previewUrl = episodeUpdate.previewUrl,
6563
seen = episodeUpdate.seen,
6664
bookmark = episodeUpdate.bookmark,
67-
fillermark = episodeUpdate.fillermark,
6865
lastSecondSeen = episodeUpdate.lastSecondSeen,
6966
totalSeconds = episodeUpdate.totalSeconds,
7067
episodeNumber = episodeUpdate.episodeNumber,
@@ -74,6 +71,9 @@ class EpisodeRepositoryImpl(
7471
episodeId = episodeUpdate.id,
7572
version = episodeUpdate.version,
7673
isSyncing = 0,
74+
summary = episodeUpdate.summary,
75+
previewUrl = episodeUpdate.previewUrl,
76+
fillermark = episodeUpdate.fillermark,
7777
)
7878
}
7979
}
@@ -129,11 +129,8 @@ class EpisodeRepositoryImpl(
129129
url: String,
130130
name: String,
131131
scanlator: String?,
132-
summary: String?,
133-
previewUrl: String?,
134132
seen: Boolean,
135133
bookmark: Boolean,
136-
fillermark: Boolean,
137134
lastSecondSeen: Long,
138135
totalSeconds: Long,
139136
episodeNumber: Double,
@@ -144,6 +141,9 @@ class EpisodeRepositoryImpl(
144141
version: Long,
145142
@Suppress("UNUSED_PARAMETER")
146143
isSyncing: Long,
144+
summary: String?,
145+
previewUrl: String?,
146+
fillermark: Boolean,
147147
): Episode = Episode(
148148
id = id,
149149
animeId = animeId,

data/src/main/sqldelightanime/dataanime/animes.sq

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@ CREATE TABLE animes(
1515
title TEXT NOT NULL,
1616
status INTEGER NOT NULL,
1717
thumbnail_url TEXT,
18-
background_url TEXT,
1918
favorite INTEGER AS Boolean NOT NULL,
2019
last_update INTEGER,
2120
next_update INTEGER,
2221
initialized INTEGER AS Boolean NOT NULL,
2322
viewer INTEGER NOT NULL,
2423
episode_flags INTEGER NOT NULL,
2524
cover_last_modified INTEGER NOT NULL,
26-
background_last_modified INTEGER NOT NULL,
2725
date_added INTEGER NOT NULL,
2826
update_strategy INTEGER AS AnimeUpdateStrategy NOT NULL DEFAULT 0,
2927
calculate_interval INTEGER DEFAULT 0 NOT NULL,
@@ -35,7 +33,9 @@ CREATE TABLE animes(
3533
parent_id INTEGER,
3634
season_flags INTEGER NOT NULL,
3735
season_number REAL NOT NULL,
38-
season_source_order INTEGER NOT NULL
36+
season_source_order INTEGER NOT NULL,
37+
background_url TEXT,
38+
background_last_modified INTEGER NOT NULL
3939
);
4040

4141
CREATE INDEX animelib_favorite_index ON animes(favorite) WHERE favorite = 1;
@@ -162,8 +162,8 @@ DELETE FROM animes
162162
WHERE favorite = 0 AND _id IN :animeIds;
163163

164164
insert:
165-
INSERT INTO animes(source, url, artist, author, description, genre, title, status, thumbnail_url, background_url, favorite, last_update, next_update, initialized, viewer, episode_flags, cover_last_modified, background_last_modified, date_added, update_strategy, calculate_interval, last_modified_at, version, fetch_type, parent_id, season_flags, season_number, season_source_order)
166-
VALUES (:source, :url, :artist, :author, :description, :genre, :title, :status, :thumbnailUrl, :backgroundUrl, :favorite, :lastUpdate, :nextUpdate, :initialized, :viewerFlags, :episodeFlags, :coverLastModified, :backgroundLastModified,:dateAdded, :updateStrategy, :calculateInterval, 0, :version, :fetchType, :parentId, :seasonFlags, :seasonNumber, :seasonSourceOrder);
165+
INSERT INTO animes(source, url, artist, author, description, genre, title, status, thumbnail_url, favorite, last_update, next_update, initialized, viewer, episode_flags, cover_last_modified, date_added, update_strategy, calculate_interval, last_modified_at, version, fetch_type, parent_id, season_flags, season_number, season_source_order, background_url, background_last_modified)
166+
VALUES (:source, :url, :artist, :author, :description, :genre, :title, :status, :thumbnailUrl, :favorite, :lastUpdate, :nextUpdate, :initialized, :viewerFlags, :episodeFlags, :coverLastModified,:dateAdded, :updateStrategy, :calculateInterval, 0, :version, :fetchType, :parentId, :seasonFlags, :seasonNumber, :seasonSourceOrder, :backgroundUrl, :backgroundLastModified);
167167

168168
update:
169169
UPDATE animes SET
@@ -176,15 +176,13 @@ UPDATE animes SET
176176
title = coalesce(:title, title),
177177
status = coalesce(:status, status),
178178
thumbnail_url = coalesce(:thumbnailUrl, thumbnail_url),
179-
background_url = coalesce(:backgroundUrl, background_url),
180179
favorite = coalesce(:favorite, favorite),
181180
last_update = coalesce(:lastUpdate, last_update),
182181
next_update = coalesce(:nextUpdate, next_update),
183182
initialized = coalesce(:initialized, initialized),
184183
viewer = coalesce(:viewer, viewer),
185184
episode_flags = coalesce(:episodeFlags, episode_flags),
186185
cover_last_modified = coalesce(:coverLastModified, cover_last_modified),
187-
background_last_modified = coalesce(:backgroundLastModified, background_last_modified),
188186
date_added = coalesce(:dateAdded, date_added),
189187
update_strategy = coalesce(:updateStrategy, update_strategy),
190188
calculate_interval = coalesce(:calculateInterval, calculate_interval),
@@ -194,7 +192,9 @@ UPDATE animes SET
194192
parent_id = coalesce(:parentId, parent_id),
195193
season_flags = coalesce(:seasonFlags, season_flags),
196194
season_number = coalesce(:seasonNumber, season_number),
197-
season_source_order = coalesce(:seasonSourceOrder, season_source_order)
195+
season_source_order = coalesce(:seasonSourceOrder, season_source_order),
196+
background_url = coalesce(:backgroundUrl, background_url),
197+
background_last_modified = coalesce(:backgroundLastModified, background_last_modified)
198198
WHERE _id = :animeId;
199199

200200
selectLastInsertedRowId:

0 commit comments

Comments
 (0)