60 lines
2.8 KiB
C#
60 lines
2.8 KiB
C#
using System.Collections.Generic;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using NodaTime;
|
|
|
|
#nullable disable
|
|
|
|
namespace DysonNetwork.Sphere.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddCloudFiles : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "files",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<string>(type: "text", nullable: false),
|
|
name = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: false),
|
|
description = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: true),
|
|
file_meta = table.Column<Dictionary<string, object>>(type: "jsonb", nullable: true),
|
|
user_meta = table.Column<Dictionary<string, object>>(type: "jsonb", nullable: true),
|
|
mime_type = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
hash = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
size = table.Column<long>(type: "bigint", nullable: false),
|
|
uploaded_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
|
|
uploaded_to = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
|
used_count = table.Column<int>(type: "integer", nullable: false),
|
|
account_id = table.Column<long>(type: "bigint", nullable: false),
|
|
created_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
|
|
updated_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
|
|
deleted_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("pk_files", x => x.id);
|
|
table.ForeignKey(
|
|
name: "fk_files_accounts_account_id",
|
|
column: x => x.account_id,
|
|
principalTable: "accounts",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "ix_files_account_id",
|
|
table: "files",
|
|
column: "account_id");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "files");
|
|
}
|
|
}
|
|
}
|