using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Moonlight.ApiServer.Database.Migrations
{
///
public partial class AddedTickerQ : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "ticker");
migrationBuilder.CreateTable(
name: "CronTickers",
schema: "ticker",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Expression = table.Column(type: "text", nullable: true),
Request = table.Column(type: "bytea", nullable: true),
Retries = table.Column(type: "integer", nullable: false),
RetryIntervals = table.Column(type: "integer[]", nullable: true),
Function = table.Column(type: "text", nullable: true),
Description = table.Column(type: "text", nullable: true),
InitIdentifier = table.Column(type: "text", nullable: true),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CronTickers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "TimeTickers",
schema: "ticker",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Status = table.Column(type: "integer", nullable: false),
LockHolder = table.Column(type: "text", nullable: true),
Request = table.Column(type: "bytea", nullable: true),
ExecutionTime = table.Column(type: "timestamp with time zone", nullable: false),
LockedAt = table.Column(type: "timestamp with time zone", nullable: true),
ExecutedAt = table.Column(type: "timestamp with time zone", nullable: true),
Exception = table.Column(type: "text", nullable: true),
ElapsedTime = table.Column(type: "bigint", nullable: false),
Retries = table.Column(type: "integer", nullable: false),
RetryCount = table.Column(type: "integer", nullable: false),
RetryIntervals = table.Column(type: "integer[]", nullable: true),
BatchParent = table.Column(type: "uuid", nullable: true),
BatchRunCondition = table.Column(type: "integer", nullable: true),
Function = table.Column(type: "text", nullable: true),
Description = table.Column(type: "text", nullable: true),
InitIdentifier = table.Column(type: "text", nullable: true),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TimeTickers", x => x.Id);
table.ForeignKey(
name: "FK_TimeTickers_TimeTickers_BatchParent",
column: x => x.BatchParent,
principalSchema: "ticker",
principalTable: "TimeTickers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "CronTickerOccurrences",
schema: "ticker",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Status = table.Column(type: "integer", nullable: false),
LockHolder = table.Column(type: "text", nullable: true),
ExecutionTime = table.Column(type: "timestamp with time zone", nullable: false),
CronTickerId = table.Column(type: "uuid", nullable: false),
LockedAt = table.Column(type: "timestamp with time zone", nullable: true),
ExecutedAt = table.Column(type: "timestamp with time zone", nullable: true),
Exception = table.Column(type: "text", nullable: true),
ElapsedTime = table.Column(type: "bigint", nullable: false),
RetryCount = table.Column(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CronTickerOccurrences", x => x.Id);
table.ForeignKey(
name: "FK_CronTickerOccurrences_CronTickers_CronTickerId",
column: x => x.CronTickerId,
principalSchema: "ticker",
principalTable: "CronTickers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_CronTickerOccurrence_CronTickerId",
schema: "ticker",
table: "CronTickerOccurrences",
column: "CronTickerId");
migrationBuilder.CreateIndex(
name: "IX_CronTickerOccurrence_ExecutionTime",
schema: "ticker",
table: "CronTickerOccurrences",
column: "ExecutionTime");
migrationBuilder.CreateIndex(
name: "IX_CronTickerOccurrence_Status_ExecutionTime",
schema: "ticker",
table: "CronTickerOccurrences",
columns: new[] { "Status", "ExecutionTime" });
migrationBuilder.CreateIndex(
name: "UQ_CronTickerId_ExecutionTime",
schema: "ticker",
table: "CronTickerOccurrences",
columns: new[] { "CronTickerId", "ExecutionTime" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_CronTickers_Expression",
schema: "ticker",
table: "CronTickers",
column: "Expression");
migrationBuilder.CreateIndex(
name: "IX_TimeTicker_ExecutionTime",
schema: "ticker",
table: "TimeTickers",
column: "ExecutionTime");
migrationBuilder.CreateIndex(
name: "IX_TimeTicker_Status_ExecutionTime",
schema: "ticker",
table: "TimeTickers",
columns: new[] { "Status", "ExecutionTime" });
migrationBuilder.CreateIndex(
name: "IX_TimeTickers_BatchParent",
schema: "ticker",
table: "TimeTickers",
column: "BatchParent");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CronTickerOccurrences",
schema: "ticker");
migrationBuilder.DropTable(
name: "TimeTickers",
schema: "ticker");
migrationBuilder.DropTable(
name: "CronTickers",
schema: "ticker");
}
}
}