- Recreated cleanup migration with discorduser default values

- Using LinqToDb UpdateOrInsert for .EnsureUserCreated
This commit is contained in:
Kwoth
2021-07-07 02:32:56 +02:00
parent 0fc5f540d8
commit ac9f84715b
7 changed files with 132 additions and 37 deletions

View File

@@ -9,7 +9,7 @@ using NadekoBot.Services.Database;
namespace NadekoBot.Migrations
{
[DbContext(typeof(NadekoContext))]
[Migration("20210621071424_cleanup")]
[Migration("20210707002343_cleanup")]
partial class cleanup
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -112,18 +112,24 @@ namespace NadekoBot.Migrations
.HasColumnType("TEXT");
b.Property<bool>("IsClubAdmin")
.HasColumnType("INTEGER");
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasDefaultValue(false);
b.Property<DateTime>("LastLevelUp")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT")
.HasDefaultValue(new DateTime(2017, 9, 21, 20, 53, 13, 305, DateTimeKind.Local));
.HasDefaultValueSql("datetime('now')");
b.Property<DateTime>("LastXpGain")
.HasColumnType("TEXT");
.ValueGeneratedOnAdd()
.HasColumnType("TEXT")
.HasDefaultValueSql("datetime('now', '-1 years')");
b.Property<int>("NotifyOnLevelUp")
.HasColumnType("INTEGER");
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasDefaultValue(0);
b.Property<int>("TotalXp")
.HasColumnType("INTEGER");

View File

@@ -7,9 +7,6 @@ namespace NadekoBot.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(
"DELETE FROM __EFMigrationsHistory WHERE __EFMigrationsHistory.MigrationId <> '20210621042359_squash'");
migrationBuilder.DropForeignKey(
name: "FK_GuildConfigs_Permission_RootPermissionId",
table: "GuildConfigs");
@@ -139,6 +136,43 @@ namespace NadekoBot.Migrations
migrationBuilder.DropColumn(
name: "UseCount",
table: "CustomReactions");
migrationBuilder.AlterColumn<int>(
name: "NotifyOnLevelUp",
table: "DiscordUser",
type: "INTEGER",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "INTEGER");
migrationBuilder.AlterColumn<DateTime>(
name: "LastXpGain",
table: "DiscordUser",
type: "TEXT",
nullable: false,
defaultValueSql: "datetime('now', '-1 years')",
oldClrType: typeof(DateTime),
oldType: "TEXT");
migrationBuilder.AlterColumn<DateTime>(
name: "LastLevelUp",
table: "DiscordUser",
type: "TEXT",
nullable: false,
defaultValueSql: "datetime('now')",
oldClrType: typeof(DateTime),
oldType: "TEXT",
oldDefaultValue: new DateTime(2017, 9, 21, 20, 53, 13, 305, DateTimeKind.Local));
migrationBuilder.AlterColumn<bool>(
name: "IsClubAdmin",
table: "DiscordUser",
type: "INTEGER",
nullable: false,
defaultValue: false,
oldClrType: typeof(bool),
oldType: "INTEGER");
}
protected override void Down(MigrationBuilder migrationBuilder)
@@ -323,6 +357,43 @@ namespace NadekoBot.Migrations
nullable: false,
defaultValue: false);
migrationBuilder.AlterColumn<int>(
name: "NotifyOnLevelUp",
table: "DiscordUser",
type: "INTEGER",
nullable: false,
oldClrType: typeof(int),
oldType: "INTEGER",
oldDefaultValue: 0);
migrationBuilder.AlterColumn<DateTime>(
name: "LastXpGain",
table: "DiscordUser",
type: "TEXT",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "TEXT",
oldDefaultValueSql: "datetime('now', '-1 years')");
migrationBuilder.AlterColumn<DateTime>(
name: "LastLevelUp",
table: "DiscordUser",
type: "TEXT",
nullable: false,
defaultValue: new DateTime(2017, 9, 21, 20, 53, 13, 305, DateTimeKind.Local),
oldClrType: typeof(DateTime),
oldType: "TEXT",
oldDefaultValueSql: "datetime('now')");
migrationBuilder.AlterColumn<bool>(
name: "IsClubAdmin",
table: "DiscordUser",
type: "INTEGER",
nullable: false,
oldClrType: typeof(bool),
oldType: "INTEGER",
oldDefaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "IsRegex",
table: "CustomReactions",

View File

@@ -110,18 +110,24 @@ namespace NadekoBot.Migrations
.HasColumnType("TEXT");
b.Property<bool>("IsClubAdmin")
.HasColumnType("INTEGER");
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasDefaultValue(false);
b.Property<DateTime>("LastLevelUp")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT")
.HasDefaultValue(new DateTime(2017, 9, 21, 20, 53, 13, 305, DateTimeKind.Local));
.HasDefaultValueSql("datetime('now')");
b.Property<DateTime>("LastXpGain")
.HasColumnType("TEXT");
.ValueGeneratedOnAdd()
.HasColumnType("TEXT")
.HasDefaultValueSql("datetime('now', '-1 years')");
b.Property<int>("NotifyOnLevelUp")
.HasColumnType("INTEGER");
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasDefaultValue(0);
b.Property<int>("TotalXp")
.HasColumnType("INTEGER");