using Microsoft.EntityFrameworkCore.Migrations;
using NodaTime;
#nullable disable
namespace DysonNetwork.Drive.Migrations
{
    /// 
    public partial class AddFileBundle : Migration
    {
        /// 
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn(
                name: "bundle_id",
                table: "files",
                type: "uuid",
                nullable: true);
            migrationBuilder.CreateTable(
                name: "bundles",
                columns: table => new
                {
                    id = table.Column(type: "uuid", nullable: false),
                    slug = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false),
                    name = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false),
                    description = table.Column(type: "character varying(8192)", maxLength: 8192, nullable: true),
                    passcode = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
                    expired_at = table.Column(type: "timestamp with time zone", 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_bundles", x => x.id);
                });
            migrationBuilder.CreateIndex(
                name: "ix_files_bundle_id",
                table: "files",
                column: "bundle_id");
            migrationBuilder.CreateIndex(
                name: "ix_bundles_slug",
                table: "bundles",
                column: "slug",
                unique: true);
            migrationBuilder.AddForeignKey(
                name: "fk_files_bundles_bundle_id",
                table: "files",
                column: "bundle_id",
                principalTable: "bundles",
                principalColumn: "id");
        }
        /// 
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "fk_files_bundles_bundle_id",
                table: "files");
            migrationBuilder.DropTable(
                name: "bundles");
            migrationBuilder.DropIndex(
                name: "ix_files_bundle_id",
                table: "files");
            migrationBuilder.DropColumn(
                name: "bundle_id",
                table: "files");
        }
    }
}