diff --git a/Data/BotDatabaseContext.cs b/Data/BotDatabaseContext.cs index d25be34..03ac6d1 100644 --- a/Data/BotDatabaseContext.cs +++ b/Data/BotDatabaseContext.cs @@ -29,7 +29,6 @@ public class BotDatabaseContext : DbContext { protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity(entity => { entity.HasKey(e => new { e.GuildId, e.UserId }).HasName("userdata_pkey"); - entity.Property(e => e.LastUpdate).HasDefaultValueSql("now()"); }); } diff --git a/Data/Migrations/20220629003046_RemoveLastUpdated.Designer.cs b/Data/Migrations/20220629003046_RemoveLastUpdated.Designer.cs new file mode 100644 index 0000000..49ba1a8 --- /dev/null +++ b/Data/Migrations/20220629003046_RemoveLastUpdated.Designer.cs @@ -0,0 +1,49 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using WorldTime.Data; + +#nullable disable + +namespace WorldTime.Data.Migrations +{ + [DbContext(typeof(BotDatabaseContext))] + [Migration("20220629003046_RemoveLastUpdated")] + partial class RemoveLastUpdated + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.6") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("WorldTime.Data.UserEntry", b => + { + b.Property("GuildId") + .HasColumnType("bigint") + .HasColumnName("guild_id"); + + b.Property("UserId") + .HasColumnType("bigint") + .HasColumnName("user_id"); + + b.Property("TimeZone") + .IsRequired() + .HasColumnType("text") + .HasColumnName("zone"); + + b.HasKey("GuildId", "UserId") + .HasName("userdata_pkey"); + + b.ToTable("userdata", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Data/Migrations/20220629003046_RemoveLastUpdated.cs b/Data/Migrations/20220629003046_RemoveLastUpdated.cs new file mode 100644 index 0000000..5ee04f4 --- /dev/null +++ b/Data/Migrations/20220629003046_RemoveLastUpdated.cs @@ -0,0 +1,27 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace WorldTime.Data.Migrations +{ + public partial class RemoveLastUpdated : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "last_active", + table: "userdata"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "last_active", + table: "userdata", + type: "timestamp with time zone", + nullable: false, + defaultValueSql: "now()"); + } + } +} diff --git a/Data/Migrations/BotDatabaseContextModelSnapshot.cs b/Data/Migrations/BotDatabaseContextModelSnapshot.cs index abae3e1..a8cfd57 100644 --- a/Data/Migrations/BotDatabaseContextModelSnapshot.cs +++ b/Data/Migrations/BotDatabaseContextModelSnapshot.cs @@ -1,5 +1,4 @@ // -using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; @@ -32,12 +31,6 @@ namespace WorldTime.Data.Migrations .HasColumnType("bigint") .HasColumnName("user_id"); - b.Property("LastUpdate") - .ValueGeneratedOnAdd() - .HasColumnType("timestamp with time zone") - .HasColumnName("last_active") - .HasDefaultValueSql("now()"); - b.Property("TimeZone") .IsRequired() .HasColumnType("text") diff --git a/Data/UserEntry.cs b/Data/UserEntry.cs index ae8ba7f..bd9a36d 100644 --- a/Data/UserEntry.cs +++ b/Data/UserEntry.cs @@ -12,7 +12,4 @@ public class UserEntry { public long UserId { get; set; } [Column("zone")] public string TimeZone { get; set; } = null!; - [Obsolete("No longer in use and should be removed promptly.")] - [Column("last_active")] - public DateTime LastUpdate { get; set; } } \ No newline at end of file