﻿// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Pokegraf.Persistence.Context;

namespace Pokegraf.Persistence.Migration.Migrations
{
    [DbContext(typeof(PokegrafDbContext))]
    [Migration("20200318152055_InitialMigrationV2")]
    partial class InitialMigrationV2
    {
        protected override void BuildTargetModel(ModelBuilder modelBuilder)
        {
#pragma warning disable 612, 618
            modelBuilder
                .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn)
                .HasAnnotation("ProductVersion", "3.1.2")
                .HasAnnotation("Relational:MaxIdentifierLength", 63);

            modelBuilder.Entity("Navigator.Extensions.Store.Entity.Chat", b =>
                {
                    b.Property<long>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("bigint")
                        .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);

                    b.Property<DateTime>("CreatedAt")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("timestamp without time zone")
                        .HasDefaultValueSql("CURRENT_TIMESTAMP");

                    b.Property<string>("Title")
                        .HasColumnType("text");

                    b.Property<int>("Type")
                        .HasColumnType("integer");

                    b.Property<string>("Username")
                        .HasColumnType("text");

                    b.HasKey("Id");

                    b.ToTable("Chats");
                });

            modelBuilder.Entity("Navigator.Extensions.Store.Entity.Conversation", b =>
                {
                    b.Property<long>("ChatId")
                        .HasColumnType("bigint");

                    b.Property<int>("UserId")
                        .HasColumnType("integer");

                    b.Property<DateTime>("CreatedAt")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("timestamp without time zone")
                        .HasDefaultValueSql("CURRENT_TIMESTAMP");

                    b.HasKey("ChatId", "UserId");

                    b.HasIndex("UserId");

                    b.ToTable("Conversations");
                });

            modelBuilder.Entity("Navigator.Extensions.Store.Entity.User", b =>
                {
                    b.Property<int>("Id")
                        .HasColumnType("integer");

                    b.Property<DateTime>("CreatedAt")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("timestamp without time zone")
                        .HasDefaultValueSql("CURRENT_TIMESTAMP");

                    b.Property<string>("Discriminator")
                        .IsRequired()
                        .HasColumnType("text");

                    b.Property<bool>("IsBot")
                        .HasColumnType("boolean");

                    b.Property<string>("LanguageCode")
                        .HasColumnType("text");

                    b.Property<string>("Username")
                        .HasColumnType("text");

                    b.HasKey("Id");

                    b.ToTable("User");

                    b.HasDiscriminator<string>("Discriminator").HasValue("User");
                });

            modelBuilder.Entity("Pokegraf.Core.Entity.Stats", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<int>("TrainerId")
                        .HasColumnType("integer");

                    b.HasKey("Id");

                    b.HasIndex("TrainerId")
                        .IsUnique();

                    b.ToTable("Stats");
                });

            modelBuilder.Entity("Pokegraf.Core.Entity.Trainer", b =>
                {
                    b.HasBaseType("Navigator.Extensions.Store.Entity.User");

                    b.Property<string>("TrainerName")
                        .HasColumnType("text");

                    b.HasDiscriminator().HasValue("Trainer");
                });

            modelBuilder.Entity("Navigator.Extensions.Store.Entity.Conversation", b =>
                {
                    b.HasOne("Navigator.Extensions.Store.Entity.Chat", "Chat")
                        .WithMany("Conversations")
                        .HasForeignKey("ChatId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("Navigator.Extensions.Store.Entity.User", "User")
                        .WithMany("Conversations")
                        .HasForeignKey("UserId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();
                });

            modelBuilder.Entity("Pokegraf.Core.Entity.Stats", b =>
                {
                    b.HasOne("Pokegraf.Core.Entity.Trainer", "Trainer")
                        .WithOne("Stats")
                        .HasForeignKey("Pokegraf.Core.Entity.Stats", "TrainerId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.OwnsOne("Pokegraf.Core.Entity.Stats+RequestStats", "Requests", b1 =>
                        {
                            b1.Property<Guid>("StatsId")
                                .HasColumnType("uuid");

                            b1.Property<int>("Fusion")
                                .HasColumnType("integer");

                            b1.Property<Guid>("Id")
                                .HasColumnType("uuid");

                            b1.Property<int>("Pokemon")
                                .HasColumnType("integer");

                            b1.HasKey("StatsId");

                            b1.ToTable("StatsRequests");

                            b1.WithOwner()
                                .HasForeignKey("StatsId");
                        });
                });
#pragma warning restore 612, 618
        }
    }
}
