|
|
|
@ -0,0 +1,240 @@ |
|
|
|
|
using System; |
|
|
|
|
using Microsoft.EntityFrameworkCore.Metadata; |
|
|
|
|
using Microsoft.EntityFrameworkCore.Migrations; |
|
|
|
|
|
|
|
|
|
#nullable disable |
|
|
|
|
|
|
|
|
|
namespace PeacePDS.Migrations |
|
|
|
|
{ |
|
|
|
|
/// <inheritdoc /> |
|
|
|
|
public partial class InitialCreate : Migration |
|
|
|
|
{ |
|
|
|
|
/// <inheritdoc /> |
|
|
|
|
protected override void Up(MigrationBuilder migrationBuilder) |
|
|
|
|
{ |
|
|
|
|
migrationBuilder.AlterDatabase() |
|
|
|
|
.Annotation("MySql:CharSet", "utf8mb4"); |
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable( |
|
|
|
|
name: "Users", |
|
|
|
|
columns: table => new |
|
|
|
|
{ |
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false) |
|
|
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
|
|
|
|
Name = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false) |
|
|
|
|
.Annotation("MySql:CharSet", "utf8mb4"), |
|
|
|
|
HashedPassword = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: false) |
|
|
|
|
.Annotation("MySql:CharSet", "utf8mb4"), |
|
|
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false) |
|
|
|
|
}, |
|
|
|
|
constraints: table => |
|
|
|
|
{ |
|
|
|
|
table.PrimaryKey("PK_Users", x => x.Id); |
|
|
|
|
}) |
|
|
|
|
.Annotation("MySql:CharSet", "utf8mb4"); |
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable( |
|
|
|
|
name: "Affirmations", |
|
|
|
|
columns: table => new |
|
|
|
|
{ |
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false) |
|
|
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
|
|
|
|
UserId = table.Column<int>(type: "int", nullable: false), |
|
|
|
|
Month = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
|
|
|
|
AffirmationWord = table.Column<string>(type: "longtext", nullable: false) |
|
|
|
|
.Annotation("MySql:CharSet", "utf8mb4"), |
|
|
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false) |
|
|
|
|
}, |
|
|
|
|
constraints: table => |
|
|
|
|
{ |
|
|
|
|
table.PrimaryKey("PK_Affirmations", x => x.Id); |
|
|
|
|
table.ForeignKey( |
|
|
|
|
name: "FK_Affirmations_Users_UserId", |
|
|
|
|
column: x => x.UserId, |
|
|
|
|
principalTable: "Users", |
|
|
|
|
principalColumn: "Id", |
|
|
|
|
onDelete: ReferentialAction.Cascade); |
|
|
|
|
}) |
|
|
|
|
.Annotation("MySql:CharSet", "utf8mb4"); |
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable( |
|
|
|
|
name: "DailyEntries", |
|
|
|
|
columns: table => new |
|
|
|
|
{ |
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false) |
|
|
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
|
|
|
|
UserId = table.Column<int>(type: "int", nullable: false), |
|
|
|
|
EntryDate = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
|
|
|
|
Compliment = table.Column<string>(type: "longtext", nullable: true) |
|
|
|
|
.Annotation("MySql:CharSet", "utf8mb4"), |
|
|
|
|
Reflection = table.Column<string>(type: "longtext", nullable: true) |
|
|
|
|
.Annotation("MySql:CharSet", "utf8mb4"), |
|
|
|
|
Gratitude = table.Column<string>(type: "longtext", nullable: true) |
|
|
|
|
.Annotation("MySql:CharSet", "utf8mb4"), |
|
|
|
|
Journal = table.Column<string>(type: "longtext", nullable: true) |
|
|
|
|
.Annotation("MySql:CharSet", "utf8mb4"), |
|
|
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false) |
|
|
|
|
}, |
|
|
|
|
constraints: table => |
|
|
|
|
{ |
|
|
|
|
table.PrimaryKey("PK_DailyEntries", x => x.Id); |
|
|
|
|
table.ForeignKey( |
|
|
|
|
name: "FK_DailyEntries_Users_UserId", |
|
|
|
|
column: x => x.UserId, |
|
|
|
|
principalTable: "Users", |
|
|
|
|
principalColumn: "Id", |
|
|
|
|
onDelete: ReferentialAction.Cascade); |
|
|
|
|
}) |
|
|
|
|
.Annotation("MySql:CharSet", "utf8mb4"); |
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable( |
|
|
|
|
name: "DailyTasks", |
|
|
|
|
columns: table => new |
|
|
|
|
{ |
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false) |
|
|
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
|
|
|
|
UserId = table.Column<int>(type: "int", nullable: false), |
|
|
|
|
Date = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
|
|
|
|
TaskName = table.Column<string>(type: "longtext", nullable: false) |
|
|
|
|
.Annotation("MySql:CharSet", "utf8mb4"), |
|
|
|
|
IsCompleted = table.Column<bool>(type: "tinyint(1)", nullable: false), |
|
|
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false) |
|
|
|
|
}, |
|
|
|
|
constraints: table => |
|
|
|
|
{ |
|
|
|
|
table.PrimaryKey("PK_DailyTasks", x => x.Id); |
|
|
|
|
table.ForeignKey( |
|
|
|
|
name: "FK_DailyTasks_Users_UserId", |
|
|
|
|
column: x => x.UserId, |
|
|
|
|
principalTable: "Users", |
|
|
|
|
principalColumn: "Id", |
|
|
|
|
onDelete: ReferentialAction.Cascade); |
|
|
|
|
}) |
|
|
|
|
.Annotation("MySql:CharSet", "utf8mb4"); |
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable( |
|
|
|
|
name: "HabitTrackers", |
|
|
|
|
columns: table => new |
|
|
|
|
{ |
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false) |
|
|
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
|
|
|
|
UserId = table.Column<int>(type: "int", nullable: false), |
|
|
|
|
HabitName = table.Column<string>(type: "longtext", nullable: false) |
|
|
|
|
.Annotation("MySql:CharSet", "utf8mb4"), |
|
|
|
|
Month = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
|
|
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false) |
|
|
|
|
}, |
|
|
|
|
constraints: table => |
|
|
|
|
{ |
|
|
|
|
table.PrimaryKey("PK_HabitTrackers", x => x.Id); |
|
|
|
|
table.ForeignKey( |
|
|
|
|
name: "FK_HabitTrackers_Users_UserId", |
|
|
|
|
column: x => x.UserId, |
|
|
|
|
principalTable: "Users", |
|
|
|
|
principalColumn: "Id", |
|
|
|
|
onDelete: ReferentialAction.Cascade); |
|
|
|
|
}) |
|
|
|
|
.Annotation("MySql:CharSet", "utf8mb4"); |
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable( |
|
|
|
|
name: "UserPolicies", |
|
|
|
|
columns: table => new |
|
|
|
|
{ |
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false) |
|
|
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
|
|
|
|
UserId = table.Column<int>(type: "int", nullable: false), |
|
|
|
|
Policy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true) |
|
|
|
|
.Annotation("MySql:CharSet", "utf8mb4"), |
|
|
|
|
IsEnable = table.Column<bool>(type: "tinyint(1)", nullable: false) |
|
|
|
|
}, |
|
|
|
|
constraints: table => |
|
|
|
|
{ |
|
|
|
|
table.PrimaryKey("PK_UserPolicies", x => x.Id); |
|
|
|
|
table.ForeignKey( |
|
|
|
|
name: "FK_UserPolicies_Users_UserId", |
|
|
|
|
column: x => x.UserId, |
|
|
|
|
principalTable: "Users", |
|
|
|
|
principalColumn: "Id", |
|
|
|
|
onDelete: ReferentialAction.Cascade); |
|
|
|
|
}) |
|
|
|
|
.Annotation("MySql:CharSet", "utf8mb4"); |
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable( |
|
|
|
|
name: "HabitChecks", |
|
|
|
|
columns: table => new |
|
|
|
|
{ |
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false) |
|
|
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
|
|
|
|
HabitTrackerId = table.Column<int>(type: "int", nullable: false), |
|
|
|
|
CheckDate = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
|
|
|
|
IsCompleted = table.Column<bool>(type: "tinyint(1)", nullable: false) |
|
|
|
|
}, |
|
|
|
|
constraints: table => |
|
|
|
|
{ |
|
|
|
|
table.PrimaryKey("PK_HabitChecks", x => x.Id); |
|
|
|
|
table.ForeignKey( |
|
|
|
|
name: "FK_HabitChecks_HabitTrackers_HabitTrackerId", |
|
|
|
|
column: x => x.HabitTrackerId, |
|
|
|
|
principalTable: "HabitTrackers", |
|
|
|
|
principalColumn: "Id", |
|
|
|
|
onDelete: ReferentialAction.Cascade); |
|
|
|
|
}) |
|
|
|
|
.Annotation("MySql:CharSet", "utf8mb4"); |
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex( |
|
|
|
|
name: "IX_Affirmations_UserId", |
|
|
|
|
table: "Affirmations", |
|
|
|
|
column: "UserId"); |
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex( |
|
|
|
|
name: "IX_DailyEntries_UserId", |
|
|
|
|
table: "DailyEntries", |
|
|
|
|
column: "UserId"); |
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex( |
|
|
|
|
name: "IX_DailyTasks_UserId", |
|
|
|
|
table: "DailyTasks", |
|
|
|
|
column: "UserId"); |
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex( |
|
|
|
|
name: "IX_HabitChecks_HabitTrackerId", |
|
|
|
|
table: "HabitChecks", |
|
|
|
|
column: "HabitTrackerId"); |
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex( |
|
|
|
|
name: "IX_HabitTrackers_UserId", |
|
|
|
|
table: "HabitTrackers", |
|
|
|
|
column: "UserId"); |
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex( |
|
|
|
|
name: "IX_UserPolicies_UserId", |
|
|
|
|
table: "UserPolicies", |
|
|
|
|
column: "UserId"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <inheritdoc /> |
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder) |
|
|
|
|
{ |
|
|
|
|
migrationBuilder.DropTable( |
|
|
|
|
name: "Affirmations"); |
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable( |
|
|
|
|
name: "DailyEntries"); |
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable( |
|
|
|
|
name: "DailyTasks"); |
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable( |
|
|
|
|
name: "HabitChecks"); |
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable( |
|
|
|
|
name: "UserPolicies"); |
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable( |
|
|
|
|
name: "HabitTrackers"); |
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable( |
|
|
|
|
name: "Users"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |