diff --git a/NotificationBot/Migrations/20251222095824_fixMigration.Designer.cs b/NotificationBot/Migrations/20251222095824_fixMigration.Designer.cs new file mode 100644 index 0000000..4a5f418 --- /dev/null +++ b/NotificationBot/Migrations/20251222095824_fixMigration.Designer.cs @@ -0,0 +1,209 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace NotificationsBot.Migrations +{ + [DbContext(typeof(AppContext))] + [Migration("20251222095824_fixMigration")] + partial class fixMigration + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("NotificationTypesProjects", b => + { + b.Property("NotificationTypesId") + .HasColumnType("integer"); + + b.Property("ProjectsId") + .HasColumnType("integer"); + + b.HasKey("NotificationTypesId", "ProjectsId"); + + b.HasIndex("ProjectsId"); + + b.ToTable("NotificationTypesProjects"); + }); + + modelBuilder.Entity("NotificationsBot.Models.Database.NotificationTypes", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EventDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("NotificationTypes"); + }); + + modelBuilder.Entity("NotificationsBot.Models.Database.NotificationsOnProjectChat", b => + { + b.Property("UserId") + .HasColumnType("bigint") + .HasColumnName("ChatId"); + + b.Property("ProjectId") + .HasColumnType("integer"); + + b.Property("NotificationTypesId") + .HasColumnType("integer"); + + b.HasKey("UserId", "ProjectId", "NotificationTypesId"); + + b.HasIndex("NotificationTypesId"); + + b.HasIndex("ProjectId"); + + b.ToTable("NotificationsOnProjectChat"); + }); + + modelBuilder.Entity("NotificationsBot.Models.Database.Projects", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Projects"); + }); + + modelBuilder.Entity("NotificationsBot.Models.Database.Topic", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("ChatId") + .HasColumnType("bigint"); + + b.Property("ProjectsId") + .HasColumnType("integer"); + + b.HasKey("Id", "ChatId"); + + b.HasIndex("ChatId"); + + b.HasIndex("ProjectsId"); + + b.ToTable("Topics"); + }); + + modelBuilder.Entity("NotificationsBot.Models.Database.User", b => + { + b.Property("ChatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ChatId")); + + b.Property("Login") + .HasColumnType("text"); + + b.Property("State") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("ChatId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("NotificationTypesProjects", b => + { + b.HasOne("NotificationsBot.Models.Database.NotificationTypes", null) + .WithMany() + .HasForeignKey("NotificationTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("NotificationsBot.Models.Database.Projects", null) + .WithMany() + .HasForeignKey("ProjectsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("NotificationsBot.Models.Database.NotificationsOnProjectChat", b => + { + b.HasOne("NotificationsBot.Models.Database.NotificationTypes", "NotificationTypes") + .WithMany() + .HasForeignKey("NotificationTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("NotificationsBot.Models.Database.Projects", "Project") + .WithMany() + .HasForeignKey("ProjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("NotificationsBot.Models.Database.User", "Users") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("NotificationTypes"); + + b.Navigation("Project"); + + b.Navigation("Users"); + }); + + modelBuilder.Entity("NotificationsBot.Models.Database.Topic", b => + { + b.HasOne("NotificationsBot.Models.Database.User", null) + .WithMany("Topics") + .HasForeignKey("ChatId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("NotificationsBot.Models.Database.Projects", null) + .WithMany("Topics") + .HasForeignKey("ProjectsId"); + }); + + modelBuilder.Entity("NotificationsBot.Models.Database.Projects", b => + { + b.Navigation("Topics"); + }); + + modelBuilder.Entity("NotificationsBot.Models.Database.User", b => + { + b.Navigation("Topics"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/NotificationBot/Migrations/20251222095824_fixMigration.cs b/NotificationBot/Migrations/20251222095824_fixMigration.cs new file mode 100644 index 0000000..371e929 --- /dev/null +++ b/NotificationBot/Migrations/20251222095824_fixMigration.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace NotificationsBot.Migrations +{ + /// + public partial class fixMigration : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql(" DO $$\r\nDECLARE\r\n db_name text;\r\nBEGIN\r\n SELECT current_database() INTO db_name;\r\n EXECUTE format('ALTER DATABASE %I REFRESH COLLATION version', db_name);\r\nEND $$;"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/NotificationBot/Migrations/AppContextModelSnapshot.cs b/NotificationBot/Migrations/AppContextModelSnapshot.cs index 0b25e44..6b1a63c 100644 --- a/NotificationBot/Migrations/AppContextModelSnapshot.cs +++ b/NotificationBot/Migrations/AppContextModelSnapshot.cs @@ -15,7 +15,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "9.0.1") + .HasAnnotation("ProductVersion", "9.0.11") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); diff --git a/docker-compose_cd.yml b/docker-compose_cd.yml index 36ad078..0a40eaa 100644 --- a/docker-compose_cd.yml +++ b/docker-compose_cd.yml @@ -1,7 +1,8 @@ services: postgresql: container_name: notificationbot-postgres - image: postgres:16 + image: postgres:16.11 + restart: unless-stopped expose: - ${POSTGRES_EXPOSE_PORT} ports: