using DysonNetwork.Shared.Models;
using Microsoft.EntityFrameworkCore.Migrations;
using NodaTime;
#nullable disable
namespace DysonNetwork.Drive.Migrations
{
    /// 
    public partial class InitialMigration : Migration
    {
        /// 
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterDatabase()
                .Annotation("Npgsql:PostgresExtension:postgis", ",,");
            migrationBuilder.CreateTable(
                name: "files",
                columns: table => new
                {
                    id = table.Column(type: "character varying(32)", maxLength: 32, nullable: false),
                    name = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false),
                    description = table.Column(type: "character varying(4096)", maxLength: 4096, nullable: true),
                    file_meta = table.Column>(type: "jsonb", nullable: true),
                    user_meta = table.Column>(type: "jsonb", nullable: true),
                    sensitive_marks = table.Column>(type: "jsonb", nullable: true),
                    mime_type = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
                    hash = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
                    size = table.Column(type: "bigint", nullable: false),
                    uploaded_at = table.Column(type: "timestamp with time zone", nullable: true),
                    uploaded_to = table.Column(type: "character varying(128)", maxLength: 128, nullable: true),
                    has_compression = table.Column(type: "boolean", nullable: false),
                    is_marked_recycle = table.Column(type: "boolean", nullable: false),
                    storage_id = table.Column(type: "character varying(32)", maxLength: 32, nullable: true),
                    storage_url = table.Column(type: "character varying(4096)", maxLength: 4096, nullable: true),
                    account_id = table.Column(type: "uuid", nullable: false),
                    created_at = table.Column(type: "timestamp with time zone", nullable: false),
                    updated_at = table.Column(type: "timestamp with time zone", nullable: false),
                    deleted_at = table.Column(type: "timestamp with time zone", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("pk_files", x => x.id);
                });
            migrationBuilder.CreateTable(
                name: "file_references",
                columns: table => new
                {
                    id = table.Column(type: "uuid", nullable: false),
                    file_id = table.Column(type: "character varying(32)", maxLength: 32, nullable: false),
                    usage = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false),
                    resource_id = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false),
                    expired_at = table.Column(type: "timestamp with time zone", nullable: true),
                    created_at = table.Column(type: "timestamp with time zone", nullable: false),
                    updated_at = table.Column(type: "timestamp with time zone", nullable: false),
                    deleted_at = table.Column(type: "timestamp with time zone", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("pk_file_references", x => x.id);
                    table.ForeignKey(
                        name: "fk_file_references_files_file_id",
                        column: x => x.file_id,
                        principalTable: "files",
                        principalColumn: "id",
                        onDelete: ReferentialAction.Cascade);
                });
            migrationBuilder.CreateIndex(
                name: "ix_file_references_file_id",
                table: "file_references",
                column: "file_id");
        }
        /// 
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "file_references");
            migrationBuilder.DropTable(
                name: "files");
        }
    }
}