using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Avalonia_EFCore.Migrations.SqlServer { /// public partial class AutoMigration_20260520162543 : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "api-refresh-token", columns: table => new { id = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), userid = table.Column(name: "user-id", type: "int", nullable: false), tokenhash = table.Column(name: "token-hash", type: "nvarchar(128)", maxLength: 128, nullable: false), createdat = table.Column(name: "created-at", type: "datetime2", nullable: false), expiresat = table.Column(name: "expires-at", type: "datetime2", nullable: false), revokedat = table.Column(name: "revoked-at", type: "datetime2", nullable: true), replacedbytokenhash = table.Column(name: "replaced-by-token-hash", type: "nvarchar(128)", maxLength: 128, nullable: true), device = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), ipaddress = table.Column(name: "ip-address", type: "nvarchar(64)", maxLength: 64, nullable: true) }, constraints: table => { table.PrimaryKey("pk-api-refresh-token", x => x.id); }, comment: "API refresh token"); migrationBuilder.CreateTable( name: "user", columns: table => new { id = table.Column(type: "int", nullable: false, comment: "用户主键") .Annotation("SqlServer:Identity", "1, 1"), name = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true, comment: "用户名称"), email = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true, comment: "用户邮箱"), phonenumber = table.Column(name: "phone-number", type: "nvarchar(50)", maxLength: 50, nullable: true, comment: "电话号码"), createdat = table.Column(name: "created-at", type: "datetime2", nullable: false, comment: "创建时间"), updatedat = table.Column(name: "updated-at", type: "datetime2", nullable: false, comment: "更新时间") }, constraints: table => { table.PrimaryKey("pk-user", x => x.id); }, comment: "用户实体,演示数据库 CRUD 操作"); migrationBuilder.CreateTable( name: "weather-forecast", columns: table => new { id = table.Column(type: "int", nullable: false, comment: "天气预报主键") .Annotation("SqlServer:Identity", "1, 1"), date = table.Column(type: "date", nullable: false, comment: "预报日期"), temperaturec = table.Column(name: "temperature-c", type: "int", nullable: false, comment: "摄氏温度"), summary = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true, comment: "天气摘要"), createdat = table.Column(name: "created-at", type: "datetime2", nullable: false, comment: "创建时间"), updatedat = table.Column(name: "updated-at", type: "datetime2", nullable: false, comment: "更新时间") }, constraints: table => { table.PrimaryKey("pk-weather-forecast", x => x.id); }, comment: "天气预报数据实体"); migrationBuilder.CreateIndex( name: "idx-api-refresh-token-hash", table: "api-refresh-token", column: "token-hash", unique: true); migrationBuilder.CreateIndex( name: "idx-api-refresh-token-user-id", table: "api-refresh-token", column: "user-id"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "api-refresh-token"); migrationBuilder.DropTable( name: "user"); migrationBuilder.DropTable( name: "weather-forecast"); } } }