using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace MessengerApi.Db.Sql.Migrations
{
///
public partial class Initial : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Messages",
columns: table => new
{
Id = table.Column(type: "uniqueidentifier", nullable: false),
CreatedUtc = table.Column(type: "datetime2", nullable: false),
FromId = table.Column(type: "uniqueidentifier", nullable: false),
ToId = table.Column(type: "uniqueidentifier", nullable: false),
IsDelivered = table.Column(type: "bit", nullable: false),
IsAcknowledged = table.Column(type: "bit", nullable: false),
PayloadType = table.Column(type: "nvarchar(max)", nullable: true),
Payload = table.Column(type: "nvarchar(max)", nullable: true),
PayloadLifespanInSeconds = table.Column(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Messages", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column(type: "uniqueidentifier", nullable: false),
ApiKey = table.Column(type: "uniqueidentifier", nullable: false),
Name = table.Column(type: "nvarchar(max)", nullable: true),
IsEnabled = table.Column(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "UserRoutes",
columns: table => new
{
Id = table.Column(type: "uniqueidentifier", nullable: false),
FromId = table.Column(type: "uniqueidentifier", nullable: true),
ToId = table.Column(type: "uniqueidentifier", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_UserRoutes", x => x.Id);
table.ForeignKey(
name: "FK_UserRoutes_Users_FromId",
column: x => x.FromId,
principalTable: "Users",
principalColumn: "Id");
table.ForeignKey(
name: "FK_UserRoutes_Users_ToId",
column: x => x.ToId,
principalTable: "Users",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_Messages_ToId_IsDelivered",
table: "Messages",
columns: new[] { "ToId", "IsDelivered" })
.Annotation("SqlServer:Clustered", false);
migrationBuilder.CreateIndex(
name: "IX_UserRoutes_FromId",
table: "UserRoutes",
column: "FromId");
migrationBuilder.CreateIndex(
name: "IX_UserRoutes_ToId",
table: "UserRoutes",
column: "ToId");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Messages");
migrationBuilder.DropTable(
name: "UserRoutes");
migrationBuilder.DropTable(
name: "Users");
}
}
}