feat: 重新生成数据库迁移调整时区保存问题
parent
3b890baa6c
commit
d04bc75105
|
|
@ -32,7 +32,8 @@ public class UserPointService : IUserPointService
|
||||||
UserPointId = userPoint.Id,
|
UserPointId = userPoint.Id,
|
||||||
UserId = user.Id,
|
UserId = user.Id,
|
||||||
Name = user.Name,
|
Name = user.Name,
|
||||||
Point = userPoint.Point
|
Point = userPoint.Point,
|
||||||
|
CreateTime = userPoint.CreateTime
|
||||||
};
|
};
|
||||||
|
|
||||||
var count = queryable.Count();
|
var count = queryable.Count();
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,6 @@ public class UserPoint
|
||||||
{
|
{
|
||||||
UserId = userId;
|
UserId = userId;
|
||||||
Point = point;
|
Point = point;
|
||||||
CreateTime = DateTime.UtcNow;
|
CreateTime = DateTime.Now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
// <auto-generated />
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
using UserPointManagement.Persistence;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace UserPointManagement.Persistence.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(UserPointManagementDbContext))]
|
|
||||||
[Migration("20230728165153_Initial")]
|
|
||||||
partial class Initial
|
|
||||||
{
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "6.0.0")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("UserPointManagement.Model.Entities.User", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer")
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasComment("主键");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("Mobile")
|
|
||||||
.IsRequired()
|
|
||||||
.HasMaxLength(30)
|
|
||||||
.HasColumnType("character varying(30)")
|
|
||||||
.HasColumnName("mobile")
|
|
||||||
.HasComment("手机号");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasMaxLength(50)
|
|
||||||
.HasColumnType("character varying(50)")
|
|
||||||
.HasColumnName("name")
|
|
||||||
.HasComment("姓名");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_user");
|
|
||||||
|
|
||||||
b.ToTable("user", (string)null);
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace UserPointManagement.Persistence.Migrations
|
|
||||||
{
|
|
||||||
public partial class Initial : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "user",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<int>(type: "integer", nullable: false, comment: "主键")
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
name = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false, comment: "姓名"),
|
|
||||||
mobile = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false, comment: "手机号")
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_user", x => x.id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "user");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -12,8 +12,8 @@ using UserPointManagement.Persistence;
|
||||||
namespace UserPointManagement.Persistence.Migrations
|
namespace UserPointManagement.Persistence.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(UserPointManagementDbContext))]
|
[DbContext(typeof(UserPointManagementDbContext))]
|
||||||
[Migration("20230729051855_AddUserPoint")]
|
[Migration("20230730041015_Initial")]
|
||||||
partial class AddUserPoint
|
partial class Initial
|
||||||
{
|
{
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
|
|
@ -65,7 +65,7 @@ namespace UserPointManagement.Persistence.Migrations
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
b.Property<DateTime>("CreateTime")
|
b.Property<DateTime>("CreateTime")
|
||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp without time zone")
|
||||||
.HasColumnName("create_time")
|
.HasColumnName("create_time")
|
||||||
.HasComment("新增时间");
|
.HasComment("新增时间");
|
||||||
|
|
||||||
|
|
@ -6,10 +6,24 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
namespace UserPointManagement.Persistence.Migrations
|
namespace UserPointManagement.Persistence.Migrations
|
||||||
{
|
{
|
||||||
public partial class AddUserPoint : Migration
|
public partial class Initial : Migration
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "user",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false, comment: "主键")
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
name = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false, comment: "姓名"),
|
||||||
|
mobile = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false, comment: "手机号")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_user", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "user_point",
|
name: "user_point",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
|
|
@ -18,7 +32,7 @@ namespace UserPointManagement.Persistence.Migrations
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
user_id = table.Column<int>(type: "integer", nullable: false, comment: "用户Id"),
|
user_id = table.Column<int>(type: "integer", nullable: false, comment: "用户Id"),
|
||||||
point = table.Column<int>(type: "integer", nullable: false, comment: "积分"),
|
point = table.Column<int>(type: "integer", nullable: false, comment: "积分"),
|
||||||
create_time = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "新增时间")
|
create_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: false, comment: "新增时间")
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
|
|
@ -28,6 +42,9 @@ namespace UserPointManagement.Persistence.Migrations
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "user");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "user_point");
|
name: "user_point");
|
||||||
}
|
}
|
||||||
|
|
@ -63,7 +63,7 @@ namespace UserPointManagement.Persistence.Migrations
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
b.Property<DateTime>("CreateTime")
|
b.Property<DateTime>("CreateTime")
|
||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp without time zone")
|
||||||
.HasColumnName("create_time")
|
.HasColumnName("create_time")
|
||||||
.HasComment("新增时间");
|
.HasComment("新增时间");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@ public class UserPointManagementDbContextFactory : IDesignTimeDbContextFactory<U
|
||||||
.UseNpgsql("Server=67.230.184.225;Port=58007;UserId=postgres;Password=postgres;Database=tiamo;")
|
.UseNpgsql("Server=67.230.184.225;Port=58007;UserId=postgres;Password=postgres;Database=tiamo;")
|
||||||
.UseSnakeCaseNamingConvention();
|
.UseSnakeCaseNamingConvention();
|
||||||
|
|
||||||
|
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||||
|
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
|
||||||
|
|
||||||
return new UserPointManagementDbContext(optionsBuilder.Options);
|
return new UserPointManagementDbContext(optionsBuilder.Options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -45,6 +45,7 @@
|
||||||
OnPageSizeChange="OnPageSizeChange">
|
OnPageSizeChange="OnPageSizeChange">
|
||||||
<PropertyColumn Property="c => c.Name" title="用户姓名"/>
|
<PropertyColumn Property="c => c.Name" title="用户姓名"/>
|
||||||
<PropertyColumn Property="c => c.Point" title="积分"/>
|
<PropertyColumn Property="c => c.Point" title="积分"/>
|
||||||
|
<PropertyColumn Property="c => c.CreateTime" title="新增时间" Format="yyyy-MM-dd hh:mm"/>
|
||||||
</Table>
|
</Table>
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,9 @@ namespace UserPointManagement.Web
|
||||||
BaseAddress = new Uri(sp.GetService<NavigationManager>().BaseUri)
|
BaseAddress = new Uri(sp.GetService<NavigationManager>().BaseUri)
|
||||||
});
|
});
|
||||||
services.Configure<ProSettings>(Configuration.GetSection("ProSettings"));
|
services.Configure<ProSettings>(Configuration.GetSection("ProSettings"));
|
||||||
|
|
||||||
|
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||||
|
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue