Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JeroenVinke/d68a7403371449662c193bb9b44e0ae2 to your computer and use it in GitHub Desktop.
Save JeroenVinke/d68a7403371449662c193bb9b44e0ae2 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Metadata;
namespace Carmel.Migrations
{
public partial class Initial : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Components",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
CreatorName = table.Column<string>(nullable: true),
DateCreated = table.Column<DateTime>(nullable: false),
Name = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Components", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ComponentTag",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
ComponentId = table.Column<int>(nullable: true),
cTag = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ComponentTag", x => x.Id);
table.ForeignKey(
name: "FK_ComponentTag_Components_ComponentId",
column: x => x.ComponentId,
principalTable: "Components",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Samples",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
AddedDate = table.Column<DateTime>(nullable: false),
ComponentId = table.Column<int>(nullable: true),
Gist = table.Column<string>(nullable: true),
Name = table.Column<string>(nullable: true),
Order = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Samples", x => x.Id);
table.ForeignKey(
name: "FK_Samples_Components_ComponentId",
column: x => x.ComponentId,
principalTable: "Components",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "SampleTag",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
SampleId = table.Column<int>(nullable: true),
sTag = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_SampleTag", x => x.Id);
table.ForeignKey(
name: "FK_SampleTag_Samples_SampleId",
column: x => x.SampleId,
principalTable: "Samples",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_ComponentTag_ComponentId",
table: "ComponentTag",
column: "ComponentId");
migrationBuilder.CreateIndex(
name: "IX_Samples_ComponentId",
table: "Samples",
column: "ComponentId");
migrationBuilder.CreateIndex(
name: "IX_SampleTag_SampleId",
table: "SampleTag",
column: "SampleId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ComponentTag");
migrationBuilder.DropTable(
name: "SampleTag");
migrationBuilder.DropTable(
name: "Samples");
migrationBuilder.DropTable(
name: "Components");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment