Skip to content

Commit

Permalink
Use hammer.db file from plugin's data directory
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverbooth committed Mar 19, 2022
1 parent 5c56481 commit 157281e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Hammer/Data/HammerContext.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.IO;
using Hammer.Data.EntityConfigurations;
using Microsoft.EntityFrameworkCore;

Expand All @@ -8,7 +9,16 @@ namespace Hammer.Data;
/// </summary>
internal sealed class HammerContext : DbContext
{
private const string DataSource = "hammer.db";
private readonly string _dataSource;

/// <summary>
/// Initializes a new instance of the <see cref="HammerContext" /> class.
/// </summary>
/// <param name="plugin">The owning plugin.</param>
public HammerContext(HammerPlugin plugin)
{
_dataSource = Path.Combine(plugin.DataDirectory.FullName, "hammer.db");
}

/// <summary>
/// Gets or sets the set of users who are blocked from making reports.
Expand Down Expand Up @@ -68,7 +78,7 @@ internal sealed class HammerContext : DbContext
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
optionsBuilder.UseSqlite($"Data Source={DataSource}");
optionsBuilder.UseSqlite($"Data Source={_dataSource}");
}

/// <inheritdoc />
Expand Down

0 comments on commit 157281e

Please sign in to comment.