| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- using Microsoft.EntityFrameworkCore.Migrations;
-
- #nullable disable
-
- namespace Diligent.WebAPI.Data.Migrations
- {
- public partial class AddedFileEntity : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "Files",
- columns: table => new
- {
- Id = table.Column<int>(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
- Size = table.Column<long>(type: "bigint", nullable: false),
- Extension = table.Column<string>(type: "nvarchar(max)", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Files", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "Tags",
- columns: table => new
- {
- Id = table.Column<int>(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Tags", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "Categories",
- columns: table => new
- {
- Id = table.Column<int>(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
- FileId = table.Column<int>(type: "int", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Categories", x => x.Id);
- table.ForeignKey(
- name: "FK_Categories_Files_FileId",
- column: x => x.FileId,
- principalTable: "Files",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "FileEntityTag",
- columns: table => new
- {
- FilesId = table.Column<int>(type: "int", nullable: false),
- TagsId = table.Column<int>(type: "int", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_FileEntityTag", x => new { x.FilesId, x.TagsId });
- table.ForeignKey(
- name: "FK_FileEntityTag_Files_FilesId",
- column: x => x.FilesId,
- principalTable: "Files",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_FileEntityTag_Tags_TagsId",
- column: x => x.TagsId,
- principalTable: "Tags",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateIndex(
- name: "IX_Categories_FileId",
- table: "Categories",
- column: "FileId");
-
- migrationBuilder.CreateIndex(
- name: "IX_FileEntityTag_TagsId",
- table: "FileEntityTag",
- column: "TagsId");
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "Categories");
-
- migrationBuilder.DropTable(
- name: "FileEntityTag");
-
- migrationBuilder.DropTable(
- name: "Files");
-
- migrationBuilder.DropTable(
- name: "Tags");
- }
- }
- }
|