@@ -6,7 +6,7 @@ use anyhow::Context;
66use chrono:: { DateTime , Utc } ;
77use sqlx:: any:: { AnyStatement , AnyTypeInfo } ;
88use sqlx:: postgres:: types:: PgTimeTz ;
9- use sqlx:: { Postgres , Statement , Type } ;
9+ use sqlx:: { Executor , Postgres , Statement , Type } ;
1010use std:: fmt:: Write ;
1111use std:: io:: ErrorKind ;
1212use std:: path:: { Component , Path , PathBuf } ;
@@ -267,13 +267,23 @@ impl DbFsQueries {
267267
268268 async fn init ( db : & Database ) -> anyhow:: Result < Self > {
269269 log:: debug!( "Initializing database filesystem queries" ) ;
270+ Self :: check_table_available ( db) . await ?;
270271 Ok ( Self {
271272 was_modified : Self :: make_was_modified_query ( db) . await ?,
272273 read_file : Self :: make_read_file_query ( db) . await ?,
273274 exists : Self :: make_exists_query ( db) . await ?,
274275 } )
275276 }
276277
278+ async fn check_table_available ( db : & Database ) -> anyhow:: Result < ( ) > {
279+ db. connection
280+ . execute ( "SELECT 1 FROM sqlpage_files WHERE 1 = 0" )
281+ . await
282+ . map ( |_| ( ) )
283+ . context ( "Unable to access sqlpage_files" ) ?;
284+ Ok ( ( ) )
285+ }
286+
277287 async fn make_was_modified_query ( db : & Database ) -> anyhow:: Result < AnyStatement < ' static > > {
278288 let was_modified_query = format ! (
279289 "SELECT 1 from sqlpage_files WHERE last_modified >= {} AND path = {}" ,
0 commit comments