Files
PlantPal/SoilMoistureAPI/Migrations/20250109170429_InitialCreate.cs
programmingPug 0f190a3f26 Major rewrite
2025-01-14 14:47:10 -05:00

64 lines
2.2 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SoilMoistureAPI.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Devices",
columns: table => new
{
DeviceId = table.Column<string>(type: "TEXT", nullable: false),
Nickname = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Devices", x => x.DeviceId);
});
migrationBuilder.CreateTable(
name: "SoilMoistures",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
DeviceId = table.Column<string>(type: "TEXT", nullable: false),
MoistureLevel = table.Column<float>(type: "REAL", nullable: false),
Timestamp = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SoilMoistures", x => x.Id);
table.ForeignKey(
name: "FK_SoilMoistures_Devices_DeviceId",
column: x => x.DeviceId,
principalTable: "Devices",
principalColumn: "DeviceId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_SoilMoistures_DeviceId",
table: "SoilMoistures",
column: "DeviceId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "SoilMoistures");
migrationBuilder.DropTable(
name: "Devices");
}
}
}