Add missing columns to a table
Examples
con <- db_connect(tempfile(fileext = ".duckdb"))
#> duckdb is storing downloaded extensions and secrets under ~/.duckdb:
#> ℹ /home/agoutsmedt/.duckdb
#> This persists across sessions and is shared with the DuckDB CLI and other clients.
#> ℹ Run duckdb(shared_home = FALSE) to use a temporary directory instead.
#> ℹ See ?duckdb_storage for details and alternatives.
DBI::dbWriteTable(con, "document", data.frame(doc_id = "a:1"))
add_missing_columns(con, "document", c(year = "INTEGER", doc_id = "VARCHAR"))
#> ℹ document: added column year.
DBI::dbListFields(con, "document")
#> [1] "doc_id" "year"
db_disconnect(con)