Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Mocha/src/Demo/Demo.Billing/Data/BillingDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Demo.Billing.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Mocha.Inbox;
using Mocha.Outbox;

namespace Demo.Billing.Data;
Expand All @@ -11,12 +12,14 @@ public class BillingDbContext(DbContextOptions<BillingDbContext> options) : DbCo
public DbSet<Payment> Payments => Set<Payment>();
public DbSet<Refund> Refunds => Set<Refund>();
public DbSet<RevenueSummary> RevenueSummaries => Set<RevenueSummary>();
public DbSet<InboxMessage> InboxMessages => Set<InboxMessage>();

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);

modelBuilder.AddPostgresOutbox();
modelBuilder.AddPostgresInbox();

modelBuilder.Entity<Invoice>(entity =>
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Demo.Billing.Migrations
{
/// <inheritdoc />
public partial class AddInboxMessage : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "inbox_messages",
columns: table => new
{
message_id = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: false),
message_type = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true),
processed_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "NOW()")
},
constraints: table =>
table.PrimaryKey("ix_inbox_messages_primary_key", x => x.message_id));
Comment thread
PascalSenn marked this conversation as resolved.
Outdated

migrationBuilder.CreateTable(
name: "RevenueSummaries",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
OrderCount = table.Column<int>(type: "integer", nullable: false),
TotalRevenue = table.Column<decimal>(type: "numeric(18,2)", nullable: false, precision: 18, scale: 2),
AverageOrderAmount = table.Column<decimal>(type: "numeric(18,2)", nullable: false, precision: 18, scale: 2),
TotalItemsSold = table.Column<int>(type: "integer", nullable: false),
PeriodStart = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
PeriodEnd = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
CompletionMode = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
table.PrimaryKey("PK_RevenueSummaries", x => x.Id));

migrationBuilder.CreateIndex(
name: "ix_inbox_messages_processed_at",
table: "inbox_messages",
column: "processed_at");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "inbox_messages");

migrationBuilder.DropTable(
name: "RevenueSummaries");
}
}
}
Loading
Loading