mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
Automatically recreate views with outdated schema
This commit is contained in:
parent
7381985c79
commit
1079c4516c
1 changed files with 8 additions and 0 deletions
|
@ -129,6 +129,14 @@ def refresh_feeds(db, logger, max_threads = 1)
|
||||||
active_threads += 1
|
active_threads += 1
|
||||||
spawn do
|
spawn do
|
||||||
begin
|
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}")
|
db.exec("REFRESH MATERIALIZED VIEW #{view_name}")
|
||||||
rescue ex
|
rescue ex
|
||||||
# Create view if it doesn't exist
|
# Create view if it doesn't exist
|
||||||
|
|
Loading…
Reference in a new issue