-
-
Notifications
You must be signed in to change notification settings - Fork 526
Description
Hi,
i just observed some unintended behaviour with the Marten.CommandLine Tool.
It was included as suggested:
https://martendb.io/configuration/cli.html#snippet-sample_using_WebApplication_1
Just short hint, since i think the Extension Methods got updated, they are called now:
...
// Add command line parsing for Marten
builder.Host.ApplyOaktonExtensions();
...
await app.RunOaktonCommands(args);
The observed behaviour is that when i run dotnet run -- projections -r, it deletes all data from the Database.
Not sure if i did something wrong in my setup. It already worked at some point for me.
I also want to mention, it is uncritical to me, since i'm working on a Hobby-Project, but maybe to others.
Here is the state after running the command

It also occured, when i ran dotnet run -- projections -p <projection-name>.
Marten Setup is this:
var martenConfiguration = builder .Services.AddMarten(options => options.SetupStoreOptions(connectionString, isDevelopment)) .AddSubscriptionWithServices<OnRideFinishedSendEmailNotificationHandler>( ServiceLifetime.Singleton, o => o.IncludeType<RideFinished>() ) // Another performance optimization if you're starting from scratch .UseLightweightSessions() // Enable projection daemon .AddAsyncDaemon(DaemonMode.Solo);
public static class StoreOptionsExtensions { public static void SetupStoreOptions( this StoreOptions options, string connectionString, bool isDevelopment ) { options.Connection(connectionString); options.UseSystemTextJsonForSerialization( EnumStorage.AsString, Casing.Default, jsonOptions => jsonOptions.Converters.Add(new JsonStringEnumConverter()) ); // If we're running in development mode, let Marten just take care // of all necessary schema building and patching behind the scenes if (isDevelopment) { options.AutoCreateSchemaObjects = AutoCreate.All; } // Ride options.Projections.Snapshot<Ride>(SnapshotLifecycle.Inline); options.Projections.Add<RideSummaryProjection>(ProjectionLifecycle.Async); // Rider options.Projections.Snapshot<Rider>(SnapshotLifecycle.Inline); options.Projections.Add<RiderHistoryProjection>(ProjectionLifecycle.Inline); options.Projections.Add<RiderTripProjection>(ProjectionLifecycle.Async); // Recent optimization you'd want with FetchForWriting up above options.Projections.UseIdentityMapForAggregates = true; // Turn on the PostgreSQL table partitioning for hot/cold storage on archived events options.Events.UseArchivedStreamPartitioning = true; } }
Can you see something obvious? Would appreciate some hints.
Best Regards,
Christoph
