151 lines
8.7 KiB
C#
151 lines
8.7 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace ASC.Migrations.PostgreSql.Migrations.Backups
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class BackupsContextMigrate : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.EnsureSchema(
|
|
name: "onlyoffice");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "backup_backup",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<Guid>(type: "char", maxLength: 38, nullable: false, collation: "utf8_general_ci"),
|
|
tenantid = table.Column<int>(name: "tenant_id", type: "int", maxLength: 10, nullable: false),
|
|
isscheduled = table.Column<int>(name: "is_scheduled", type: "int", maxLength: 10, nullable: false),
|
|
name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false, collation: "utf8_general_ci"),
|
|
hash = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false, collation: "utf8_general_ci"),
|
|
storagetype = table.Column<int>(name: "storage_type", type: "int", maxLength: 10, nullable: false),
|
|
storagebasepath = table.Column<string>(name: "storage_base_path", type: "character varying(255)", maxLength: 255, nullable: true, defaultValueSql: "NULL", collation: "utf8_general_ci"),
|
|
storagepath = table.Column<string>(name: "storage_path", type: "character varying(255)", maxLength: 255, nullable: false, collation: "utf8_general_ci"),
|
|
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"),
|
|
removed = table.Column<int>(type: "int", maxLength: 10, nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PRIMARY", x => x.id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "backup_schedule",
|
|
columns: table => new
|
|
{
|
|
tenantid = table.Column<int>(name: "tenant_id", type: "integer", maxLength: 10, nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
cron = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false, collation: "utf8_general_ci"),
|
|
backupsstored = table.Column<int>(name: "backups_stored", type: "integer", maxLength: 10, nullable: false),
|
|
storagetype = table.Column<int>(name: "storage_type", type: "integer", maxLength: 10, nullable: false),
|
|
storagebasepath = table.Column<string>(name: "storage_base_path", type: "character varying(255)", maxLength: 255, nullable: true, defaultValueSql: "NULL", collation: "utf8_general_ci"),
|
|
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")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PRIMARY", x => x.tenantid);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "tenants_tenants",
|
|
schema: "onlyoffice",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
|
alias = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
mappeddomain = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true, defaultValueSql: "NULL"),
|
|
version = table.Column<int>(type: "integer", nullable: false, defaultValueSql: "2"),
|
|
versionchanged = table.Column<DateTime>(name: "version_changed", type: "timestamp with time zone", nullable: true),
|
|
language = table.Column<string>(type: "character(10)", fixedLength: true, maxLength: 10, nullable: false, defaultValueSql: "'en-US'"),
|
|
timezone = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true, defaultValueSql: "NULL"),
|
|
trusteddomains = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: true, defaultValueSql: "NULL"),
|
|
trusteddomainsenabled = table.Column<int>(type: "integer", nullable: false, defaultValueSql: "1"),
|
|
status = table.Column<int>(type: "integer", nullable: false),
|
|
statuschanged = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
creationdatetime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
ownerid = table.Column<Guid>(name: "owner_id", type: "uuid", maxLength: 38, nullable: true, defaultValueSql: "NULL"),
|
|
paymentid = table.Column<string>(name: "payment_id", type: "character varying(38)", maxLength: 38, nullable: true, defaultValueSql: "NULL"),
|
|
industry = table.Column<int>(type: "integer", nullable: false),
|
|
lastmodified = table.Column<DateTime>(name: "last_modified", type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"),
|
|
spam = table.Column<bool>(type: "boolean", nullable: false, defaultValueSql: "true"),
|
|
calls = table.Column<bool>(type: "boolean", nullable: false, defaultValueSql: "true")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_tenants_tenants", x => x.id);
|
|
});
|
|
|
|
migrationBuilder.InsertData(
|
|
schema: "onlyoffice",
|
|
table: "tenants_tenants",
|
|
columns: new[] { "id", "alias", "creationdatetime", "industry", "last_modified", "name", "owner_id", "status", "statuschanged", "version_changed" },
|
|
values: new object[] { 1, "localhost", new DateTime(2021, 3, 9, 17, 46, 59, 97, DateTimeKind.Utc).AddTicks(4317), 0, new DateTime(2022, 7, 8, 0, 0, 0, 0, DateTimeKind.Unspecified), "Web Office", new Guid("66faa6e4-f133-11ea-b126-00ffeec8b4ef"), 0, 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",
|
|
schema: "onlyoffice",
|
|
table: "tenants_tenants",
|
|
column: "alias",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "last_modified_tenants_tenants",
|
|
schema: "onlyoffice",
|
|
table: "tenants_tenants",
|
|
column: "last_modified");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "mappeddomain",
|
|
schema: "onlyoffice",
|
|
table: "tenants_tenants",
|
|
column: "mappeddomain");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "version",
|
|
schema: "onlyoffice",
|
|
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",
|
|
schema: "onlyoffice");
|
|
}
|
|
}
|
|
}
|