using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace backend.Migrations
{
///
public partial class AddDevicesAndSettings : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Devices",
columns: table => new
{
Id = table.Column(type: "TEXT", nullable: false),
OwnerUserId = table.Column(type: "TEXT", nullable: false),
Name = table.Column(type: "TEXT", nullable: false),
PairedAt = table.Column(type: "TEXT", nullable: false),
LastSeenAt = table.Column(type: "TEXT", nullable: true),
TokenHash = table.Column(type: "TEXT", nullable: false),
IsRevoked = table.Column(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Devices", x => x.Id);
});
migrationBuilder.CreateTable(
name: "SystemSettings",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
DefaultSystemPrompt = table.Column(type: "TEXT", nullable: false),
DefaultVoice = table.Column(type: "TEXT", nullable: false),
DefaultModel = table.Column(type: "TEXT", nullable: false),
DefaultIdleTimeoutSeconds = table.Column(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SystemSettings", x => x.Id);
});
migrationBuilder.CreateTable(
name: "DeviceConfigs",
columns: table => new
{
DeviceId = table.Column(type: "TEXT", nullable: false),
SystemPrompt = table.Column(type: "TEXT", nullable: false),
Voice = table.Column(type: "TEXT", nullable: false),
Model = table.Column(type: "TEXT", nullable: false),
IdleTimeoutSeconds = table.Column(type: "INTEGER", nullable: false),
EnabledToolsJson = table.Column(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);
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "DeviceConfigs");
migrationBuilder.DropTable(
name: "SystemSettings");
migrationBuilder.DropTable(
name: "Devices");
}
}
}