Skip to content

Commit

Permalink
Don't migrate schemas on read only databases
Browse files Browse the repository at this point in the history
  • Loading branch information
halgari committed Jan 28, 2025
1 parent f7fff01 commit acc0d12
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/NexusMods.MnemonicDB/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class Connection : IConnection
/// <summary>
/// Main connection class, co-ordinates writes and immutable reads
/// </summary>
public Connection(ILogger<Connection> logger, IDatomStore store, IServiceProvider provider, IEnumerable<IAnalyzer> analyzers)
public Connection(ILogger<Connection> logger, IDatomStore store, IServiceProvider provider, IEnumerable<IAnalyzer> analyzers, bool readOnlyMode = false)
{
ServiceProvider = provider;
AttributeCache = store.AttributeCache;
Expand All @@ -57,7 +57,7 @@ public Connection(ILogger<Connection> logger, IDatomStore store, IServiceProvide
_store = (DatomStore)store;
_dbStream = new DbStream();
_analyzers = analyzers.ToArray();
Bootstrap();
Bootstrap(readOnlyMode);
}

/// <summary>
Expand Down Expand Up @@ -315,7 +315,7 @@ internal async Task<ICommitResult> Transact(IInternalTxFunction fn)
return result;
}

private void Bootstrap()
private void Bootstrap(bool readOnlyMode)
{
try
{
Expand All @@ -327,7 +327,9 @@ private void Bootstrap()
AttributeCache.Reset(initialDb);

var declaredAttributes = AttributeResolver.DefinedAttributes.OrderBy(a => a.Id.Id).ToArray();
_store.Transact(new SimpleMigration(declaredAttributes));

if (!readOnlyMode)
_store.Transact(new SimpleMigration(declaredAttributes));

_dbStreamDisposable = ProcessUpdates(_store.TxLog)
.Subscribe();
Expand Down

0 comments on commit acc0d12

Please sign in to comment.