234 lines
11 KiB
C#
234 lines
11 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace FutureMailAPI.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class InitialCreate : 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", maxLength: 100, nullable: false),
|
|
Email = table.Column<string>(type: "TEXT", maxLength: 255, nullable: false),
|
|
PasswordHash = table.Column<string>(type: "TEXT", maxLength: 255, nullable: false),
|
|
Nickname = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
|
|
Avatar = table.Column<string>(type: "TEXT", maxLength: 500, nullable: true),
|
|
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"),
|
|
LastLoginAt = table.Column<DateTime>(type: "TEXT", nullable: true),
|
|
IsActive = table.Column<bool>(type: "INTEGER", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Users", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "SentMails",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
Title = table.Column<string>(type: "TEXT", maxLength: 200, nullable: false),
|
|
Content = table.Column<string>(type: "TEXT", nullable: false),
|
|
SenderId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
RecipientType = table.Column<int>(type: "INTEGER", nullable: false),
|
|
RecipientId = table.Column<int>(type: "INTEGER", nullable: true),
|
|
SentAt = table.Column<DateTime>(type: "TEXT", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"),
|
|
DeliveryTime = table.Column<DateTime>(type: "TEXT", nullable: false),
|
|
Status = table.Column<int>(type: "INTEGER", nullable: false),
|
|
TriggerType = table.Column<int>(type: "INTEGER", nullable: false),
|
|
TriggerDetails = table.Column<string>(type: "TEXT", nullable: true),
|
|
Attachments = table.Column<string>(type: "TEXT", nullable: true),
|
|
IsEncrypted = table.Column<bool>(type: "INTEGER", nullable: false),
|
|
EncryptionKey = table.Column<string>(type: "TEXT", nullable: true),
|
|
Theme = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
|
|
RecipientId1 = table.Column<int>(type: "INTEGER", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_SentMails", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_SentMails_Users_RecipientId",
|
|
column: x => x.RecipientId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
table.ForeignKey(
|
|
name: "FK_SentMails_Users_RecipientId1",
|
|
column: x => x.RecipientId1,
|
|
principalTable: "Users",
|
|
principalColumn: "Id");
|
|
table.ForeignKey(
|
|
name: "FK_SentMails_Users_SenderId",
|
|
column: x => x.SenderId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ReceivedMails",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
SentMailId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
RecipientId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
ReceivedAt = table.Column<DateTime>(type: "TEXT", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"),
|
|
IsRead = table.Column<bool>(type: "INTEGER", nullable: false),
|
|
ReadAt = table.Column<DateTime>(type: "TEXT", nullable: true),
|
|
IsReplied = table.Column<bool>(type: "INTEGER", nullable: false),
|
|
ReplyMailId = table.Column<int>(type: "INTEGER", nullable: true),
|
|
RecipientId1 = table.Column<int>(type: "INTEGER", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ReceivedMails", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_ReceivedMails_SentMails_SentMailId",
|
|
column: x => x.SentMailId,
|
|
principalTable: "SentMails",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_ReceivedMails_Users_RecipientId",
|
|
column: x => x.RecipientId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_ReceivedMails_Users_RecipientId1",
|
|
column: x => x.RecipientId1,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "TimeCapsules",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
UserId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
SentMailId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
PositionX = table.Column<double>(type: "REAL", nullable: false),
|
|
PositionY = table.Column<double>(type: "REAL", nullable: false),
|
|
PositionZ = table.Column<double>(type: "REAL", nullable: false),
|
|
Size = table.Column<double>(type: "REAL", nullable: false),
|
|
Color = table.Column<string>(type: "TEXT", maxLength: 20, nullable: true),
|
|
Opacity = table.Column<double>(type: "REAL", nullable: false),
|
|
Rotation = table.Column<double>(type: "REAL", nullable: false),
|
|
Status = table.Column<int>(type: "INTEGER", nullable: false),
|
|
Type = table.Column<int>(type: "INTEGER", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"),
|
|
SentMailId1 = table.Column<int>(type: "INTEGER", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_TimeCapsules", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_TimeCapsules_SentMails_SentMailId",
|
|
column: x => x.SentMailId,
|
|
principalTable: "SentMails",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_TimeCapsules_SentMails_SentMailId1",
|
|
column: x => x.SentMailId1,
|
|
principalTable: "SentMails",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_TimeCapsules_Users_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ReceivedMails_RecipientId",
|
|
table: "ReceivedMails",
|
|
column: "RecipientId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ReceivedMails_RecipientId1",
|
|
table: "ReceivedMails",
|
|
column: "RecipientId1");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ReceivedMails_SentMailId",
|
|
table: "ReceivedMails",
|
|
column: "SentMailId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SentMails_RecipientId",
|
|
table: "SentMails",
|
|
column: "RecipientId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SentMails_RecipientId1",
|
|
table: "SentMails",
|
|
column: "RecipientId1");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SentMails_SenderId",
|
|
table: "SentMails",
|
|
column: "SenderId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_TimeCapsules_SentMailId",
|
|
table: "TimeCapsules",
|
|
column: "SentMailId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_TimeCapsules_SentMailId1",
|
|
table: "TimeCapsules",
|
|
column: "SentMailId1");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_TimeCapsules_UserId",
|
|
table: "TimeCapsules",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Users_Email",
|
|
table: "Users",
|
|
column: "Email",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Users_Username",
|
|
table: "Users",
|
|
column: "Username",
|
|
unique: true);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "ReceivedMails");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "TimeCapsules");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "SentMails");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Users");
|
|
}
|
|
}
|
|
}
|