Skip to content

Commit

Permalink
chore: use sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
eugbyte committed Aug 30, 2024
1 parent b75f749 commit a7d545e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
7 changes: 4 additions & 3 deletions src/StoreOnWheels.Server/Libs/Shared/Configs/AppDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

namespace StoreOnWheels.Server.Libs.Shared.Configs;

public class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options) {
public class AppDbContext(DbContextOptions<AppDbContext> options, IConfiguration Configuration) : DbContext(options) {
public DbSet<Vendor> Vendors { get; set; }

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
base.OnConfiguring(optionsBuilder);
protected override void OnConfiguring(DbContextOptionsBuilder options) {
base.OnConfiguring(options);
}

protected override void OnModelCreating(ModelBuilder modelBuilder) {
Expand All @@ -21,4 +21,5 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) {

modelBuilder.Entity<Vendor>().HasData(vendor);
}

}
2 changes: 1 addition & 1 deletion src/StoreOnWheels.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// register DB
string? dbConnStr = builder.Configuration.GetConnectionString("WebApiDatabase");
builder.Services.AddDbContext<AppDbContext>(options => options.UseNpgsql(dbConnStr));
builder.Services.AddDbContext<AppDbContext>(options => options.UseSqlite(dbConnStr));

// Add cache
builder.Services.AddSingleton(new LRUCache<string, Vendor>(capacity: 200, evictCount: 10));
Expand Down
14 changes: 8 additions & 6 deletions src/StoreOnWheels.Server/StoreOnWheels.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,22 @@
<Version>8.*-*</Version>
</PackageReference>
<PackageReference Include="Caching.dll" Version="2.0.0.1" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.7">
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.8" />
<PackageReference Include="Microsoft.Build.NoTargets" Version="3.7.56" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.7">
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.3" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.4" />
<PackageReference Include="Nanoid" Version="3.1.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.3" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/StoreOnWheels.Server/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
},
"AllowedHosts": "*",
"ConnectionStrings": {
"WebApiDatabase": "Database=store_on_wheels;Server=localhost;Port=5432;Username=postgres;Password=admin;"
"WebApiDatabase": "Data Source=StoreOnWheels.db"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNet.SignalR" Version="2.4.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.7" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.7" />
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="8.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.7" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.8" />
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.8" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
Expand Down

0 comments on commit a7d545e

Please sign in to comment.