Added more database stuff, applied migrations

This commit is contained in:
Kwoth 2016-08-30 03:17:16 +02:00
parent e6dca827f9
commit 7647f71020
4 changed files with 72 additions and 1 deletions

View File

@ -8,7 +8,7 @@ using NadekoBot.Services.Database.Impl;
namespace NadekoBot.Migrations namespace NadekoBot.Migrations
{ {
[DbContext(typeof(NadekoSqliteContext))] [DbContext(typeof(NadekoSqliteContext))]
[Migration("20160829215759_first")] [Migration("20160830011641_first")]
partial class first partial class first
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -104,6 +104,23 @@ namespace NadekoBot.Migrations
b.ToTable("ClashOfClans"); b.ToTable("ClashOfClans");
}); });
modelBuilder.Entity("NadekoBot.Services.Database.Models.Currency", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<long>("Amount");
b.Property<ulong>("UserId");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("Currency");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.Donator", b => modelBuilder.Entity("NadekoBot.Services.Database.Models.Donator", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@ -160,6 +177,8 @@ namespace NadekoBot.Migrations
b.Property<string>("ChannelGreetMessageText"); b.Property<string>("ChannelGreetMessageText");
b.Property<float>("DefaultMusicVolume");
b.Property<bool>("DeleteMessageOnCommand"); b.Property<bool>("DeleteMessageOnCommand");
b.Property<string>("DmGreetMessageText"); b.Property<string>("DmGreetMessageText");

View File

@ -47,6 +47,20 @@ namespace NadekoBot.Migrations
table.PrimaryKey("PK_ClashOfClans", x => x.Id); table.PrimaryKey("PK_ClashOfClans", x => x.Id);
}); });
migrationBuilder.CreateTable(
name: "Currency",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Autoincrement", true),
Amount = table.Column<long>(nullable: false),
UserId = table.Column<ulong>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Currency", x => x.Id);
});
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Donators", name: "Donators",
columns: table => new columns: table => new
@ -76,6 +90,7 @@ namespace NadekoBot.Migrations
ByeMessageChannelId = table.Column<ulong>(nullable: false), ByeMessageChannelId = table.Column<ulong>(nullable: false),
ChannelByeMessageText = table.Column<string>(nullable: true), ChannelByeMessageText = table.Column<string>(nullable: true),
ChannelGreetMessageText = table.Column<string>(nullable: true), ChannelGreetMessageText = table.Column<string>(nullable: true),
DefaultMusicVolume = table.Column<float>(nullable: false),
DeleteMessageOnCommand = table.Column<bool>(nullable: false), DeleteMessageOnCommand = table.Column<bool>(nullable: false),
DmGreetMessageText = table.Column<string>(nullable: true), DmGreetMessageText = table.Column<string>(nullable: true),
ExclusiveSelfAssignedRoles = table.Column<bool>(nullable: false), ExclusiveSelfAssignedRoles = table.Column<bool>(nullable: false),
@ -290,6 +305,12 @@ namespace NadekoBot.Migrations
table: "ClashCallers", table: "ClashCallers",
column: "ClashWarId"); column: "ClashWarId");
migrationBuilder.CreateIndex(
name: "IX_Currency_UserId",
table: "Currency",
column: "UserId",
unique: true);
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Donators_UserId", name: "IX_Donators_UserId",
table: "Donators", table: "Donators",
@ -343,6 +364,9 @@ namespace NadekoBot.Migrations
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "ClashCallers"); name: "ClashCallers");
migrationBuilder.DropTable(
name: "Currency");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Donators"); name: "Donators");

View File

@ -103,6 +103,23 @@ namespace NadekoBot.Migrations
b.ToTable("ClashOfClans"); b.ToTable("ClashOfClans");
}); });
modelBuilder.Entity("NadekoBot.Services.Database.Models.Currency", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<long>("Amount");
b.Property<ulong>("UserId");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("Currency");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.Donator", b => modelBuilder.Entity("NadekoBot.Services.Database.Models.Donator", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@ -159,6 +176,8 @@ namespace NadekoBot.Migrations
b.Property<string>("ChannelGreetMessageText"); b.Property<string>("ChannelGreetMessageText");
b.Property<float>("DefaultMusicVolume");
b.Property<bool>("DeleteMessageOnCommand"); b.Property<bool>("DeleteMessageOnCommand");
b.Property<string>("DmGreetMessageText"); b.Property<string>("DmGreetMessageText");

View File

@ -19,6 +19,7 @@ namespace NadekoBot.Services.Database
public DbSet<SelfAssignedRole> SelfAssignableRoles { get; set; } public DbSet<SelfAssignedRole> SelfAssignableRoles { get; set; }
public DbSet<BotConfig> BotConfig { get; set; } public DbSet<BotConfig> BotConfig { get; set; }
public DbSet<Repeater> Repeaters { get; set; } public DbSet<Repeater> Repeaters { get; set; }
public DbSet<Currency> Currency { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnModelCreating(ModelBuilder modelBuilder)
{ {
@ -74,6 +75,14 @@ namespace NadekoBot.Services.Database
.IsUnique(); .IsUnique();
#endregion #endregion
#region Currency
var currencyEntity = modelBuilder.Entity<Currency>();
currencyEntity
.HasIndex(c => c.UserId)
.IsUnique();
#endregion
} }
protected abstract override void OnConfiguring(DbContextOptionsBuilder optionsBuilder); protected abstract override void OnConfiguring(DbContextOptionsBuilder optionsBuilder);
} }