// using System; using Foxchat.Chat.Database; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using NodaTime; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace Foxchat.Chat.Migrations { [DbContext(typeof(ChatContext))] [Migration("20240521132416_Init")] partial class Init { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder .HasAnnotation("ProductVersion", "8.0.5") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("Foxchat.Chat.Database.Models.Channel", b => { b.Property("Id") .HasColumnType("uuid") .HasColumnName("id"); b.Property("GuildId") .HasColumnType("uuid") .HasColumnName("guild_id"); b.Property("Name") .IsRequired() .HasColumnType("text") .HasColumnName("name"); b.Property("Topic") .HasColumnType("text") .HasColumnName("topic"); b.HasKey("Id") .HasName("pk_channels"); b.HasIndex("GuildId") .HasDatabaseName("ix_channels_guild_id"); b.ToTable("channels", (string)null); }); modelBuilder.Entity("Foxchat.Chat.Database.Models.Guild", b => { b.Property("Id") .HasColumnType("uuid") .HasColumnName("id"); b.Property("Name") .IsRequired() .HasColumnType("text") .HasColumnName("name"); b.Property("OwnerId") .HasColumnType("uuid") .HasColumnName("owner_id"); b.HasKey("Id") .HasName("pk_guilds"); b.HasIndex("OwnerId") .HasDatabaseName("ix_guilds_owner_id"); b.ToTable("guilds", (string)null); }); modelBuilder.Entity("Foxchat.Chat.Database.Models.IdentityInstance", b => { b.Property("Id") .HasColumnType("uuid") .HasColumnName("id"); b.Property("BaseUrl") .IsRequired() .HasColumnType("text") .HasColumnName("base_url"); b.Property("Domain") .IsRequired() .HasColumnType("text") .HasColumnName("domain"); b.Property("PublicKey") .IsRequired() .HasColumnType("text") .HasColumnName("public_key"); b.Property("Reason") .HasColumnType("text") .HasColumnName("reason"); b.Property("Status") .HasColumnType("integer") .HasColumnName("status"); b.HasKey("Id") .HasName("pk_identity_instances"); b.HasIndex("Domain") .IsUnique() .HasDatabaseName("ix_identity_instances_domain"); b.ToTable("identity_instances", (string)null); }); modelBuilder.Entity("Foxchat.Chat.Database.Models.Message", b => { b.Property("Id") .HasColumnType("uuid") .HasColumnName("id"); b.Property("AuthorId") .HasColumnType("uuid") .HasColumnName("author_id"); b.Property("ChannelId") .HasColumnType("uuid") .HasColumnName("channel_id"); b.Property("Content") .HasColumnType("text") .HasColumnName("content"); b.Property("UpdatedAt") .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); b.HasKey("Id") .HasName("pk_messages"); b.HasIndex("AuthorId") .HasDatabaseName("ix_messages_author_id"); b.HasIndex("ChannelId") .HasDatabaseName("ix_messages_channel_id"); b.ToTable("messages", (string)null); }); modelBuilder.Entity("Foxchat.Chat.Database.Models.User", b => { b.Property("Id") .HasColumnType("uuid") .HasColumnName("id"); b.Property("Avatar") .HasColumnType("text") .HasColumnName("avatar"); b.Property("InstanceId") .HasColumnType("uuid") .HasColumnName("instance_id"); b.Property("RemoteUserId") .IsRequired() .HasColumnType("text") .HasColumnName("remote_user_id"); b.Property("Username") .IsRequired() .HasColumnType("text") .HasColumnName("username"); b.HasKey("Id") .HasName("pk_users"); b.HasIndex("InstanceId") .HasDatabaseName("ix_users_instance_id"); b.HasIndex("RemoteUserId", "InstanceId") .IsUnique() .HasDatabaseName("ix_users_remote_user_id_instance_id"); b.HasIndex("Username", "InstanceId") .IsUnique() .HasDatabaseName("ix_users_username_instance_id"); b.ToTable("users", (string)null); }); modelBuilder.Entity("Foxchat.Core.Database.Instance", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("integer") .HasColumnName("id"); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("PrivateKey") .IsRequired() .HasColumnType("text") .HasColumnName("private_key"); b.Property("PublicKey") .IsRequired() .HasColumnType("text") .HasColumnName("public_key"); b.HasKey("Id") .HasName("pk_instance"); b.ToTable("instance", (string)null); }); modelBuilder.Entity("GuildUser", b => { b.Property("GuildsId") .HasColumnType("uuid") .HasColumnName("guilds_id"); b.Property("UsersId") .HasColumnType("uuid") .HasColumnName("users_id"); b.HasKey("GuildsId", "UsersId") .HasName("pk_guild_user"); b.HasIndex("UsersId") .HasDatabaseName("ix_guild_user_users_id"); b.ToTable("guild_user", (string)null); }); modelBuilder.Entity("Foxchat.Chat.Database.Models.Channel", b => { b.HasOne("Foxchat.Chat.Database.Models.Guild", "Guild") .WithMany("Channels") .HasForeignKey("GuildId") .OnDelete(DeleteBehavior.Cascade) .IsRequired() .HasConstraintName("fk_channels_guilds_guild_id"); b.Navigation("Guild"); }); modelBuilder.Entity("Foxchat.Chat.Database.Models.Guild", b => { b.HasOne("Foxchat.Chat.Database.Models.User", "Owner") .WithMany("OwnedGuilds") .HasForeignKey("OwnerId") .OnDelete(DeleteBehavior.Cascade) .IsRequired() .HasConstraintName("fk_guilds_users_owner_id"); b.Navigation("Owner"); }); modelBuilder.Entity("Foxchat.Chat.Database.Models.Message", b => { b.HasOne("Foxchat.Chat.Database.Models.User", "Author") .WithMany() .HasForeignKey("AuthorId") .OnDelete(DeleteBehavior.Cascade) .IsRequired() .HasConstraintName("fk_messages_users_author_id"); b.HasOne("Foxchat.Chat.Database.Models.Channel", "Channel") .WithMany() .HasForeignKey("ChannelId") .OnDelete(DeleteBehavior.Cascade) .IsRequired() .HasConstraintName("fk_messages_channels_channel_id"); b.Navigation("Author"); b.Navigation("Channel"); }); modelBuilder.Entity("Foxchat.Chat.Database.Models.User", b => { b.HasOne("Foxchat.Chat.Database.Models.IdentityInstance", "Instance") .WithMany() .HasForeignKey("InstanceId") .OnDelete(DeleteBehavior.Cascade) .IsRequired() .HasConstraintName("fk_users_identity_instances_instance_id"); b.Navigation("Instance"); }); modelBuilder.Entity("GuildUser", b => { b.HasOne("Foxchat.Chat.Database.Models.Guild", null) .WithMany() .HasForeignKey("GuildsId") .OnDelete(DeleteBehavior.Cascade) .IsRequired() .HasConstraintName("fk_guild_user_guilds_guilds_id"); b.HasOne("Foxchat.Chat.Database.Models.User", null) .WithMany() .HasForeignKey("UsersId") .OnDelete(DeleteBehavior.Cascade) .IsRequired() .HasConstraintName("fk_guild_user_users_users_id"); }); modelBuilder.Entity("Foxchat.Chat.Database.Models.Guild", b => { b.Navigation("Channels"); }); modelBuilder.Entity("Foxchat.Chat.Database.Models.User", b => { b.Navigation("OwnedGuilds"); }); #pragma warning restore 612, 618 } } }