DocSpace-client/migrations/mysql/WebhooksDbContext/20220818144209_WebhooksDbContext_Upgrade1.cs

152 lines
5.0 KiB
C#
Raw Normal View History

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ASC.Migrations.MySql.Migrations.WebhooksDb
{
public partial class WebhooksDbContext_Upgrade1 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
2022-08-18 13:41:53 +00:00
migrationBuilder.RenameColumn(
name: "config_id",
table: "webhooks_config",
newName: "id");
migrationBuilder.UpdateData(
table: "webhooks_logs",
keyColumn: "uid",
keyValue: null,
column: "uid",
value: "");
migrationBuilder.AlterColumn<string>(
name: "uid",
table: "webhooks_logs",
type: "varchar(36)",
nullable: false,
collation: "utf8_general_ci",
oldClrType: typeof(string),
oldType: "varchar(50)",
oldMaxLength: 50,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8")
.OldAnnotation("MySql:CharSet", "utf8");
migrationBuilder.AlterColumn<int>(
name: "status",
table: "webhooks_logs",
type: "int",
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(50)",
oldMaxLength: 50)
.OldAnnotation("MySql:CharSet", "utf8");
migrationBuilder.AddColumn<DateTime>(
name: "delivery",
table: "webhooks_logs",
type: "datetime",
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "enabled",
table: "webhooks_config",
type: "tinyint(1)",
nullable: false,
defaultValueSql: "'1'");
2022-08-18 13:41:53 +00:00
migrationBuilder.AddColumn<string>(
name: "name",
table: "webhooks_config",
type: "varchar(50)",
maxLength: 50,
nullable: false,
defaultValue: "")
.Annotation("MySql:CharSet", "utf8");
2022-08-18 19:06:51 +00:00
migrationBuilder.CreateIndex(
name: "IX_webhooks_logs_config_id",
table: "webhooks_logs",
column: "config_id");
migrationBuilder.CreateIndex(
name: "tenant_id",
table: "webhooks_logs",
column: "tenant_id");
migrationBuilder.CreateIndex(
name: "tenant_id",
table: "webhooks_config",
column: "tenant_id");
migrationBuilder.AddForeignKey(
name: "FK_webhooks_logs_webhooks_config_config_id",
table: "webhooks_logs",
column: "config_id",
principalTable: "webhooks_config",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
2022-08-18 19:06:51 +00:00
migrationBuilder.DropForeignKey(
name: "FK_webhooks_logs_webhooks_config_config_id",
table: "webhooks_logs");
migrationBuilder.DropIndex(
name: "IX_webhooks_logs_config_id",
table: "webhooks_logs");
migrationBuilder.DropIndex(
name: "tenant_id",
table: "webhooks_logs");
migrationBuilder.DropIndex(
name: "tenant_id",
table: "webhooks_config");
migrationBuilder.DropColumn(
name: "delivery",
table: "webhooks_logs");
migrationBuilder.DropColumn(
name: "enabled",
table: "webhooks_config");
2022-08-18 13:41:53 +00:00
migrationBuilder.DropColumn(
name: "name",
table: "webhooks_config");
migrationBuilder.RenameColumn(
name: "id",
table: "webhooks_config",
newName: "config_id");
migrationBuilder.AlterColumn<string>(
name: "uid",
table: "webhooks_logs",
type: "varchar(50)",
maxLength: 50,
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(36)",
oldCollation: "utf8_general_ci")
.Annotation("MySql:CharSet", "utf8")
.OldAnnotation("MySql:CharSet", "utf8");
migrationBuilder.AlterColumn<string>(
name: "status",
table: "webhooks_logs",
type: "varchar(50)",
maxLength: 50,
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.Annotation("MySql:CharSet", "utf8");
}
}
}