Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
<RepositoryUrl>https://github.com/managedcode/graphrag</RepositoryUrl>
<PackageProjectUrl>https://github.com/managedcode/graphrag</PackageProjectUrl>
<Product>Managed Code GraphRag</Product>
<Version>10.0.5</Version>
<PackageVersion>10.0.5</PackageVersion>
<Version>10.0.6</Version>
<PackageVersion>10.0.6</PackageVersion>

</PropertyGroup>
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,38 @@ private async Task LoadAgeAsync(NpgsqlConnection connection, CancellationToken c
{
try
{
await using var checkCommand = connection.CreateCommand();
checkCommand.CommandText = "SELECT 1 FROM pg_extension WHERE extname = 'age';";
checkCommand.CommandTimeout = 0;
var result = await checkCommand.ExecuteScalarAsync(cancellationToken).ConfigureAwait(false);

if (result is null)
{
throw new AgeException("AGE extension is not installed.");
}

await using var load = connection.CreateCommand();
load.CommandText = "LOAD 'age';";
load.CommandTimeout = 0;
await load.ExecuteNonQueryAsync(cancellationToken).ConfigureAwait(false);
LogMessages.ExtensionLoaded(_logger, ConnectionString);
}
catch (PostgresException ex) when (ex.SqlState == "42501")
{
await using var initCommand = connection.CreateCommand();
initCommand.CommandText = "SELECT ag_catalog.create_graph('__age_init__'); SELECT ag_catalog.drop_graph('__age_init__', true);";
initCommand.CommandTimeout = 0;

try
{
await initCommand.ExecuteNonQueryAsync(cancellationToken).ConfigureAwait(false);
}
catch (PostgresException)
{
}

LogMessages.ExtensionLoaded(_logger, ConnectionString);
}
catch (PostgresException ex)
{
LogMessages.ExtensionNotLoadedError(_logger, ConnectionString, ex.MessageText);
Expand Down