71 lines
2.5 KiB
C#
71 lines
2.5 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace ClaudeDo.Data.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class SplitUsageThrottlePerBucket : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.RenameColumn(
|
|
name: "usage_throttle_soft_pct",
|
|
table: "app_settings",
|
|
newName: "usage_throttle_seven_day_soft_pct");
|
|
|
|
migrationBuilder.RenameColumn(
|
|
name: "usage_throttle_hard_pct",
|
|
table: "app_settings",
|
|
newName: "usage_throttle_seven_day_hard_pct");
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "usage_throttle_five_hour_hard_pct",
|
|
table: "app_settings",
|
|
type: "INTEGER",
|
|
nullable: false,
|
|
defaultValue: 65);
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "usage_throttle_five_hour_soft_pct",
|
|
table: "app_settings",
|
|
type: "INTEGER",
|
|
nullable: false,
|
|
defaultValue: 50);
|
|
|
|
// The old single soft/hard pair was compared against whichever bucket was more utilized,
|
|
// so carrying it into BOTH buckets keeps an existing install behaving exactly as before
|
|
// the split — the rename above already preserved it for the 7d side.
|
|
migrationBuilder.Sql(
|
|
"""
|
|
UPDATE app_settings
|
|
SET usage_throttle_five_hour_soft_pct = usage_throttle_seven_day_soft_pct,
|
|
usage_throttle_five_hour_hard_pct = usage_throttle_seven_day_hard_pct;
|
|
""");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropColumn(
|
|
name: "usage_throttle_five_hour_hard_pct",
|
|
table: "app_settings");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "usage_throttle_five_hour_soft_pct",
|
|
table: "app_settings");
|
|
|
|
migrationBuilder.RenameColumn(
|
|
name: "usage_throttle_seven_day_soft_pct",
|
|
table: "app_settings",
|
|
newName: "usage_throttle_soft_pct");
|
|
|
|
migrationBuilder.RenameColumn(
|
|
name: "usage_throttle_seven_day_hard_pct",
|
|
table: "app_settings",
|
|
newName: "usage_throttle_hard_pct");
|
|
}
|
|
}
|
|
}
|