96 lines
3.6 KiB
C#
96 lines
3.6 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Api.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class init : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Users",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
UserName = table.Column<string>(type: "TEXT", nullable: false),
|
|
Password = table.Column<string>(type: "TEXT", nullable: false),
|
|
FullName = table.Column<string>(type: "TEXT", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Users", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Devices",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
TempHigh = table.Column<double>(type: "REAL", nullable: false),
|
|
TempLow = table.Column<double>(type: "REAL", nullable: false),
|
|
UserId = table.Column<int>(type: "INTEGER", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Devices", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Devices_Users_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "TemperatureLogs",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
Temperature = table.Column<double>(type: "REAL", nullable: false),
|
|
Date = table.Column<DateTime>(type: "TEXT", nullable: false),
|
|
TempHigh = table.Column<double>(type: "REAL", nullable: false),
|
|
TempLow = table.Column<double>(type: "REAL", nullable: false),
|
|
DeviceId = table.Column<int>(type: "INTEGER", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_TemperatureLogs", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_TemperatureLogs_Devices_DeviceId",
|
|
column: x => x.DeviceId,
|
|
principalTable: "Devices",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Devices_UserId",
|
|
table: "Devices",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_TemperatureLogs_DeviceId",
|
|
table: "TemperatureLogs",
|
|
column: "DeviceId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "TemperatureLogs");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Devices");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Users");
|
|
}
|
|
}
|
|
}
|