using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace Avalonia_EFCore.Migrations.SQLite { /// /// 初始数据库基线。后续软件版本只追加新的 Migration,不修改已发布 Migration。 /// public partial class InitialCreate : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "user", columns: table => new { Id = table.Column(name: "id", nullable: false, comment: "用户主键") .Annotation("SqlServer:Identity", "1, 1") .Annotation("Sqlite:Autoincrement", true) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(name: "name", maxLength: 100, nullable: true, comment: "用户名称"), Email = table.Column(name: "email", maxLength: 200, nullable: true, comment: "用户邮箱"), CreatedAt = table.Column(name: "created-at", nullable: false, comment: "创建时间"), UpdatedAt = table.Column(name: "updated-at", 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(name: "id", nullable: false, comment: "天气预报主键") .Annotation("SqlServer:Identity", "1, 1") .Annotation("Sqlite:Autoincrement", true) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Date = table.Column(name: "date", nullable: false, comment: "预报日期"), TemperatureC = table.Column(name: "temperature-c", nullable: false, comment: "摄氏温度"), Summary = table.Column(name: "summary", maxLength: 200, nullable: true, comment: "天气摘要"), CreatedAt = table.Column(name: "created-at", nullable: false, comment: "创建时间"), UpdatedAt = table.Column(name: "updated-at", nullable: false, comment: "更新时间") }, constraints: table => { table.PrimaryKey("pk-weather-forecast", x => x.Id); }, comment: "天气预报数据实体"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable(name: "weather-forecast"); migrationBuilder.DropTable(name: "user"); } } }