orderly_rebuild {orderly} | R Documentation |
Rebuild the report database
Description
Rebuild the report database. This is necessary when the orderly database schema changes, and you will be prompted to run this function after upgrading orderly in that case.
Usage
orderly_rebuild(
root = NULL,
locate = TRUE,
verbose = TRUE,
if_schema_changed = FALSE
)
Arguments
root |
The path to an orderly root directory, or |
locate |
Logical, indicating if the configuration should be
searched for. If |
verbose |
Logical, indicating if information about the rebuild should be printed as it runs |
if_schema_changed |
Logical, indicating if the rebuild should take place only if the schema has changed. This is designed to be safe to use in (say) deployment scripts because it will be fast enough to call regularly. |
Details
The report database (orderly's "destination" database) is
essentially an index over all the metadata associated with
reports. It is used by orderly itself, and can be used by
applications that extend orderly (e.g.,
OrderlyWeb. All the
data in this database can be rebuilt from files stored with the
committed (archive) orderly reports, using the
orderly_rebuild
function.
Value
No return value, this function is called only for its side effects
Examples
path <- orderly::orderly_example("minimal")
id <- orderly::orderly_run("example", root = path)
orderly::orderly_commit(id, root = path)
con <- orderly::orderly_db("destination", root = path)
DBI::dbReadTable(con, "report_version")
DBI::dbDisconnect(con)
# The database can be removed and will be rebuilt if requested
# (this is only a good idea if you do not extend the database with
# your own fields - only the fields that orderly looks after can
# be recovered!)
file.remove(file.path(path, "orderly.sqlite"))
orderly::orderly_rebuild(path)
file.exists(file.path(path, "orderly.sqlite"))
con <- orderly::orderly_db("destination", root = path)
DBI::dbReadTable(con, "report_version")
DBI::dbDisconnect(con)
# It is safe to rebuild a database repeatedly, though this can be
# slow with larger databases.
orderly::orderly_rebuild(path)