DocSpace-buildtools/migrations/mysql/BackupsContext/20230130103901_BackupsContextMigrate.cs
2023-01-30 13:41:25 +03:00

163 lines
9.2 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ASC.Migrations.MySql.Migrations.Backups
{
/// <inheritdoc />
public partial class BackupsContextMigrate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterDatabase()
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "backup_backup",
columns: table => new
{
id = table.Column<string>(type: "char(38)", nullable: false, collation: "utf8_general_ci")
.Annotation("MySql:CharSet", "utf8"),
tenantid = table.Column<int>(name: "tenant_id", type: "int(10)", nullable: false),
isscheduled = table.Column<bool>(name: "is_scheduled", type: "tinyint(1)", nullable: false),
name = table.Column<string>(type: "varchar(255)", nullable: false, collation: "utf8_general_ci")
.Annotation("MySql:CharSet", "utf8"),
hash = table.Column<string>(type: "varchar(64)", nullable: false, collation: "utf8_general_ci")
.Annotation("MySql:CharSet", "utf8"),
storagetype = table.Column<int>(name: "storage_type", type: "int(10)", nullable: false),
storagebasepath = table.Column<string>(name: "storage_base_path", type: "varchar(255)", nullable: true, defaultValueSql: "NULL", collation: "utf8_general_ci")
.Annotation("MySql:CharSet", "utf8"),
storagepath = table.Column<string>(name: "storage_path", type: "varchar(255)", nullable: false, collation: "utf8_general_ci")
.Annotation("MySql:CharSet", "utf8"),
createdon = table.Column<DateTime>(name: "created_on", type: "datetime", nullable: false),
expireson = table.Column<DateTime>(name: "expires_on", type: "datetime", nullable: false, defaultValueSql: "'0001-01-01 00:00:00'"),
storageparams = table.Column<string>(name: "storage_params", type: "text", nullable: true, defaultValueSql: "NULL", collation: "utf8_general_ci")
.Annotation("MySql:CharSet", "utf8"),
removed = table.Column<bool>(type: "tinyint(1)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PRIMARY", x => x.id);
})
.Annotation("MySql:CharSet", "utf8");
migrationBuilder.CreateTable(
name: "backup_schedule",
columns: table => new
{
tenantid = table.Column<int>(name: "tenant_id", type: "int(10)", nullable: false),
cron = table.Column<string>(type: "varchar(255)", nullable: false, collation: "utf8_general_ci")
.Annotation("MySql:CharSet", "utf8"),
backupsstored = table.Column<int>(name: "backups_stored", type: "int(10)", nullable: false),
storagetype = table.Column<int>(name: "storage_type", type: "int(10)", nullable: false),
storagebasepath = table.Column<string>(name: "storage_base_path", type: "varchar(255)", nullable: true, defaultValueSql: "NULL", collation: "utf8_general_ci")
.Annotation("MySql:CharSet", "utf8"),
lastbackuptime = table.Column<DateTime>(name: "last_backup_time", type: "datetime", nullable: false),
storageparams = table.Column<string>(name: "storage_params", type: "text", nullable: true, defaultValueSql: "NULL", collation: "utf8_general_ci")
.Annotation("MySql:CharSet", "utf8")
},
constraints: table =>
{
table.PrimaryKey("PRIMARY", x => x.tenantid);
})
.Annotation("MySql:CharSet", "utf8");
migrationBuilder.CreateTable(
name: "tenants_tenants",
columns: table => new
{
id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
name = table.Column<string>(type: "varchar(255)", nullable: false, collation: "utf8_general_ci")
.Annotation("MySql:CharSet", "utf8"),
alias = table.Column<string>(type: "varchar(100)", nullable: false, collation: "utf8_general_ci")
.Annotation("MySql:CharSet", "utf8"),
mappeddomain = table.Column<string>(type: "varchar(100)", nullable: true, collation: "utf8_general_ci")
.Annotation("MySql:CharSet", "utf8"),
version = table.Column<int>(type: "int", nullable: false, defaultValueSql: "'2'"),
versionchanged = table.Column<DateTime>(name: "version_changed", type: "datetime", nullable: true),
language = table.Column<string>(type: "char(10)", nullable: false, defaultValueSql: "'en-US'", collation: "utf8_general_ci")
.Annotation("MySql:CharSet", "utf8"),
timezone = table.Column<string>(type: "varchar(50)", nullable: true, collation: "utf8_general_ci")
.Annotation("MySql:CharSet", "utf8"),
trusteddomains = table.Column<string>(type: "varchar(1024)", nullable: true, collation: "utf8_general_ci")
.Annotation("MySql:CharSet", "utf8"),
trusteddomainsenabled = table.Column<int>(type: "int", nullable: false, defaultValueSql: "'1'"),
status = table.Column<int>(type: "int", nullable: false, defaultValueSql: "'0'"),
statuschanged = table.Column<DateTime>(type: "datetime", nullable: true),
creationdatetime = table.Column<DateTime>(type: "datetime", nullable: false),
ownerid = table.Column<string>(name: "owner_id", type: "varchar(38)", nullable: true, collation: "utf8_general_ci")
.Annotation("MySql:CharSet", "utf8"),
paymentid = table.Column<string>(name: "payment_id", type: "varchar(38)", nullable: true, collation: "utf8_general_ci")
.Annotation("MySql:CharSet", "utf8"),
industry = table.Column<int>(type: "int", nullable: false, defaultValueSql: "'0'"),
lastmodified = table.Column<DateTime>(name: "last_modified", type: "timestamp", nullable: false),
spam = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValueSql: "'1'"),
calls = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValueSql: "'1'")
},
constraints: table =>
{
table.PrimaryKey("PK_tenants_tenants", x => x.id);
})
.Annotation("MySql:CharSet", "utf8");
migrationBuilder.InsertData(
table: "tenants_tenants",
columns: new[] { "id", "alias", "creationdatetime", "last_modified", "mappeddomain", "name", "owner_id", "payment_id", "statuschanged", "timezone", "trusteddomains", "version_changed" },
values: new object[] { 1, "localhost", new DateTime(2021, 3, 9, 17, 46, 59, 97, DateTimeKind.Utc).AddTicks(4317), new DateTime(2022, 7, 8, 0, 0, 0, 0, DateTimeKind.Unspecified), null, "Web Office", "66faa6e4-f133-11ea-b126-00ffeec8b4ef", null, null, null, null, null });
migrationBuilder.CreateIndex(
name: "expires_on",
table: "backup_backup",
column: "expires_on");
migrationBuilder.CreateIndex(
name: "is_scheduled",
table: "backup_backup",
column: "is_scheduled");
migrationBuilder.CreateIndex(
name: "tenant_id",
table: "backup_backup",
column: "tenant_id");
migrationBuilder.CreateIndex(
name: "alias",
table: "tenants_tenants",
column: "alias",
unique: true);
migrationBuilder.CreateIndex(
name: "last_modified",
table: "tenants_tenants",
column: "last_modified");
migrationBuilder.CreateIndex(
name: "mappeddomain",
table: "tenants_tenants",
column: "mappeddomain");
migrationBuilder.CreateIndex(
name: "version",
table: "tenants_tenants",
column: "version");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "backup_backup");
migrationBuilder.DropTable(
name: "backup_schedule");
migrationBuilder.DropTable(
name: "tenants_tenants");
}
}
}