From 8de5e477831a3ec2337f697088f0da019f11a699 Mon Sep 17 00:00:00 2001 From: Karolis2011 Date: Tue, 18 Jun 2019 23:20:49 +0300 Subject: [PATCH] Finaly DB is deployment ready. --- ...20190618201842_InitialDatabase.Designer.cs | 141 ++++++++++++++++++ .../MySql/20190618201842_InitialDatabase.cs | 139 +++++++++++++++++ .../MySqlDatabaseServiceModelSnapshot.cs | 139 +++++++++++++++++ EventBot/Modules/EventModule.cs | 1 - 4 files changed, 419 insertions(+), 1 deletion(-) create mode 100644 EventBot/Migrations/MySql/20190618201842_InitialDatabase.Designer.cs create mode 100644 EventBot/Migrations/MySql/20190618201842_InitialDatabase.cs create mode 100644 EventBot/Migrations/MySql/MySqlDatabaseServiceModelSnapshot.cs diff --git a/EventBot/Migrations/MySql/20190618201842_InitialDatabase.Designer.cs b/EventBot/Migrations/MySql/20190618201842_InitialDatabase.Designer.cs new file mode 100644 index 0000000..67920ef --- /dev/null +++ b/EventBot/Migrations/MySql/20190618201842_InitialDatabase.Designer.cs @@ -0,0 +1,141 @@ +// +using System; +using EventBot.Services; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace EventBot.Migrations.MySql +{ + [DbContext(typeof(MySqlDatabaseService))] + [Migration("20190618201842_InitialDatabase")] + partial class InitialDatabase + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("EventBot.Entities.Event", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Description"); + + b.Property("GuildId"); + + b.Property("MessageChannelId"); + + b.Property("MessageId"); + + b.Property("Opened"); + + b.Property("Title"); + + b.Property("Type"); + + b.HasKey("Id"); + + b.HasIndex("GuildId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("EventBot.Entities.EventParticipant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("EventId"); + + b.Property("EventRoleId"); + + b.Property("UserData"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("EventId"); + + b.HasIndex("EventRoleId"); + + b.ToTable("EventParticipants"); + }); + + modelBuilder.Entity("EventBot.Entities.EventRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Description"); + + b.Property("Emote"); + + b.Property("EventId"); + + b.Property("MaxParticipants"); + + b.Property("Title"); + + b.HasKey("Id"); + + b.HasIndex("EventId"); + + b.ToTable("EventRoles"); + }); + + modelBuilder.Entity("EventBot.Entities.GuildConfig", b => + { + b.Property("GuildId") + .ValueGeneratedOnAdd(); + + b.Property("EventRoleConfirmationChannelId"); + + b.Property("ParticipantRoleId"); + + b.Property("Prefix"); + + b.HasKey("GuildId"); + + b.ToTable("GuildConfigs"); + }); + + modelBuilder.Entity("EventBot.Entities.Event", b => + { + b.HasOne("EventBot.Entities.GuildConfig", "Guild") + .WithMany("Events") + .HasForeignKey("GuildId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("EventBot.Entities.EventParticipant", b => + { + b.HasOne("EventBot.Entities.Event", "Event") + .WithMany("Participants") + .HasForeignKey("EventId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("EventBot.Entities.EventRole", "Role") + .WithMany("Participants") + .HasForeignKey("EventRoleId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("EventBot.Entities.EventRole", b => + { + b.HasOne("EventBot.Entities.Event", "Event") + .WithMany("Roles") + .HasForeignKey("EventId") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/EventBot/Migrations/MySql/20190618201842_InitialDatabase.cs b/EventBot/Migrations/MySql/20190618201842_InitialDatabase.cs new file mode 100644 index 0000000..35b9d49 --- /dev/null +++ b/EventBot/Migrations/MySql/20190618201842_InitialDatabase.cs @@ -0,0 +1,139 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace EventBot.Migrations.MySql +{ + public partial class InitialDatabase : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "GuildConfigs", + columns: table => new + { + GuildId = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Prefix = table.Column(nullable: true), + EventRoleConfirmationChannelId = table.Column(nullable: false), + ParticipantRoleId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GuildConfigs", x => x.GuildId); + }); + + migrationBuilder.CreateTable( + name: "Events", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Title = table.Column(nullable: true), + Description = table.Column(nullable: true), + Active = table.Column(nullable: false), + MessageId = table.Column(nullable: false), + MessageChannelId = table.Column(nullable: false), + Opened = table.Column(nullable: false), + Type = table.Column(nullable: false), + GuildId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Events", x => x.Id); + table.ForeignKey( + name: "FK_Events_GuildConfigs_GuildId", + column: x => x.GuildId, + principalTable: "GuildConfigs", + principalColumn: "GuildId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "EventRoles", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Title = table.Column(nullable: true), + Description = table.Column(nullable: true), + Emote = table.Column(nullable: true), + MaxParticipants = table.Column(nullable: false), + EventId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_EventRoles", x => x.Id); + table.ForeignKey( + name: "FK_EventRoles_Events_EventId", + column: x => x.EventId, + principalTable: "Events", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "EventParticipants", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + EventRoleId = table.Column(nullable: false), + EventId = table.Column(nullable: false), + UserId = table.Column(nullable: false), + UserData = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_EventParticipants", x => x.Id); + table.ForeignKey( + name: "FK_EventParticipants_Events_EventId", + column: x => x.EventId, + principalTable: "Events", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_EventParticipants_EventRoles_EventRoleId", + column: x => x.EventRoleId, + principalTable: "EventRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_EventParticipants_EventId", + table: "EventParticipants", + column: "EventId"); + + migrationBuilder.CreateIndex( + name: "IX_EventParticipants_EventRoleId", + table: "EventParticipants", + column: "EventRoleId"); + + migrationBuilder.CreateIndex( + name: "IX_EventRoles_EventId", + table: "EventRoles", + column: "EventId"); + + migrationBuilder.CreateIndex( + name: "IX_Events_GuildId", + table: "Events", + column: "GuildId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "EventParticipants"); + + migrationBuilder.DropTable( + name: "EventRoles"); + + migrationBuilder.DropTable( + name: "Events"); + + migrationBuilder.DropTable( + name: "GuildConfigs"); + } + } +} diff --git a/EventBot/Migrations/MySql/MySqlDatabaseServiceModelSnapshot.cs b/EventBot/Migrations/MySql/MySqlDatabaseServiceModelSnapshot.cs new file mode 100644 index 0000000..6f9a1b5 --- /dev/null +++ b/EventBot/Migrations/MySql/MySqlDatabaseServiceModelSnapshot.cs @@ -0,0 +1,139 @@ +// +using System; +using EventBot.Services; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace EventBot.Migrations.MySql +{ + [DbContext(typeof(MySqlDatabaseService))] + partial class MySqlDatabaseServiceModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("EventBot.Entities.Event", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Description"); + + b.Property("GuildId"); + + b.Property("MessageChannelId"); + + b.Property("MessageId"); + + b.Property("Opened"); + + b.Property("Title"); + + b.Property("Type"); + + b.HasKey("Id"); + + b.HasIndex("GuildId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("EventBot.Entities.EventParticipant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("EventId"); + + b.Property("EventRoleId"); + + b.Property("UserData"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("EventId"); + + b.HasIndex("EventRoleId"); + + b.ToTable("EventParticipants"); + }); + + modelBuilder.Entity("EventBot.Entities.EventRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Description"); + + b.Property("Emote"); + + b.Property("EventId"); + + b.Property("MaxParticipants"); + + b.Property("Title"); + + b.HasKey("Id"); + + b.HasIndex("EventId"); + + b.ToTable("EventRoles"); + }); + + modelBuilder.Entity("EventBot.Entities.GuildConfig", b => + { + b.Property("GuildId") + .ValueGeneratedOnAdd(); + + b.Property("EventRoleConfirmationChannelId"); + + b.Property("ParticipantRoleId"); + + b.Property("Prefix"); + + b.HasKey("GuildId"); + + b.ToTable("GuildConfigs"); + }); + + modelBuilder.Entity("EventBot.Entities.Event", b => + { + b.HasOne("EventBot.Entities.GuildConfig", "Guild") + .WithMany("Events") + .HasForeignKey("GuildId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("EventBot.Entities.EventParticipant", b => + { + b.HasOne("EventBot.Entities.Event", "Event") + .WithMany("Participants") + .HasForeignKey("EventId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("EventBot.Entities.EventRole", "Role") + .WithMany("Participants") + .HasForeignKey("EventRoleId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("EventBot.Entities.EventRole", b => + { + b.HasOne("EventBot.Entities.Event", "Event") + .WithMany("Roles") + .HasForeignKey("EventId") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/EventBot/Modules/EventModule.cs b/EventBot/Modules/EventModule.cs index b46e8f6..bc63c32 100644 --- a/EventBot/Modules/EventModule.cs +++ b/EventBot/Modules/EventModule.cs @@ -8,7 +8,6 @@ using System.Threading.Tasks; using System.Linq; using EventBot.Entities; using Discord.WebSocket; -using NeoSmart.Unicode; using Discord.Addons.Interactive; namespace EventBot.Modules