DocSpace-buildtools/migrations/postgre/CoreDbContext/20220724114546_CoreDbContextMigrate.cs

133 lines
6.8 KiB
C#

// (c) Copyright Ascensio System SIA 2010-2022
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace ASC.Migrations.PostgreSql.Migrations
{
public partial class CoreDbContextMigrate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "onlyoffice");
migrationBuilder.CreateTable(
name: "tenants_quota",
schema: "onlyoffice",
columns: table => new
{
tenant = table.Column<int>(type: "integer", nullable: false),
name = table.Column<string>(type: "character varying", nullable: true),
description = table.Column<string>(type: "character varying", nullable: true),
max_file_size = table.Column<long>(type: "bigint", nullable: false, defaultValueSql: "'0'"),
max_total_size = table.Column<long>(type: "bigint", nullable: false, defaultValueSql: "'0'"),
active_users = table.Column<int>(type: "integer", nullable: false),
features = table.Column<string>(type: "text", nullable: true),
price = table.Column<decimal>(type: "numeric(10,2)", nullable: false, defaultValueSql: "0.00"),
avangate_id = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true, defaultValueSql: "NULL"),
visible = table.Column<bool>(type: "boolean", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("tenants_quota_pkey", x => x.tenant);
});
migrationBuilder.CreateTable(
name: "tenants_quotarow",
schema: "onlyoffice",
columns: table => new
{
tenant = table.Column<int>(type: "integer", nullable: false),
path = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
counter = table.Column<long>(type: "bigint", nullable: false, defaultValueSql: "'0'"),
tag = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: true, defaultValueSql: "'0'"),
last_modified = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP")
},
constraints: table =>
{
table.PrimaryKey("tenants_quotarow_pkey", x => new { x.tenant, x.path });
});
migrationBuilder.CreateTable(
name: "tenants_tariff",
schema: "onlyoffice",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
tenant = table.Column<int>(type: "integer", nullable: false),
tariff = table.Column<int>(type: "integer", nullable: false),
stamp = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
quantity = table.Column<int>(type: "integer", nullable: false),
comment = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true, defaultValueSql: "NULL"),
create_on = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP")
},
constraints: table =>
{
table.PrimaryKey("PK_tenants_tariff", x => x.id);
});
migrationBuilder.InsertData(
schema: "onlyoffice",
table: "tenants_quota",
columns: new[] { "tenant", "active_users", "avangate_id", "description", "features", "max_file_size", "max_total_size", "name", "visible" },
values: new object[] { -1, 10000, "0", null, "domain,audit,controlpanel,healthcheck,ldap,sso,whitelabel,branding,ssbranding,update,support,portals:10000,discencryption,privacyroom,restore", 102400L, 10995116277760L, "default", false });
migrationBuilder.CreateIndex(
name: "last_modified_tenants_quotarow",
schema: "onlyoffice",
table: "tenants_quotarow",
column: "last_modified");
migrationBuilder.CreateIndex(
name: "tenant_tenants_tariff",
schema: "onlyoffice",
table: "tenants_tariff",
column: "tenant");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "tenants_quota",
schema: "onlyoffice");
migrationBuilder.DropTable(
name: "tenants_quotarow",
schema: "onlyoffice");
migrationBuilder.DropTable(
name: "tenants_tariff",
schema: "onlyoffice");
}
}
}