Use a local SQLite3 backend instead of PostgreSQL Docker container.
* The provided SQLite3 database contains the required schemas, but no data and can be reset to if required. * Remove all references to PostgreSQL in documentation and configuration. * Replace native sqlite3 command with a console app to remove dependency on SQLite3 installation.
This commit is contained in:
@@ -21,10 +21,9 @@ services.AddEndpointsApiExplorer();
|
||||
services.AddSwaggerGen();
|
||||
services.AddDbContext<AppDbContext>(optionsBuilder =>
|
||||
{
|
||||
// Configure the database connection string.
|
||||
var connectionString = builder.Configuration.GetValue<string>("PostgresConnection");
|
||||
Console.WriteLine($"Connecting to PostgreSQL database with connection string: {connectionString}");
|
||||
optionsBuilder.UseNpgsql(connectionString);
|
||||
var connectionString = builder.Configuration.GetValue<string>("SqliteConnection");
|
||||
Console.WriteLine($"Setting up SQLite database with {connectionString}");
|
||||
optionsBuilder.UseSqlite(connectionString);
|
||||
});
|
||||
var httpClientBuilder = services.AddHttpClient<JsonPlaceholderClient>();
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"PostgresConnection": "Server=db;Database=mydatabase;User Id=user;Password=password;"
|
||||
}
|
||||
@@ -7,5 +7,5 @@
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"PostgresConnection": "Server=localhost;Database=mydatabase;User Id=user;Password=password;"
|
||||
}
|
||||
"SqliteConnection": "Data Source=service.db"
|
||||
}
|
||||
@@ -6,15 +6,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.16" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.6" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="9.6.0" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.24" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.13" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.13" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="9.10.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.9.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="docker compose up -d db" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
||||
BIN
service/service.db
Normal file
BIN
service/service.db
Normal file
Binary file not shown.
Reference in New Issue
Block a user