157 lines
6.9 KiB
C#
157 lines
6.9 KiB
C#
namespace InventoryTraker.Web.Migrations
|
|
{
|
|
using System;
|
|
using System.Data.Entity.Migrations;
|
|
|
|
public partial class Initial : DbMigration
|
|
{
|
|
|
|
|
|
public override void Up()
|
|
{
|
|
CreateTable(
|
|
"dbo.Inventories",
|
|
c => new
|
|
{
|
|
Id = c.Int(nullable: false, identity: true),
|
|
ExpirationDate = c.DateTime(nullable: false),
|
|
AddedDate = c.DateTime(nullable: false),
|
|
Quantity = c.Int(nullable: false),
|
|
Memo = c.String(),
|
|
InventoryType_Id = c.Int(),
|
|
})
|
|
.PrimaryKey(t => t.Id)
|
|
.ForeignKey("dbo.InventoryTypes", t => t.InventoryType_Id)
|
|
.Index(t => t.InventoryType_Id);
|
|
|
|
CreateTable(
|
|
"dbo.InventoryTypes",
|
|
c => new
|
|
{
|
|
Id = c.Int(nullable: false, identity: true),
|
|
Identifier = c.String(nullable: false),
|
|
Name = c.String(nullable: false),
|
|
UnitsPerCase = c.Int(nullable: false),
|
|
ContainerType = c.String(nullable: false),
|
|
WeightPerCase = c.Double(nullable: false),
|
|
PricePerCase = c.Decimal(nullable: false, precision: 18, scale: 2),
|
|
})
|
|
.PrimaryKey(t => t.Id);
|
|
|
|
CreateTable(
|
|
"dbo.Transactions",
|
|
c => new
|
|
{
|
|
Id = c.Int(nullable: false, identity: true),
|
|
TransactionType = c.Int(nullable: false),
|
|
AddedQuantity = c.Int(nullable: false),
|
|
RemovedQuantity = c.Int(nullable: false),
|
|
CurrentQuantity = c.Int(nullable: false),
|
|
TransactionDate = c.DateTime(nullable: false),
|
|
Memo = c.String(),
|
|
Destination = c.String(),
|
|
Timestamp = c.DateTime(nullable: false),
|
|
Inventory_Id = c.Int(),
|
|
})
|
|
.PrimaryKey(t => t.Id)
|
|
.ForeignKey("dbo.Inventories", t => t.Inventory_Id)
|
|
.Index(t => t.Inventory_Id);
|
|
|
|
CreateTable(
|
|
"dbo.AspNetRoles",
|
|
c => new
|
|
{
|
|
Id = c.String(nullable: false, maxLength: 128),
|
|
Name = c.String(nullable: false, maxLength: 256),
|
|
})
|
|
.PrimaryKey(t => t.Id)
|
|
.Index(t => t.Name, unique: true, name: "RoleNameIndex");
|
|
|
|
CreateTable(
|
|
"dbo.AspNetUserRoles",
|
|
c => new
|
|
{
|
|
UserId = c.String(nullable: false, maxLength: 128),
|
|
RoleId = c.String(nullable: false, maxLength: 128),
|
|
})
|
|
.PrimaryKey(t => new { t.UserId, t.RoleId })
|
|
.ForeignKey("dbo.AspNetRoles", t => t.RoleId, cascadeDelete: true)
|
|
.ForeignKey("dbo.AspNetUsers", t => t.UserId, cascadeDelete: true)
|
|
.Index(t => t.UserId)
|
|
.Index(t => t.RoleId);
|
|
|
|
CreateTable(
|
|
"dbo.AspNetUsers",
|
|
c => new
|
|
{
|
|
Id = c.String(nullable: false, maxLength: 128),
|
|
Email = c.String(maxLength: 256),
|
|
EmailConfirmed = c.Boolean(nullable: false),
|
|
PasswordHash = c.String(),
|
|
SecurityStamp = c.String(),
|
|
PhoneNumber = c.String(),
|
|
PhoneNumberConfirmed = c.Boolean(nullable: false),
|
|
TwoFactorEnabled = c.Boolean(nullable: false),
|
|
LockoutEndDateUtc = c.DateTime(),
|
|
LockoutEnabled = c.Boolean(nullable: false),
|
|
AccessFailedCount = c.Int(nullable: false),
|
|
UserName = c.String(nullable: false, maxLength: 256),
|
|
})
|
|
.PrimaryKey(t => t.Id)
|
|
.Index(t => t.UserName, unique: true, name: "UserNameIndex");
|
|
|
|
CreateTable(
|
|
"dbo.AspNetUserClaims",
|
|
c => new
|
|
{
|
|
Id = c.Int(nullable: false, identity: true),
|
|
UserId = c.String(nullable: false, maxLength: 128),
|
|
ClaimType = c.String(),
|
|
ClaimValue = c.String(),
|
|
})
|
|
.PrimaryKey(t => t.Id)
|
|
.ForeignKey("dbo.AspNetUsers", t => t.UserId, cascadeDelete: true)
|
|
.Index(t => t.UserId);
|
|
|
|
CreateTable(
|
|
"dbo.AspNetUserLogins",
|
|
c => new
|
|
{
|
|
LoginProvider = c.String(nullable: false, maxLength: 128),
|
|
ProviderKey = c.String(nullable: false, maxLength: 128),
|
|
UserId = c.String(nullable: false, maxLength: 128),
|
|
})
|
|
.PrimaryKey(t => new { t.LoginProvider, t.ProviderKey, t.UserId })
|
|
.ForeignKey("dbo.AspNetUsers", t => t.UserId, cascadeDelete: true)
|
|
.Index(t => t.UserId);
|
|
|
|
}
|
|
|
|
public override void Down()
|
|
{
|
|
DropForeignKey("dbo.AspNetUserRoles", "UserId", "dbo.AspNetUsers");
|
|
DropForeignKey("dbo.AspNetUserLogins", "UserId", "dbo.AspNetUsers");
|
|
DropForeignKey("dbo.AspNetUserClaims", "UserId", "dbo.AspNetUsers");
|
|
DropForeignKey("dbo.AspNetUserRoles", "RoleId", "dbo.AspNetRoles");
|
|
DropForeignKey("dbo.Transactions", "Inventory_Id", "dbo.Inventories");
|
|
DropForeignKey("dbo.Inventories", "InventoryType_Id", "dbo.InventoryTypes");
|
|
DropIndex("dbo.AspNetUserLogins", new[] { "UserId" });
|
|
DropIndex("dbo.AspNetUserClaims", new[] { "UserId" });
|
|
DropIndex("dbo.AspNetUsers", "UserNameIndex");
|
|
DropIndex("dbo.AspNetUserRoles", new[] { "RoleId" });
|
|
DropIndex("dbo.AspNetUserRoles", new[] { "UserId" });
|
|
DropIndex("dbo.AspNetRoles", "RoleNameIndex");
|
|
DropIndex("dbo.Transactions", new[] { "Inventory_Id" });
|
|
DropIndex("dbo.Inventories", new[] { "InventoryType_Id" });
|
|
DropTable("dbo.AspNetUserLogins");
|
|
DropTable("dbo.AspNetUserClaims");
|
|
DropTable("dbo.AspNetUsers");
|
|
DropTable("dbo.AspNetUserRoles");
|
|
DropTable("dbo.AspNetRoles");
|
|
DropTable("dbo.Transactions");
|
|
DropTable("dbo.InventoryTypes");
|
|
DropTable("dbo.Inventories");
|
|
}
|
|
}
|
|
}
|