using System; using Microsoft.EntityFrameworkCore.Migrations; namespace MP.FileData.Migrations { public partial class InitDb : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Macchine", columns: table => new { IdxMacchina = table.Column(type: "nvarchar(450)", nullable: false), RuleName = table.Column(type: "nvarchar(max)", nullable: true), Nome = table.Column(type: "nvarchar(max)", nullable: true), Descrizione = table.Column(type: "nvarchar(max)", nullable: true), BasePath = table.Column(type: "nvarchar(max)", nullable: true), ImgUrl = table.Column(type: "nvarchar(max)", nullable: true), Note = table.Column(type: "nvarchar(max)", nullable: true), ShowOrder = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Macchine", x => x.IdxMacchina); }); migrationBuilder.CreateTable( name: "Tags", columns: table => new { TagId = table.Column(type: "nvarchar(450)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Tags", x => x.TagId); }); migrationBuilder.CreateTable( name: "Files", columns: table => new { FileId = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Active = table.Column(type: "bit", nullable: false), IdxMacchina = table.Column(type: "nvarchar(450)", nullable: true), Name = table.Column(type: "nvarchar(max)", nullable: true), Rev = table.Column(type: "int", nullable: false), LastMod = table.Column(type: "datetime2", nullable: false), Size = table.Column(type: "bigint", nullable: false), Path = table.Column(type: "nvarchar(max)", nullable: true), MimeType = table.Column(type: "nvarchar(max)", nullable: true), MD5 = table.Column(type: "nvarchar(max)", nullable: true), DiskStatus = table.Column(type: "int", nullable: false), LastCheck = table.Column(type: "datetime2", nullable: false), FileContent = table.Column(type: "varbinary(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Files", x => x.FileId); table.ForeignKey( name: "FK_Files_Macchine_IdxMacchina", column: x => x.IdxMacchina, principalTable: "Macchine", principalColumn: "IdxMacchina", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "FileModelTagModel", columns: table => new { FilesFileId = table.Column(type: "int", nullable: false), TagsTagId = table.Column(type: "nvarchar(450)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_FileModelTagModel", x => new { x.FilesFileId, x.TagsTagId }); table.ForeignKey( name: "FK_FileModelTagModel_Files_FilesFileId", column: x => x.FilesFileId, principalTable: "Files", principalColumn: "FileId", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_FileModelTagModel_Tags_TagsTagId", column: x => x.TagsTagId, principalTable: "Tags", principalColumn: "TagId", onDelete: ReferentialAction.Cascade); }); migrationBuilder.InsertData( table: "Macchine", columns: new[] { "IdxMacchina", "BasePath", "Descrizione", "ImgUrl", "Nome", "Note", "RuleName", "ShowOrder" }, values: new object[] { "0", "", "--- Tutte ---", "", "--- Tutte ---", "", "0", 0 }); migrationBuilder.CreateIndex( name: "IX_FileModelTagModel_TagsTagId", table: "FileModelTagModel", column: "TagsTagId"); migrationBuilder.CreateIndex( name: "IX_Files_IdxMacchina_Active_DiskStatus", table: "Files", columns: new[] { "IdxMacchina", "Active", "DiskStatus" }); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "FileModelTagModel"); migrationBuilder.DropTable( name: "Files"); migrationBuilder.DropTable( name: "Tags"); migrationBuilder.DropTable( name: "Macchine"); } } }