Skip to content

Commit

Permalink
Fix the creation of the flockmtl_storage (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
dorbanianas authored Dec 16, 2024
1 parent ad676de commit c8cad4a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/core/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ void Config::ConfigureGlobal() {
void Config::ConfigureLocal(duckdb::DatabaseInstance& db) {
auto con = Config::GetConnection(&db);
ConfigureTables(con, ConfigType::LOCAL);
con.Query(
duckdb_fmt::format("ATTACH DATABASE '{}' AS flockmtl_storage;", Config::get_global_storage_path().string()));
}

void Config::ConfigureTables(duckdb::Connection& con, const ConfigType type) {
Expand All @@ -73,18 +75,16 @@ void Config::ConfigureTables(duckdb::Connection& con, const ConfigType type) {
ConfigSchema(con, schema);
ConfigModelTable(con, schema, type);
ConfigPromptTable(con, schema, type);
con.Query(
duckdb_fmt::format("ATTACH DATABASE '{}' AS flockmtl_storage;", Config::get_global_storage_path().string()));
con.Commit();
}

void Config::Configure(duckdb::DatabaseInstance& db) {
Registry::Register(db);
SecretManager::Register(db);
if (const auto db_path = db.config.options.database_path; db_path != get_global_storage_path().string()) {
ConfigureLocal(db);
SetupGlobalStorageLocation();
ConfigureGlobal();
ConfigureLocal(db);
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/core/config/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ void Config::SetupDefaultModelsConfig(duckdb::Connection& con, std::string& sche
" AND table_name = '{}'; ",
schema_name, table_name));
if (result->RowCount() == 0) {
con.Query(duckdb_fmt::format(" LOAD JSON; "
con.Query(duckdb_fmt::format(" INSTALL JSON; "
" LOAD JSON; "
" CREATE TABLE {}.{} ( "
" model_name VARCHAR NOT NULL PRIMARY KEY, "
" model VARCHAR NOT NULL, "
Expand Down Expand Up @@ -49,7 +50,8 @@ void Config::SetupUserDefinedModelsConfig(duckdb::Connection& con, std::string&
" AND table_name = '{}'; ",
schema_name, table_name));
if (result->RowCount() == 0) {
con.Query(duckdb_fmt::format(" LOAD JSON; "
con.Query(duckdb_fmt::format(" INSTALL JSON; "
" LOAD JSON; "
" CREATE TABLE {}.{} ( "
" model_name VARCHAR NOT NULL PRIMARY KEY, "
" model VARCHAR NOT NULL, "
Expand Down

0 comments on commit c8cad4a

Please sign in to comment.