Add database model and migrations for RoleReaction
This commit is contained in:
parent
680d0419f6
commit
9dae8289dc
163
ChaosBot/Migrations/20200819203430_RoleReaction.Designer.cs
generated
Normal file
163
ChaosBot/Migrations/20200819203430_RoleReaction.Designer.cs
generated
Normal file
@ -0,0 +1,163 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using ChaosBot.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace ChaosBot.Migrations
|
||||
{
|
||||
[DbContext(typeof(ChaosbotContext))]
|
||||
[Migration("20200819203430_RoleReaction")]
|
||||
partial class RoleReaction
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "3.1.6")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||
|
||||
modelBuilder.Entity("ChaosBot.Models.CommandPermission", b =>
|
||||
{
|
||||
b.Property<ulong>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<string>("Command")
|
||||
.IsRequired()
|
||||
.HasColumnType("varchar(128) CHARACTER SET utf8mb4")
|
||||
.HasMaxLength(128);
|
||||
|
||||
b.Property<ulong>("DiscordGuildId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<ulong>("TargetId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<int>("TargetType")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("CommandPermissions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ChaosBot.Models.Configuration", b =>
|
||||
{
|
||||
b.Property<ulong>("DiscordGuildId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<string>("Key")
|
||||
.HasColumnType("varchar(128) CHARACTER SET utf8mb4")
|
||||
.HasMaxLength(128);
|
||||
|
||||
b.Property<string>("SerializedValue")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext CHARACTER SET utf8mb4");
|
||||
|
||||
b.HasKey("DiscordGuildId", "Key");
|
||||
|
||||
b.ToTable("Configuration");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ChaosBot.Models.Experience", b =>
|
||||
{
|
||||
b.Property<ulong>("DiscordGuildId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<ulong>("DiscordUserId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<ulong>("Amount")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<DateTime>("LastUpdated")
|
||||
.HasColumnType("datetime");
|
||||
|
||||
b.Property<ulong>("Level")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.HasKey("DiscordGuildId", "DiscordUserId");
|
||||
|
||||
b.ToTable("ExperiencePoints");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ChaosBot.Models.LodestoneCharacter", b =>
|
||||
{
|
||||
b.Property<ulong>("DiscordGuildId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<ulong>("LodestoneId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<string>("Avatar")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext CHARACTER SET utf8mb4");
|
||||
|
||||
b.Property<ulong>("DiscordUserId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext CHARACTER SET utf8mb4");
|
||||
|
||||
b.HasKey("DiscordGuildId", "LodestoneId");
|
||||
|
||||
b.ToTable("LodestoneCharacter");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ChaosBot.Models.LodestoneFreeCompany", b =>
|
||||
{
|
||||
b.Property<ulong>("DiscordGuildId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<ulong>("LodestoneId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext CHARACTER SET utf8mb4");
|
||||
|
||||
b.HasKey("DiscordGuildId", "LodestoneId");
|
||||
|
||||
b.ToTable("LodestoneFreeCompany");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ChaosBot.Models.Point", b =>
|
||||
{
|
||||
b.Property<ulong>("DiscordGuildId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<ulong>("DiscordUserId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<ulong>("Amount")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.HasKey("DiscordGuildId", "DiscordUserId");
|
||||
|
||||
b.ToTable("Points");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ChaosBot.Models.Raffle", b =>
|
||||
{
|
||||
b.Property<ulong>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<ulong>("DiscordGuildId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<ulong>("DiscordUserId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Raffles");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
33
ChaosBot/Migrations/20200819203430_RoleReaction.cs
Normal file
33
ChaosBot/Migrations/20200819203430_RoleReaction.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace ChaosBot.Migrations
|
||||
{
|
||||
public partial class RoleReaction : Migration
|
||||
{
|
||||
protected readonly string Table = "RoleReactions";
|
||||
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: Table,
|
||||
columns: table => new
|
||||
{
|
||||
DiscordGuildId = table.Column<ulong>(nullable: false),
|
||||
DiscordMessageId = table.Column<ulong>(nullable: false),
|
||||
DiscordRoleId = table.Column<ulong>(nullable: false),
|
||||
DiscordEmoteNameEncoded = table.Column<string>(nullable: false, maxLength: 128)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RoleReactions", x => new { x.DiscordGuildId, x.DiscordRoleId, x.DiscordMessageId, x.DiscordEmoteNameEncoded });
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(name: Table);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using ChaosBot.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
@ -24,7 +25,8 @@ namespace ChaosBot.Migrations
|
||||
|
||||
b.Property<string>("Command")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext CHARACTER SET utf8mb4");
|
||||
.HasColumnType("varchar(128) CHARACTER SET utf8mb4")
|
||||
.HasMaxLength(128);
|
||||
|
||||
b.Property<ulong>("DiscordGuildId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
@ -58,6 +60,28 @@ namespace ChaosBot.Migrations
|
||||
b.ToTable("Configuration");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ChaosBot.Models.Experience", b =>
|
||||
{
|
||||
b.Property<ulong>("DiscordGuildId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<ulong>("DiscordUserId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<ulong>("Amount")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<DateTime>("LastUpdated")
|
||||
.HasColumnType("datetime");
|
||||
|
||||
b.Property<ulong>("Level")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.HasKey("DiscordGuildId", "DiscordUserId");
|
||||
|
||||
b.ToTable("ExperiencePoints");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ChaosBot.Models.LodestoneCharacter", b =>
|
||||
{
|
||||
b.Property<ulong>("DiscordGuildId")
|
||||
|
||||
@ -12,6 +12,7 @@ namespace ChaosBot.Models
|
||||
public DbSet<CommandPermission> CommandPermissions { get; set; }
|
||||
public DbSet<Configuration> Configuration { get; set; }
|
||||
public DbSet<Experience> ExperiencePoints { get; set; }
|
||||
public DbSet<RoleReaction> RoleReactions { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
@ -46,6 +47,8 @@ namespace ChaosBot.Models
|
||||
.HasKey(x => new {x.DiscordGuildId, x.DiscordUserId});
|
||||
modelBuilder.Entity<Configuration>()
|
||||
.HasKey(x => new {x.DiscordGuildId, x.Key});
|
||||
modelBuilder.Entity<RoleReaction>()
|
||||
.HasKey(x => new {x.DiscordGuildId, x.DiscordMessageId, x.DiscordRoleId, x.DiscordEmoteNameEncoded});
|
||||
}
|
||||
}
|
||||
}
|
||||
37
ChaosBot/Models/RoleReaction.cs
Normal file
37
ChaosBot/Models/RoleReaction.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
|
||||
namespace ChaosBot.Models
|
||||
{
|
||||
#region Required
|
||||
public class RoleReaction
|
||||
{
|
||||
[Required]
|
||||
public ulong DiscordGuildId { get; set; }
|
||||
[Required]
|
||||
public ulong DiscordMessageId { get; set; }
|
||||
[Required]
|
||||
public ulong DiscordRoleId { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public string DiscordEmoteName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (DiscordEmoteNameEncoded == null) return null;
|
||||
return Encoding.UTF8.GetString(Convert.FromBase64String(DiscordEmoteNameEncoded));
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
DiscordEmoteNameEncoded = Convert.ToBase64String(Encoding.UTF8.GetBytes(value));
|
||||
}
|
||||
}
|
||||
|
||||
[Required]
|
||||
public string DiscordEmoteNameEncoded { get; set; }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user