Add domestic vendor push infrastructure
This commit is contained in:
@@ -17,7 +17,12 @@ public class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(op
|
||||
public DbSet<AppConfig> AppConfigs => Set<AppConfig>();
|
||||
public DbSet<AiPersona> AiPersonas => Set<AiPersona>();
|
||||
public DbSet<AiAvatar> AiAvatars => Set<AiAvatar>();
|
||||
public DbSet<Sticker> Stickers => Set<Sticker>();
|
||||
public DbSet<Sticker> Stickers => Set<Sticker>();
|
||||
public DbSet<PushDevice> PushDevices => Set<PushDevice>();
|
||||
public DbSet<UserPushPreference> UserPushPreferences => Set<UserPushPreference>();
|
||||
public DbSet<PushMessage> PushMessages => Set<PushMessage>();
|
||||
public DbSet<PushDelivery> PushDeliveries => Set<PushDelivery>();
|
||||
public DbSet<BudgetNotificationReceipt> BudgetNotificationReceipts => Set<BudgetNotificationReceipt>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder b)
|
||||
{
|
||||
@@ -67,6 +72,76 @@ public class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(op
|
||||
b.Entity<AiAvatar>(e => e.HasIndex(x => x.Key).IsUnique());
|
||||
b.Entity<Sticker>(e => e.HasIndex(x => x.Key).IsUnique());
|
||||
|
||||
b.Entity<PushDevice>(e =>
|
||||
{
|
||||
e.Property(x => x.InstallationId).HasMaxLength(64);
|
||||
e.Property(x => x.Provider).HasMaxLength(16);
|
||||
e.Property(x => x.TokenCiphertext).HasMaxLength(6144);
|
||||
e.Property(x => x.TokenHash).HasMaxLength(64);
|
||||
e.Property(x => x.UnbindTokenHash).HasMaxLength(64);
|
||||
e.Property(x => x.PackageName).HasMaxLength(128);
|
||||
e.Property(x => x.Flavor).HasMaxLength(24);
|
||||
e.Property(x => x.AppVersion).HasMaxLength(32);
|
||||
e.Property(x => x.DisabledReason).HasMaxLength(64);
|
||||
e.HasIndex(x => new { x.PackageName, x.InstallationId }).IsUnique();
|
||||
e.HasIndex(x => new { x.Provider, x.PackageName, x.TokenHash }).IsUnique();
|
||||
e.HasIndex(x => new { x.UserId, x.IsActive });
|
||||
e.HasIndex(x => x.LastSeenAt);
|
||||
e.HasOne(x => x.User).WithMany(x => x.PushDevices)
|
||||
.HasForeignKey(x => x.UserId).OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
b.Entity<UserPushPreference>(e =>
|
||||
{
|
||||
e.Property(x => x.Category).HasMaxLength(24);
|
||||
e.HasIndex(x => new { x.UserId, x.Category }).IsUnique();
|
||||
e.HasOne(x => x.User).WithMany(x => x.PushPreferences)
|
||||
.HasForeignKey(x => x.UserId).OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
b.Entity<PushMessage>(e =>
|
||||
{
|
||||
e.Property(x => x.PublicId).HasMaxLength(36);
|
||||
e.Property(x => x.Source).HasMaxLength(24);
|
||||
e.Property(x => x.State).HasMaxLength(24);
|
||||
e.Property(x => x.Category).HasMaxLength(24);
|
||||
e.Property(x => x.Title).HasMaxLength(80);
|
||||
e.Property(x => x.Body).HasMaxLength(240);
|
||||
e.Property(x => x.Action).HasMaxLength(24);
|
||||
e.Property(x => x.EntityId).HasMaxLength(64);
|
||||
e.Property(x => x.Flavor).HasMaxLength(24);
|
||||
e.Property(x => x.ProviderFilter).HasMaxLength(16);
|
||||
e.HasIndex(x => x.PublicId).IsUnique();
|
||||
e.HasIndex(x => new { x.State, x.ScheduledAt });
|
||||
e.HasIndex(x => new { x.TargetUserId, x.CreatedAt });
|
||||
});
|
||||
|
||||
b.Entity<PushDelivery>(e =>
|
||||
{
|
||||
e.Property(x => x.Provider).HasMaxLength(16);
|
||||
e.Property(x => x.State).HasMaxLength(24);
|
||||
e.Property(x => x.LeaseId).HasMaxLength(36);
|
||||
e.Property(x => x.ProviderMessageId).HasMaxLength(128);
|
||||
e.Property(x => x.ErrorCode).HasMaxLength(64);
|
||||
e.Property(x => x.ErrorMessage).HasMaxLength(400);
|
||||
e.HasIndex(x => new { x.PushMessageId, x.PushDeviceId }).IsUnique();
|
||||
e.HasIndex(x => new { x.State, x.NextAttemptAt, x.LeaseExpiresAt });
|
||||
e.HasOne(x => x.PushMessage).WithMany(x => x.Deliveries)
|
||||
.HasForeignKey(x => x.PushMessageId).OnDelete(DeleteBehavior.Cascade);
|
||||
e.HasOne(x => x.PushDevice).WithMany(x => x.Deliveries)
|
||||
.HasForeignKey(x => x.PushDeviceId).OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
b.Entity<BudgetNotificationReceipt>(e =>
|
||||
{
|
||||
e.HasIndex(x => new { x.BudgetId, x.Period, x.Threshold }).IsUnique();
|
||||
e.HasIndex(x => new { x.UserId, x.Period });
|
||||
e.HasOne(x => x.User).WithMany()
|
||||
.HasForeignKey(x => x.UserId).OnDelete(DeleteBehavior.Cascade);
|
||||
e.HasOne(x => x.Budget).WithMany()
|
||||
.HasForeignKey(x => x.BudgetId).OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
// MySQL DATETIME has no timezone metadata. Preserve stored UTC wall-clock
|
||||
// values and restore DateTimeKind.Utc whenever EF materializes them.
|
||||
var utcDateTimeConverter = new ValueConverter<DateTime, DateTime>(
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Design;
|
||||
|
||||
namespace MiaoJiZhang.Infrastructure.Persistence;
|
||||
|
||||
public sealed class AppDbContextFactory : IDesignTimeDbContextFactory<AppDbContext>
|
||||
{
|
||||
public AppDbContext CreateDbContext(string[] args)
|
||||
{
|
||||
var options = new DbContextOptionsBuilder<AppDbContext>()
|
||||
.UseMySql(
|
||||
"Server=127.0.0.1;Database=miaoji_design;User=design;Password=design;",
|
||||
new MySqlServerVersion(new Version(8, 0, 36)))
|
||||
.Options;
|
||||
return new AppDbContext(options);
|
||||
}
|
||||
}
|
||||
+1031
File diff suppressed because it is too large
Load Diff
+295
@@ -0,0 +1,295 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MiaoJiZhang.Infrastructure.Persistence.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class VendorPushInfrastructure : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "BudgetNotificationReceipts",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
UserId = table.Column<long>(type: "bigint", nullable: false),
|
||||
BudgetId = table.Column<long>(type: "bigint", nullable: false),
|
||||
Period = table.Column<int>(type: "int", nullable: false),
|
||||
Threshold = table.Column<int>(type: "int", nullable: false),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_BudgetNotificationReceipts", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_BudgetNotificationReceipts_Budgets_BudgetId",
|
||||
column: x => x.BudgetId,
|
||||
principalTable: "Budgets",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_BudgetNotificationReceipts_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PushDevices",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
UserId = table.Column<long>(type: "bigint", nullable: false),
|
||||
InstallationId = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Provider = table.Column<string>(type: "varchar(16)", maxLength: 16, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
TokenCiphertext = table.Column<string>(type: "varchar(6144)", maxLength: 6144, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
TokenHash = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
UnbindTokenHash = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
PackageName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Flavor = table.Column<string>(type: "varchar(24)", maxLength: 24, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
AppVersion = table.Column<string>(type: "varchar(32)", maxLength: 32, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
VersionCode = table.Column<int>(type: "int", nullable: false),
|
||||
NotificationsAllowed = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
DisabledReason = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
LastSeenAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PushDevices", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_PushDevices_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PushMessages",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
PublicId = table.Column<string>(type: "varchar(36)", maxLength: 36, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Source = table.Column<string>(type: "varchar(24)", maxLength: 24, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
State = table.Column<string>(type: "varchar(24)", maxLength: 24, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Category = table.Column<string>(type: "varchar(24)", maxLength: 24, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Title = table.Column<string>(type: "varchar(80)", maxLength: 80, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Body = table.Column<string>(type: "varchar(240)", maxLength: 240, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Action = table.Column<string>(type: "varchar(24)", maxLength: 24, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
EntityId = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
TargetUserId = table.Column<long>(type: "bigint", nullable: true),
|
||||
Flavor = table.Column<string>(type: "varchar(24)", maxLength: 24, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ProviderFilter = table.Column<string>(type: "varchar(16)", maxLength: 16, nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
MinVersionCode = table.Column<int>(type: "int", nullable: true),
|
||||
MaxVersionCode = table.Column<int>(type: "int", nullable: true),
|
||||
TtlSeconds = table.Column<int>(type: "int", nullable: false),
|
||||
IsTest = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
TestDeviceId = table.Column<long>(type: "bigint", nullable: true),
|
||||
ScheduledAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
StartedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
||||
CompletedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
||||
CancelledAt = table.Column<DateTime>(type: "datetime(6)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PushMessages", x => x.Id);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "UserPushPreferences",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
UserId = table.Column<long>(type: "bigint", nullable: false),
|
||||
Category = table.Column<string>(type: "varchar(24)", maxLength: 24, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
IsEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_UserPushPreferences", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_UserPushPreferences_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PushDeliveries",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
PushMessageId = table.Column<long>(type: "bigint", nullable: false),
|
||||
PushDeviceId = table.Column<long>(type: "bigint", nullable: false),
|
||||
UserId = table.Column<long>(type: "bigint", nullable: false),
|
||||
Provider = table.Column<string>(type: "varchar(16)", maxLength: 16, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
State = table.Column<string>(type: "varchar(24)", maxLength: 24, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
AttemptCount = table.Column<int>(type: "int", nullable: false),
|
||||
NextAttemptAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
LeaseId = table.Column<string>(type: "varchar(36)", maxLength: 36, nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
LeaseExpiresAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
||||
ProviderMessageId = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ErrorCode = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ErrorMessage = table.Column<string>(type: "varchar(400)", maxLength: 400, nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
AcceptedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PushDeliveries", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_PushDeliveries_PushDevices_PushDeviceId",
|
||||
column: x => x.PushDeviceId,
|
||||
principalTable: "PushDevices",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_PushDeliveries_PushMessages_PushMessageId",
|
||||
column: x => x.PushMessageId,
|
||||
principalTable: "PushMessages",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_BudgetNotificationReceipts_BudgetId_Period_Threshold",
|
||||
table: "BudgetNotificationReceipts",
|
||||
columns: new[] { "BudgetId", "Period", "Threshold" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_BudgetNotificationReceipts_UserId_Period",
|
||||
table: "BudgetNotificationReceipts",
|
||||
columns: new[] { "UserId", "Period" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PushDeliveries_PushDeviceId",
|
||||
table: "PushDeliveries",
|
||||
column: "PushDeviceId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PushDeliveries_PushMessageId_PushDeviceId",
|
||||
table: "PushDeliveries",
|
||||
columns: new[] { "PushMessageId", "PushDeviceId" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PushDeliveries_State_NextAttemptAt_LeaseExpiresAt",
|
||||
table: "PushDeliveries",
|
||||
columns: new[] { "State", "NextAttemptAt", "LeaseExpiresAt" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PushDevices_LastSeenAt",
|
||||
table: "PushDevices",
|
||||
column: "LastSeenAt");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PushDevices_PackageName_InstallationId",
|
||||
table: "PushDevices",
|
||||
columns: new[] { "PackageName", "InstallationId" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PushDevices_Provider_PackageName_TokenHash",
|
||||
table: "PushDevices",
|
||||
columns: new[] { "Provider", "PackageName", "TokenHash" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PushDevices_UserId_IsActive",
|
||||
table: "PushDevices",
|
||||
columns: new[] { "UserId", "IsActive" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PushMessages_PublicId",
|
||||
table: "PushMessages",
|
||||
column: "PublicId",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PushMessages_State_ScheduledAt",
|
||||
table: "PushMessages",
|
||||
columns: new[] { "State", "ScheduledAt" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PushMessages_TargetUserId_CreatedAt",
|
||||
table: "PushMessages",
|
||||
columns: new[] { "TargetUserId", "CreatedAt" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_UserPushPreferences_UserId_Category",
|
||||
table: "UserPushPreferences",
|
||||
columns: new[] { "UserId", "Category" },
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "BudgetNotificationReceipts");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PushDeliveries");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "UserPushPreferences");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PushDevices");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PushMessages");
|
||||
}
|
||||
}
|
||||
}
|
||||
+448
-47
@@ -1,4 +1,4 @@
|
||||
// <auto-generated />
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using MiaoJiZhang.Infrastructure.Persistence;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -199,6 +199,39 @@ namespace MiaoJiZhang.Infrastructure.Persistence.Migrations
|
||||
b.ToTable("Budgets");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MiaoJiZhang.Domain.Entities.BudgetNotificationReceipt", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<long>("BudgetId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int>("Period")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Threshold")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<long>("UserId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId", "Period");
|
||||
|
||||
b.HasIndex("BudgetId", "Period", "Threshold")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("BudgetNotificationReceipts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MiaoJiZhang.Domain.Entities.Category", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
@@ -303,6 +336,271 @@ namespace MiaoJiZhang.Infrastructure.Persistence.Migrations
|
||||
b.ToTable("Ledgers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MiaoJiZhang.Domain.Entities.PushDelivery", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime?>("AcceptedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int>("AttemptCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("ErrorCode")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("varchar(64)");
|
||||
|
||||
b.Property<string>("ErrorMessage")
|
||||
.HasMaxLength(400)
|
||||
.HasColumnType("varchar(400)");
|
||||
|
||||
b.Property<DateTime?>("LeaseExpiresAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("LeaseId")
|
||||
.HasMaxLength(36)
|
||||
.HasColumnType("varchar(36)");
|
||||
|
||||
b.Property<DateTime>("NextAttemptAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Provider")
|
||||
.IsRequired()
|
||||
.HasMaxLength(16)
|
||||
.HasColumnType("varchar(16)");
|
||||
|
||||
b.Property<string>("ProviderMessageId")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("varchar(128)");
|
||||
|
||||
b.Property<long>("PushDeviceId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("PushMessageId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("State")
|
||||
.IsRequired()
|
||||
.HasMaxLength(24)
|
||||
.HasColumnType("varchar(24)");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<long>("UserId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PushDeviceId");
|
||||
|
||||
b.HasIndex("PushMessageId", "PushDeviceId")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("State", "NextAttemptAt", "LeaseExpiresAt");
|
||||
|
||||
b.ToTable("PushDeliveries");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MiaoJiZhang.Domain.Entities.PushDevice", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<string>("AppVersion")
|
||||
.IsRequired()
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("varchar(32)");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("DisabledReason")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("varchar(64)");
|
||||
|
||||
b.Property<string>("Flavor")
|
||||
.IsRequired()
|
||||
.HasMaxLength(24)
|
||||
.HasColumnType("varchar(24)");
|
||||
|
||||
b.Property<string>("InstallationId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("varchar(64)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<DateTime>("LastSeenAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("NotificationsAllowed")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("PackageName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("varchar(128)");
|
||||
|
||||
b.Property<string>("Provider")
|
||||
.IsRequired()
|
||||
.HasMaxLength(16)
|
||||
.HasColumnType("varchar(16)");
|
||||
|
||||
b.Property<string>("TokenCiphertext")
|
||||
.IsRequired()
|
||||
.HasMaxLength(6144)
|
||||
.HasColumnType("varchar(6144)");
|
||||
|
||||
b.Property<string>("TokenHash")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("varchar(64)");
|
||||
|
||||
b.Property<string>("UnbindTokenHash")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("varchar(64)");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<long>("UserId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("VersionCode")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("LastSeenAt");
|
||||
|
||||
b.HasIndex("PackageName", "InstallationId")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("UserId", "IsActive");
|
||||
|
||||
b.HasIndex("Provider", "PackageName", "TokenHash")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("PushDevices");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MiaoJiZhang.Domain.Entities.PushMessage", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<string>("Action")
|
||||
.IsRequired()
|
||||
.HasMaxLength(24)
|
||||
.HasColumnType("varchar(24)");
|
||||
|
||||
b.Property<string>("Body")
|
||||
.IsRequired()
|
||||
.HasMaxLength(240)
|
||||
.HasColumnType("varchar(240)");
|
||||
|
||||
b.Property<DateTime?>("CancelledAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Category")
|
||||
.IsRequired()
|
||||
.HasMaxLength(24)
|
||||
.HasColumnType("varchar(24)");
|
||||
|
||||
b.Property<DateTime?>("CompletedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("EntityId")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("varchar(64)");
|
||||
|
||||
b.Property<string>("Flavor")
|
||||
.IsRequired()
|
||||
.HasMaxLength(24)
|
||||
.HasColumnType("varchar(24)");
|
||||
|
||||
b.Property<bool>("IsTest")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int?>("MaxVersionCode")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("MinVersionCode")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ProviderFilter")
|
||||
.HasMaxLength(16)
|
||||
.HasColumnType("varchar(16)");
|
||||
|
||||
b.Property<string>("PublicId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(36)
|
||||
.HasColumnType("varchar(36)");
|
||||
|
||||
b.Property<DateTime?>("ScheduledAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Source")
|
||||
.IsRequired()
|
||||
.HasMaxLength(24)
|
||||
.HasColumnType("varchar(24)");
|
||||
|
||||
b.Property<DateTime?>("StartedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("State")
|
||||
.IsRequired()
|
||||
.HasMaxLength(24)
|
||||
.HasColumnType("varchar(24)");
|
||||
|
||||
b.Property<long?>("TargetUserId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long?>("TestDeviceId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasMaxLength(80)
|
||||
.HasColumnType("varchar(80)");
|
||||
|
||||
b.Property<int>("TtlSeconds")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PublicId")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("State", "ScheduledAt");
|
||||
|
||||
b.HasIndex("TargetUserId", "CreatedAt");
|
||||
|
||||
b.ToTable("PushMessages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MiaoJiZhang.Domain.Entities.Sticker", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
@@ -404,47 +702,14 @@ namespace MiaoJiZhang.Infrastructure.Persistence.Migrations
|
||||
|
||||
b.HasIndex("LedgerId", "OccurredAt");
|
||||
|
||||
b.HasIndex("UserId", "IsDeleted");
|
||||
|
||||
b.HasIndex("UserId", "ClientRequestId")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("UserId", "IsDeleted");
|
||||
|
||||
b.ToTable("Transactions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MiaoJiZhang.Domain.Entities.UserFeaturePermission", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsEnabled")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("PermissionKey")
|
||||
.IsRequired()
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("varchar(32)");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<long>("UserId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId", "PermissionKey")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("UserFeaturePermissions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MiaoJiZhang.Domain.Entities.User", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
@@ -453,8 +718,11 @@ namespace MiaoJiZhang.Infrastructure.Persistence.Migrations
|
||||
|
||||
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<int>("AppMode")
|
||||
.HasColumnType("int");
|
||||
b.Property<DateTime?>("AccountClosureRequestedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime?>("AccountClosureScheduledAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int>("AiChatLimit")
|
||||
.HasColumnType("int");
|
||||
@@ -468,15 +736,15 @@ namespace MiaoJiZhang.Infrastructure.Persistence.Migrations
|
||||
b.Property<DateTime>("AiChatWindowStartedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime?>("AccountClosureRequestedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime?>("AccountClosureScheduledAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
b.Property<int>("AppMode")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("AppleUserId")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("AuthVersion")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("AvatarUrl")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
@@ -489,9 +757,6 @@ namespace MiaoJiZhang.Infrastructure.Persistence.Migrations
|
||||
b.Property<bool>("EmailVerified")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("AuthVersion")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<bool>("IsBanned")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
@@ -542,6 +807,69 @@ namespace MiaoJiZhang.Infrastructure.Persistence.Migrations
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MiaoJiZhang.Domain.Entities.UserFeaturePermission", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsEnabled")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("PermissionKey")
|
||||
.IsRequired()
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("varchar(32)");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<long>("UserId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId", "PermissionKey")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("UserFeaturePermissions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MiaoJiZhang.Domain.Entities.UserPushPreference", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<string>("Category")
|
||||
.IsRequired()
|
||||
.HasMaxLength(24)
|
||||
.HasColumnType("varchar(24)");
|
||||
|
||||
b.Property<bool>("IsEnabled")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<long>("UserId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId", "Category")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("UserPushPreferences");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MiaoJiZhang.Domain.Entities.AiCompanionSetting", b =>
|
||||
{
|
||||
b.HasOne("MiaoJiZhang.Domain.Entities.User", "User")
|
||||
@@ -564,6 +892,25 @@ namespace MiaoJiZhang.Infrastructure.Persistence.Migrations
|
||||
b.Navigation("Ledger");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MiaoJiZhang.Domain.Entities.BudgetNotificationReceipt", b =>
|
||||
{
|
||||
b.HasOne("MiaoJiZhang.Domain.Entities.Budget", "Budget")
|
||||
.WithMany()
|
||||
.HasForeignKey("BudgetId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("MiaoJiZhang.Domain.Entities.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Budget");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MiaoJiZhang.Domain.Entities.Ledger", b =>
|
||||
{
|
||||
b.HasOne("MiaoJiZhang.Domain.Entities.User", "Owner")
|
||||
@@ -575,6 +922,36 @@ namespace MiaoJiZhang.Infrastructure.Persistence.Migrations
|
||||
b.Navigation("Owner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MiaoJiZhang.Domain.Entities.PushDelivery", b =>
|
||||
{
|
||||
b.HasOne("MiaoJiZhang.Domain.Entities.PushDevice", "PushDevice")
|
||||
.WithMany("Deliveries")
|
||||
.HasForeignKey("PushDeviceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("MiaoJiZhang.Domain.Entities.PushMessage", "PushMessage")
|
||||
.WithMany("Deliveries")
|
||||
.HasForeignKey("PushMessageId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("PushDevice");
|
||||
|
||||
b.Navigation("PushMessage");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MiaoJiZhang.Domain.Entities.PushDevice", b =>
|
||||
{
|
||||
b.HasOne("MiaoJiZhang.Domain.Entities.User", "User")
|
||||
.WithMany("PushDevices")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MiaoJiZhang.Domain.Entities.Transaction", b =>
|
||||
{
|
||||
b.HasOne("MiaoJiZhang.Domain.Entities.Category", "Category")
|
||||
@@ -605,6 +982,17 @@ namespace MiaoJiZhang.Infrastructure.Persistence.Migrations
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MiaoJiZhang.Domain.Entities.UserPushPreference", b =>
|
||||
{
|
||||
b.HasOne("MiaoJiZhang.Domain.Entities.User", "User")
|
||||
.WithMany("PushPreferences")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MiaoJiZhang.Domain.Entities.Ledger", b =>
|
||||
{
|
||||
b.Navigation("Budgets");
|
||||
@@ -612,6 +1000,16 @@ namespace MiaoJiZhang.Infrastructure.Persistence.Migrations
|
||||
b.Navigation("Transactions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MiaoJiZhang.Domain.Entities.PushDevice", b =>
|
||||
{
|
||||
b.Navigation("Deliveries");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MiaoJiZhang.Domain.Entities.PushMessage", b =>
|
||||
{
|
||||
b.Navigation("Deliveries");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MiaoJiZhang.Domain.Entities.User", b =>
|
||||
{
|
||||
b.Navigation("AiCompanion");
|
||||
@@ -619,9 +1017,12 @@ namespace MiaoJiZhang.Infrastructure.Persistence.Migrations
|
||||
b.Navigation("FeaturePermissions");
|
||||
|
||||
b.Navigation("Ledgers");
|
||||
|
||||
b.Navigation("PushDevices");
|
||||
|
||||
b.Navigation("PushPreferences");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user