yavsc/src/Yavsc.Org/Migrations/20261007011348_ResourceUsageRecords.cs

53 lines
2.6 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Yavsc.Migrations
{
/// <inheritdoc />
public partial class ResourceUsageRecords : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ResourceUsageRecords",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
UserId = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
UserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
RecordedAtUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
ApiCalls = table.Column<decimal>(type: "numeric", nullable: false),
CpuSeconds = table.Column<decimal>(type: "numeric", nullable: false),
BandwidthMb = table.Column<decimal>(type: "numeric", nullable: false),
StorageMb = table.Column<decimal>(type: "numeric", nullable: false),
EstimatedCompensation = table.Column<decimal>(type: "numeric", nullable: false),
Currency = table.Column<string>(type: "character varying(8)", maxLength: 8, nullable: false, defaultValue: "EUR"),
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UserCreated = table.Column<string>(type: "text", nullable: true),
DateModified = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UserModified = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ResourceUsageRecords", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_ResourceUsageRecords_UserId_RecordedAtUtc",
table: "ResourceUsageRecords",
columns: new[] { "UserId", "RecordedAtUtc" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ResourceUsageRecords");
}
}
}