Add Device, DeviceConfig, SystemSettings entities and seed defaults

This commit is contained in:
2026-06-11 18:41:27 +00:00
parent a1aa5023a2
commit 68e7e81312
8 changed files with 634 additions and 1 deletions
@@ -0,0 +1,94 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace backend.Migrations
{
/// <inheritdoc />
public partial class AddDevicesAndSettings : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Devices",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
OwnerUserId = table.Column<Guid>(type: "TEXT", nullable: false),
Name = table.Column<string>(type: "TEXT", nullable: false),
PairedAt = table.Column<DateTimeOffset>(type: "TEXT", nullable: false),
LastSeenAt = table.Column<DateTimeOffset>(type: "TEXT", nullable: true),
TokenHash = table.Column<string>(type: "TEXT", nullable: false),
IsRevoked = table.Column<bool>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Devices", x => x.Id);
});
migrationBuilder.CreateTable(
name: "SystemSettings",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
DefaultSystemPrompt = table.Column<string>(type: "TEXT", nullable: false),
DefaultVoice = table.Column<string>(type: "TEXT", nullable: false),
DefaultModel = table.Column<string>(type: "TEXT", nullable: false),
DefaultIdleTimeoutSeconds = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SystemSettings", x => x.Id);
});
migrationBuilder.CreateTable(
name: "DeviceConfigs",
columns: table => new
{
DeviceId = table.Column<Guid>(type: "TEXT", nullable: false),
SystemPrompt = table.Column<string>(type: "TEXT", nullable: false),
Voice = table.Column<string>(type: "TEXT", nullable: false),
Model = table.Column<string>(type: "TEXT", nullable: false),
IdleTimeoutSeconds = table.Column<int>(type: "INTEGER", nullable: false),
EnabledToolsJson = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DeviceConfigs", x => x.DeviceId);
table.ForeignKey(
name: "FK_DeviceConfigs_Devices_DeviceId",
column: x => x.DeviceId,
principalTable: "Devices",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Devices_OwnerUserId",
table: "Devices",
column: "OwnerUserId");
migrationBuilder.CreateIndex(
name: "IX_Devices_TokenHash",
table: "Devices",
column: "TokenHash",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "DeviceConfigs");
migrationBuilder.DropTable(
name: "SystemSettings");
migrationBuilder.DropTable(
name: "Devices");
}
}
}