| | | 1 | | using System; |
| | | 2 | | using Microsoft.EntityFrameworkCore.Migrations; |
| | | 3 | | |
| | | 4 | | #nullable disable |
| | | 5 | | |
| | | 6 | | namespace LifeChart.Infrastructure.Migrations |
| | | 7 | | { |
| | | 8 | | /// <inheritdoc /> |
| | | 9 | | public partial class InitialCreate : Migration |
| | | 10 | | { |
| | | 11 | | /// <inheritdoc /> |
| | | 12 | | protected override void Up(MigrationBuilder migrationBuilder) |
| | | 13 | | { |
| | 0 | 14 | | migrationBuilder.CreateTable( |
| | 0 | 15 | | name: "DailyEntries", |
| | 0 | 16 | | columns: table => new |
| | 0 | 17 | | { |
| | 0 | 18 | | Id = table.Column<int>(type: "INTEGER", nullable: false) |
| | 0 | 19 | | .Annotation("Sqlite:Autoincrement", true), |
| | 0 | 20 | | Date = table.Column<DateTime>(type: "TEXT", nullable: false), |
| | 0 | 21 | | Mood = table.Column<int>(type: "INTEGER", nullable: false), |
| | 0 | 22 | | Functionality = table.Column<int>(type: "INTEGER", nullable: false), |
| | 0 | 23 | | SleepHours = table.Column<int>(type: "INTEGER", nullable: false), |
| | 0 | 24 | | MedicationTaken = table.Column<bool>(type: "INTEGER", nullable: false), |
| | 0 | 25 | | MenstrualCycle = table.Column<bool>(type: "INTEGER", nullable: false), |
| | 0 | 26 | | Symptoms = table.Column<string>(type: "TEXT", maxLength: 1000, nullable: true), |
| | 0 | 27 | | Notes = table.Column<string>(type: "TEXT", maxLength: 2000, nullable: true) |
| | 0 | 28 | | }, |
| | 0 | 29 | | constraints: table => |
| | 0 | 30 | | { |
| | 0 | 31 | | table.PrimaryKey("PK_DailyEntries", x => x.Id); |
| | 0 | 32 | | }); |
| | | 33 | | |
| | 0 | 34 | | migrationBuilder.CreateTable( |
| | 0 | 35 | | name: "Medications", |
| | 0 | 36 | | columns: table => new |
| | 0 | 37 | | { |
| | 0 | 38 | | Id = table.Column<int>(type: "INTEGER", nullable: false) |
| | 0 | 39 | | .Annotation("Sqlite:Autoincrement", true), |
| | 0 | 40 | | Name = table.Column<string>(type: "TEXT", maxLength: 200, nullable: false), |
| | 0 | 41 | | Dosage = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false), |
| | 0 | 42 | | MinStock = table.Column<int>(type: "INTEGER", nullable: false), |
| | 0 | 43 | | CurrentStock = table.Column<int>(type: "INTEGER", nullable: false), |
| | 0 | 44 | | Active = table.Column<bool>(type: "INTEGER", nullable: false) |
| | 0 | 45 | | }, |
| | 0 | 46 | | constraints: table => |
| | 0 | 47 | | { |
| | 0 | 48 | | table.PrimaryKey("PK_Medications", x => x.Id); |
| | 0 | 49 | | }); |
| | | 50 | | |
| | 0 | 51 | | migrationBuilder.CreateTable( |
| | 0 | 52 | | name: "IntakeTime", |
| | 0 | 53 | | columns: table => new |
| | 0 | 54 | | { |
| | 0 | 55 | | Id = table.Column<int>(type: "INTEGER", nullable: false) |
| | 0 | 56 | | .Annotation("Sqlite:Autoincrement", true), |
| | 0 | 57 | | Time = table.Column<string>(type: "TEXT", nullable: false), |
| | 0 | 58 | | DoseCount = table.Column<int>(type: "INTEGER", nullable: false), |
| | 0 | 59 | | MedicationId = table.Column<int>(type: "INTEGER", nullable: false) |
| | 0 | 60 | | }, |
| | 0 | 61 | | constraints: table => |
| | 0 | 62 | | { |
| | 0 | 63 | | table.PrimaryKey("PK_IntakeTime", x => x.Id); |
| | 0 | 64 | | table.ForeignKey( |
| | 0 | 65 | | name: "FK_IntakeTime_Medications_MedicationId", |
| | 0 | 66 | | column: x => x.MedicationId, |
| | 0 | 67 | | principalTable: "Medications", |
| | 0 | 68 | | principalColumn: "Id", |
| | 0 | 69 | | onDelete: ReferentialAction.Cascade); |
| | 0 | 70 | | }); |
| | | 71 | | |
| | 0 | 72 | | migrationBuilder.CreateIndex( |
| | 0 | 73 | | name: "IX_DailyEntries_Date", |
| | 0 | 74 | | table: "DailyEntries", |
| | 0 | 75 | | column: "Date", |
| | 0 | 76 | | unique: true); |
| | | 77 | | |
| | 0 | 78 | | migrationBuilder.CreateIndex( |
| | 0 | 79 | | name: "IX_IntakeTime_MedicationId", |
| | 0 | 80 | | table: "IntakeTime", |
| | 0 | 81 | | column: "MedicationId"); |
| | 0 | 82 | | } |
| | | 83 | | |
| | | 84 | | /// <inheritdoc /> |
| | | 85 | | protected override void Down(MigrationBuilder migrationBuilder) |
| | | 86 | | { |
| | 0 | 87 | | migrationBuilder.DropTable( |
| | 0 | 88 | | name: "DailyEntries"); |
| | | 89 | | |
| | 0 | 90 | | migrationBuilder.DropTable( |
| | 0 | 91 | | name: "IntakeTime"); |
| | | 92 | | |
| | 0 | 93 | | migrationBuilder.DropTable( |
| | 0 | 94 | | name: "Medications"); |
| | 0 | 95 | | } |
| | | 96 | | } |
| | | 97 | | } |