2022-10-19 14:46:47 +00:00
|
|
|
using System;
|
|
|
|
using Microsoft.EntityFrameworkCore.Metadata;
|
|
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
|
|
|
|
#nullable disable
|
|
|
|
|
|
|
|
namespace ASC.Migrations.MySql.Migrations
|
|
|
|
{
|
|
|
|
public partial class WebhooksDbContextMigrate : Migration
|
|
|
|
{
|
|
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
|
|
{
|
|
|
|
migrationBuilder.AlterDatabase()
|
|
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
name: "webhooks_config",
|
|
|
|
columns: table => new
|
|
|
|
{
|
|
|
|
id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
|
|
name = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
|
|
|
|
.Annotation("MySql:CharSet", "utf8"),
|
|
|
|
secret_key = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, defaultValueSql: "''")
|
|
|
|
.Annotation("MySql:CharSet", "utf8"),
|
|
|
|
tenant_id = table.Column<uint>(type: "int unsigned", nullable: false),
|
|
|
|
uri = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, defaultValueSql: "''")
|
|
|
|
.Annotation("MySql:CharSet", "utf8"),
|
|
|
|
enabled = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValueSql: "'1'")
|
|
|
|
},
|
|
|
|
constraints: table =>
|
|
|
|
{
|
|
|
|
table.PrimaryKey("PRIMARY", x => x.id);
|
|
|
|
})
|
|
|
|
.Annotation("MySql:CharSet", "utf8");
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
name: "webhooks_logs",
|
|
|
|
columns: table => new
|
|
|
|
{
|
|
|
|
id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
|
|
config_id = table.Column<int>(type: "int", nullable: false),
|
|
|
|
creation_time = table.Column<DateTime>(type: "datetime", nullable: false),
|
|
|
|
method = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
|
|
|
|
.Annotation("MySql:CharSet", "utf8"),
|
|
|
|
route = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
|
|
|
|
.Annotation("MySql:CharSet", "utf8"),
|
|
|
|
request_headers = table.Column<string>(type: "json", nullable: true)
|
|
|
|
.Annotation("MySql:CharSet", "utf8"),
|
|
|
|
request_payload = table.Column<string>(type: "text", nullable: false, collation: "utf8_general_ci")
|
|
|
|
.Annotation("MySql:CharSet", "utf8"),
|
|
|
|
response_headers = table.Column<string>(type: "json", nullable: true)
|
|
|
|
.Annotation("MySql:CharSet", "utf8"),
|
|
|
|
response_payload = table.Column<string>(type: "text", nullable: true, collation: "utf8_general_ci")
|
|
|
|
.Annotation("MySql:CharSet", "utf8"),
|
|
|
|
status = table.Column<int>(type: "int", nullable: false),
|
|
|
|
tenant_id = table.Column<uint>(type: "int unsigned", nullable: false),
|
|
|
|
uid = table.Column<string>(type: "varchar(36)", nullable: false, collation: "utf8_general_ci")
|
|
|
|
.Annotation("MySql:CharSet", "utf8"),
|
|
|
|
delivery = table.Column<DateTime>(type: "datetime", nullable: true)
|
|
|
|
},
|
|
|
|
constraints: table =>
|
|
|
|
{
|
|
|
|
table.PrimaryKey("PRIMARY", x => x.id);
|
|
|
|
table.ForeignKey(
|
|
|
|
name: "FK_webhooks_logs_webhooks_config_config_id",
|
|
|
|
column: x => x.config_id,
|
|
|
|
principalTable: "webhooks_config",
|
|
|
|
principalColumn: "id",
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
})
|
|
|
|
.Annotation("MySql:CharSet", "utf8");
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
name: "tenant_id",
|
|
|
|
table: "webhooks_config",
|
|
|
|
column: "tenant_id");
|
|
|
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
|
|
{
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
name: "webhooks_logs");
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
name: "webhooks_config");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|