7a4c516a20
- 后端:新增 CloudSync 认证/权限/端点/服务与 DTO - 数据:新增用户/会话/安全策略实体与 EF Core migrations - 前端:新增云同步设置 UI、客户端与本地存储;Vite 支持 maui 构建输出到 wwwroot - 桌面端:新增 Avalonia 项目、内置 WebServer、托盘与 Windows 全局热键 - 发布/构建:新增 Windows/Linux 发布脚本与统一入口;调整 MAUI 资源与安装包配置 - 文档:同步更新 README/docs 与协作规则
137 lines
5.0 KiB
C#
137 lines
5.0 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Hua.Todo.Application.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddCloudSyncCoreEntities : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<Guid>(
|
|
name: "UserId",
|
|
table: "Tasks",
|
|
type: "TEXT",
|
|
nullable: false,
|
|
defaultValue: new Guid("00000000-0000-0000-0000-000000000001"));
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Users",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "TEXT", nullable: false),
|
|
UserName = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
|
|
PasswordHash = table.Column<string>(type: "TEXT", nullable: false),
|
|
Role = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Users", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.InsertData(
|
|
table: "Users",
|
|
columns: new[] { "Id", "UserName", "PasswordHash", "Role" },
|
|
values: new object[] { new Guid("00000000-0000-0000-0000-000000000001"), "local", "", "local" });
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "SecurityPolicies",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "TEXT", nullable: false),
|
|
UserId = table.Column<Guid>(type: "TEXT", nullable: false),
|
|
AllowPersist = table.Column<bool>(type: "INTEGER", nullable: false, defaultValue: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_SecurityPolicies", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_SecurityPolicies_Users_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "UserSessions",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "TEXT", nullable: false),
|
|
UserId = table.Column<Guid>(type: "TEXT", nullable: false),
|
|
CreatedAtUtc = table.Column<DateTime>(type: "TEXT", nullable: false),
|
|
ExpiresAtUtc = table.Column<DateTime>(type: "TEXT", nullable: false),
|
|
StepUpExpiresAtUtc = table.Column<DateTime>(type: "TEXT", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_UserSessions", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_UserSessions_Users_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Tasks_UserId",
|
|
table: "Tasks",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SecurityPolicies_UserId",
|
|
table: "SecurityPolicies",
|
|
column: "UserId",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Users_UserName",
|
|
table: "Users",
|
|
column: "UserName",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_UserSessions_UserId",
|
|
table: "UserSessions",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_Tasks_Users_UserId",
|
|
table: "Tasks",
|
|
column: "UserId",
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_Tasks_Users_UserId",
|
|
table: "Tasks");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "SecurityPolicies");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "UserSessions");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Users");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_Tasks_UserId",
|
|
table: "Tasks");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "UserId",
|
|
table: "Tasks");
|
|
}
|
|
}
|
|
}
|