I used to initialize DB tables in the init function, which now segfaults the program in the newest version of webserver.
Modified code from examples:
init! : {} => Result Model [Exit I32 Str]_
init! = |{}|
db_path = read_env_var!("DB_PATH")?
list_todos_stmt = prepare_stmt!(db_path, "SELECT id, task, status FROM todos")?
create_todo_stmt = prepare_stmt!(db_path, "INSERT INTO todos (task, status) VALUES (:task, :status)")?
last_created_todo_stmt = prepare_stmt!(db_path, "SELECT id, task, status FROM todos WHERE id = last_insert_rowid()")?
begin_stmt = prepare_stmt!(db_path, "BEGIN")?
end_stmt = prepare_stmt!(db_path, "END")?
rollback_stmt = prepare_stmt!(db_path, "ROLLBACK")?
Sqlite.execute_prepared!({ bindings: [], stmt: list_todos_stmt })? **<-- this will crash**
Ok({ list_todos_stmt, create_todo_stmt, last_created_todo_stmt, begin_stmt, end_stmt, rollback_stmt })