SimpleMessagingService

Log | Files | Refs | README

20240713180846_initial.cs (2318B)


      1 using System;
      2 using Microsoft.EntityFrameworkCore.Migrations;
      3 
      4 #nullable disable
      5 
      6 namespace Api.Migrations
      7 {
      8     /// <inheritdoc />
      9     public partial class initial : Migration
     10     {
     11         /// <inheritdoc />
     12         protected override void Up(MigrationBuilder migrationBuilder)
     13         {
     14             migrationBuilder.CreateTable(
     15                 name: "Users",
     16                 columns: table => new
     17                 {
     18                     Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
     19                     Key = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
     20                     CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
     21                 },
     22                 constraints: table =>
     23                 {
     24                     table.PrimaryKey("PK_Users", x => x.Name);
     25                 });
     26 
     27             migrationBuilder.CreateTable(
     28                 name: "Messages",
     29                 columns: table => new
     30                 {
     31                     Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
     32                     TimeStamp = table.Column<DateTime>(type: "datetime2", nullable: false),
     33                     Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
     34                     Content = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
     35                     UserName = table.Column<string>(type: "nvarchar(100)", nullable: true)
     36                 },
     37                 constraints: table =>
     38                 {
     39                     table.PrimaryKey("PK_Messages", x => x.Id);
     40                     table.ForeignKey(
     41                         name: "FK_Messages_Users_UserName",
     42                         column: x => x.UserName,
     43                         principalTable: "Users",
     44                         principalColumn: "Name");
     45                 });
     46 
     47             migrationBuilder.CreateIndex(
     48                 name: "IX_Messages_UserName",
     49                 table: "Messages",
     50                 column: "UserName");
     51         }
     52 
     53         /// <inheritdoc />
     54         protected override void Down(MigrationBuilder migrationBuilder)
     55         {
     56             migrationBuilder.DropTable(
     57                 name: "Messages");
     58 
     59             migrationBuilder.DropTable(
     60                 name: "Users");
     61         }
     62     }
     63 }