diff --git a/src/invidious/jobs.cr b/src/invidious/jobs.cr index 3c8470a54..9aaa7bd36 100644 --- a/src/invidious/jobs.cr +++ b/src/invidious/jobs.cr @@ -129,6 +129,14 @@ def refresh_feeds(db, logger, max_threads = 1) active_threads += 1 spawn do begin + db.query("SELECT * FROM #{view_name} LIMIT 1") do |rs| + # View doesn't contain same number of rows as ChannelVideo + if ChannelVideo.from_rs(rs)[0]?.try &.to_a.size.try &.!= rs.column_count + db.exec("DROP MATERIALIZED VIEW #{view_name}") + raise "valid schema does not exist" + end + end + db.exec("REFRESH MATERIALIZED VIEW #{view_name}") rescue ex # Create view if it doesn't exist