FileShare/Avalonia-EFCore/Migrations/SQLite/20260514000100_InitialCreate.cs
2026-05-21 15:52:36 +08:00

63 lines
3.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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