Skip to content

Commit 8f41b76

Browse files
committed
Bump version to 10.0.6 and refine AGE extension initialization logic in AgeConnectionManager.
1 parent 660c96c commit 8f41b76

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
<RepositoryUrl>https://github.com/managedcode/graphrag</RepositoryUrl>
2727
<PackageProjectUrl>https://github.com/managedcode/graphrag</PackageProjectUrl>
2828
<Product>Managed Code GraphRag</Product>
29-
<Version>10.0.5</Version>
30-
<PackageVersion>10.0.5</PackageVersion>
29+
<Version>10.0.6</Version>
30+
<PackageVersion>10.0.6</PackageVersion>
3131

3232
</PropertyGroup>
3333
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">

src/ManagedCode.GraphRag.Postgres/ApacheAge/AgeConnectionManager.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,9 @@ private async Task LoadAgeAsync(NpgsqlConnection connection, CancellationToken c
137137
checkCommand.CommandTimeout = 0;
138138
var result = await checkCommand.ExecuteScalarAsync(cancellationToken).ConfigureAwait(false);
139139

140-
if (result is not null)
140+
if (result is null)
141141
{
142-
LogMessages.ExtensionLoaded(_logger, ConnectionString);
143-
return;
142+
throw new AgeException("AGE extension is not installed.");
144143
}
145144

146145
await using var load = connection.CreateCommand();
@@ -151,6 +150,18 @@ private async Task LoadAgeAsync(NpgsqlConnection connection, CancellationToken c
151150
}
152151
catch (PostgresException ex) when (ex.SqlState == "42501")
153152
{
153+
await using var initCommand = connection.CreateCommand();
154+
initCommand.CommandText = "SELECT ag_catalog.create_graph('__age_init__'); SELECT ag_catalog.drop_graph('__age_init__', true);";
155+
initCommand.CommandTimeout = 0;
156+
157+
try
158+
{
159+
await initCommand.ExecuteNonQueryAsync(cancellationToken).ConfigureAwait(false);
160+
}
161+
catch (PostgresException)
162+
{
163+
}
164+
154165
LogMessages.ExtensionLoaded(_logger, ConnectionString);
155166
}
156167
catch (PostgresException ex)

0 commit comments

Comments
 (0)