namespace Weee.Migrations { using System; using System.Data.Entity.Migrations; public partial class InitialCreate : DbMigration { public override void Up() { CreateTable( "dbo.ActionLogs", c => new { ID = c.Int(nullable: false, identity: true), Name = c.String(), Controller = c.String(), Action = c.String(), IP = c.String(), ActionTime = c.DateTime(nullable: false), ExecuteResult = c.String(), }) .PrimaryKey(t => t.ID); CreateTable( "dbo.Companies", c => new { ID = c.Int(nullable: false, identity: true), UID = c.Guid(nullable: false), LogoUrl = c.String(), Name = c.String(nullable: false, maxLength: 100), Address = c.String(nullable: false, maxLength: 300), VATNumber = c.String(nullable: false), CEOName = c.String(nullable: false), IndustryDescription = c.String(maxLength: 100), Description = c.String(maxLength: 500), WebSiteUrl = c.String(maxLength: 50), RegisterDate = c.DateTime(nullable: false), LastStatusUpdateDate = c.DateTime(nullable: false), Status = c.Int(nullable: false), }) .PrimaryKey(t => t.ID); CreateTable( "dbo.AspNetUsers", c => new { Id = c.String(nullable: false, maxLength: 128), UserName = c.String(nullable: false, maxLength: 256), Name = c.String(nullable: false), Department = c.String(), Job = c.String(), Email = c.String(nullable: false, maxLength: 256), PhoneNumber = c.String(), MobileNumber = c.String(), CompanyID = c.Int(), DefaultPassword = c.String(), IsCompanyAdmin = c.Boolean(nullable: false), IsSystemAdmin = c.Boolean(nullable: false), EmailConfirmed = c.Boolean(nullable: false), PasswordHash = c.String(), SecurityStamp = 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), }) .PrimaryKey(t => t.Id) .ForeignKey("dbo.Companies", t => t.CompanyID) .Index(t => t.UserName, unique: true, name: "UserNameIndex") .Index(t => t.CompanyID); 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.Fabs", c => new { ID = c.Int(nullable: false, identity: true), Name = c.String(nullable: false, maxLength: 50), Phone = c.String(nullable: false, maxLength: 30), WorkerNumber = c.Int(), Address = c.String(nullable: false, maxLength: 300), IsIso14064Passed = c.Boolean(nullable: false), CompanyID = c.Int(nullable: false), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.NormalCompany", t => t.CompanyID) .Index(t => t.CompanyID); CreateTable( "dbo.LCAs", c => new { ID = c.Int(nullable: false, identity: true), LCAStarter = c.String(), LCAStarterDepartment = c.String(), LCAStarterPhone = c.String(), LCAStarterJob = c.String(), InterrogationResultUrl = c.String(), ProductInventoryResultUrl = c.String(), CreatedDate = c.DateTime(nullable: false, precision: 7, storeType: "datetime2"), StartDate = c.DateTime(nullable: false, precision: 7, storeType: "datetime2"), EndDate = c.DateTime(nullable: false, precision: 7, storeType: "datetime2"), DeadLine = c.DateTime(), Description = c.String(maxLength: 200), OwnerID = c.Int(), VerifierCompanyID = c.Int(), Status = c.Int(nullable: false), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.NormalCompany", t => t.OwnerID) .ForeignKey("dbo.CertificationCompany", t => t.VerifierCompanyID) .Index(t => t.OwnerID) .Index(t => t.VerifierCompanyID); CreateTable( "dbo.Comments", c => new { ID = c.Int(nullable: false, identity: true), IsHistory = c.Boolean(nullable: false), Category = c.String(), CommentText = c.String(), CreateTime = c.DateTime(nullable: false, precision: 7, storeType: "datetime2"), UpdateTime = c.DateTime(nullable: false, precision: 7, storeType: "datetime2"), LCAID = c.Int(nullable: false), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.LCAs", t => t.LCAID, cascadeDelete: true) .Index(t => t.LCAID); CreateTable( "dbo.LCACommonSurveyForm_PowerUsages", c => new { ID = c.Int(nullable: false, identity: true), Peak = c.Decimal(precision: 18, scale: 6), HalfPeak = c.Decimal(precision: 18, scale: 6), SaturdayHalfPeak = c.Decimal(precision: 18, scale: 6), OffPeak = c.Decimal(precision: 18, scale: 6), ReferenceFileLink = c.String(), Index = c.Int(nullable: false), Scalar = c.Decimal(nullable: false, precision: 18, scale: 6), KgCO2e = c.Decimal(nullable: false, precision: 18, scale: 6), Area = c.String(), Year = c.String(), LCAID = c.Int(nullable: false), ParameterID = c.Int(), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.YearlyParameters", t => t.ParameterID) .ForeignKey("dbo.LCAs", t => t.LCAID, cascadeDelete: true) .Index(t => t.LCAID) .Index(t => t.ParameterID); CreateTable( "dbo.Parameters", c => new { ID = c.Int(nullable: false, identity: true), Value = c.Decimal(nullable: false, precision: 18, scale: 6), }) .PrimaryKey(t => t.ID); CreateTable( "dbo.YearlyParameterAreas", c => new { ID = c.Int(nullable: false, identity: true), CategoryID = c.Int(nullable: false), DisplayNameTW = c.String(nullable: false, maxLength: 200), DisplayNameCN = c.String(), DisplayNameEN = c.String(), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.YearlyParameterCategories", t => t.CategoryID) .Index(t => t.CategoryID); CreateTable( "dbo.YearlyParameterCategories", c => new { ID = c.Int(nullable: false, identity: true), Category = c.Int(nullable: false), }) .PrimaryKey(t => t.ID); CreateTable( "dbo.YearlyParameterTypes", c => new { ID = c.Int(nullable: false, identity: true), CategoryID = c.Int(nullable: false), DisplayNameTW = c.String(nullable: false, maxLength: 200), DisplayNameCN = c.String(), DisplayNameEN = c.String(), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.YearlyParameterCategories", t => t.CategoryID) .Index(t => t.CategoryID); CreateTable( "dbo.LCACommonSurveyForm_Refrigerants", c => new { ID = c.Int(nullable: false, identity: true), ModelNumber = c.String(), TotalNumber = c.Int(nullable: false), ParameterID = c.Int(nullable: false), ParameterID2 = c.Int(nullable: false), LCAID = c.Int(nullable: false), ProcessName = c.String(), ResponsibleUnit = c.String(), Name = c.String(), Scalar = c.Decimal(nullable: false, precision: 18, scale: 6), KgCO2e = c.Decimal(nullable: false, precision: 18, scale: 6), CreatedTime = c.DateTime(nullable: false, precision: 7, storeType: "datetime2"), NoteDescription = c.String(), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.NonYearlyParameters", t => t.ParameterID2) .ForeignKey("dbo.NonYearlyParameters", t => t.ParameterID) .ForeignKey("dbo.LCAs", t => t.LCAID, cascadeDelete: true) .Index(t => t.ParameterID) .Index(t => t.ParameterID2) .Index(t => t.LCAID); CreateTable( "dbo.NonYearlyParameterTypes", c => new { ID = c.Int(nullable: false, identity: true), CategoryID = c.Int(nullable: false), DisplayNameTW = c.String(nullable: false, maxLength: 200), DisplayNameCN = c.String(), DisplayNameEN = c.String(), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.NonYearlyParameterCategories", t => t.CategoryID, cascadeDelete: true) .Index(t => t.CategoryID); CreateTable( "dbo.NonYearlyParameterCategories", c => new { ID = c.Int(nullable: false, identity: true), Category = c.Int(nullable: false), }) .PrimaryKey(t => t.ID); CreateTable( "dbo.LCAStatusLogs", c => new { ID = c.Int(nullable: false, identity: true), NewStatus = c.Int(nullable: false), ActionTime = c.DateTime(nullable: false, precision: 7, storeType: "datetime2"), Description = c.String(), LCAID = c.Int(nullable: false), WhoDidThis = c.String(), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.LCAs", t => t.LCAID, cascadeDelete: true) .Index(t => t.LCAID); CreateTable( "dbo.LCACommonSurveyForm_SteamUsages", c => new { ID = c.Int(nullable: false, identity: true), Area = c.String(), Year = c.String(), ReferenceFileLink = c.String(), Scalar = c.Decimal(nullable: false, precision: 18, scale: 6), KgCO2e = c.Decimal(nullable: false, precision: 18, scale: 6), Index = c.Int(nullable: false), ParameterID = c.Int(), LCAID = c.Int(nullable: false), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.YearlyParameters", t => t.ParameterID) .ForeignKey("dbo.LCAs", t => t.LCAID, cascadeDelete: true) .Index(t => t.ParameterID) .Index(t => t.LCAID); CreateTable( "dbo.LCACommonSurveyForm_Vehicles", c => new { ID = c.Int(nullable: false, identity: true), CarPlateNo = c.String(), Type = c.Int(nullable: false), ReferenceFileUrl = c.String(), ReferencePhotoUrl = c.String(), ParameterID = c.Int(), LCAID = c.Int(nullable: false), ProcessName = c.String(), ResponsibleUnit = c.String(), Name = c.String(), Scalar = c.Decimal(nullable: false, precision: 18, scale: 6), KgCO2e = c.Decimal(nullable: false, precision: 18, scale: 6), CreatedTime = c.DateTime(nullable: false, precision: 7, storeType: "datetime2"), NoteDescription = c.String(), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.YearlyParameters", t => t.ParameterID) .ForeignKey("dbo.LCAs", t => t.LCAID, cascadeDelete: true) .Index(t => t.ParameterID) .Index(t => t.LCAID); CreateTable( "dbo.ProductLCAFabSurveyForm_FireEquipments", c => new { ID = c.Int(nullable: false, identity: true), Quantity = c.Int(nullable: false), ParameterID = c.Int(), LCAID = c.Int(nullable: false), ProcessName = c.String(), ResponsibleUnit = c.String(), Name = c.String(), Scalar = c.Decimal(nullable: false, precision: 18, scale: 6), KgCO2e = c.Decimal(nullable: false, precision: 18, scale: 6), CreatedTime = c.DateTime(nullable: false, precision: 7, storeType: "datetime2"), NoteDescription = c.String(), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.NonYearlyParameters", t => t.ParameterID) .ForeignKey("dbo.ProductLCA", t => t.LCAID) .Index(t => t.ParameterID) .Index(t => t.LCAID); CreateTable( "dbo.ProductLCAFabSurveyForm_GasolineEquipments", c => new { ID = c.Int(nullable: false, identity: true), ReferenceFileUrl = c.String(), ReferencePhotoUrl = c.String(), ParameterID = c.Int(), LCAID = c.Int(nullable: false), ProcessName = c.String(), ResponsibleUnit = c.String(), Name = c.String(), Scalar = c.Decimal(nullable: false, precision: 18, scale: 6), KgCO2e = c.Decimal(nullable: false, precision: 18, scale: 6), CreatedTime = c.DateTime(nullable: false, precision: 7, storeType: "datetime2"), NoteDescription = c.String(), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.YearlyParameters", t => t.ParameterID) .ForeignKey("dbo.ProductLCA", t => t.LCAID) .Index(t => t.ParameterID) .Index(t => t.LCAID); CreateTable( "dbo.ProductLCAFabSurveyForm_Kitchens", c => new { ID = c.Int(nullable: false, identity: true), ReferenceFileUrl = c.String(), ReferencePhotoUrl = c.String(), ParameterID = c.Int(), Type = c.Int(nullable: false), LCAID = c.Int(nullable: false), ProcessName = c.String(), ResponsibleUnit = c.String(), Name = c.String(), Scalar = c.Decimal(nullable: false, precision: 18, scale: 6), KgCO2e = c.Decimal(nullable: false, precision: 18, scale: 6), CreatedTime = c.DateTime(nullable: false, precision: 7, storeType: "datetime2"), NoteDescription = c.String(), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.YearlyParameters", t => t.ParameterID) .ForeignKey("dbo.ProductLCA", t => t.LCAID) .Index(t => t.ParameterID) .Index(t => t.LCAID); CreateTable( "dbo.ProductLCAProductSurveyForm_Materials", c => new { ID = c.Int(nullable: false, identity: true), Name = c.String(), LocalName = c.String(), Composite = c.String(), CompositePercentage = c.String(), CASNumber = c.String(), DQI = c.Int(nullable: false), Description = c.String(), PartNumber = c.String(), Quantity = c.Int(nullable: false), Scalar = c.Decimal(nullable: false, precision: 18, scale: 6), Unit = c.String(), HighLevelAnalyzeResult = c.Decimal(nullable: false, precision: 18, scale: 6), KgCO2e = c.Decimal(nullable: false, precision: 18, scale: 6), MaterialType = c.Int(), InputParameterValue = c.Decimal(precision: 18, scale: 6), IncludedInInterrogation = c.Boolean(), SupplierCompanyID = c.Int(), SupplierCompanyEmail = c.String(), LCAID = c.Int(nullable: false), ParameterTypeID = c.Int(), ParameterID = c.Int(), ParentMaterialID = c.Int(), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.SimaproParameters", t => t.ParameterID) .ForeignKey("dbo.SimaproParameterCategories", t => t.ParameterTypeID) .ForeignKey("dbo.ProductLCA", t => t.LCAID) .ForeignKey("dbo.ProductLCAProductSurveyForm_Materials", t => t.ParentMaterialID) .Index(t => t.LCAID) .Index(t => t.ParameterTypeID) .Index(t => t.ParameterID) .Index(t => t.ParentMaterialID); CreateTable( "dbo.SimaproParameterTypes", c => new { ID = c.Int(nullable: false, identity: true), CategoryID = c.Int(nullable: false), DisplayNameTW = c.String(nullable: false, maxLength: 200), DisplayNameCN = c.String(), DisplayNameEN = c.String(), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.SimaproParameterCategories", t => t.CategoryID, cascadeDelete: true) .Index(t => t.CategoryID); CreateTable( "dbo.SimaproParameterCategories", c => new { ID = c.Int(nullable: false, identity: true), VersionID = c.Int(nullable: false), DisplayNameTW = c.String(nullable: false, maxLength: 200), DisplayNameCN = c.String(), DisplayNameEN = c.String(), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.SimaproVersions", t => t.VersionID, cascadeDelete: true) .Index(t => t.VersionID); CreateTable( "dbo.SimaproVersions", c => new { ID = c.Int(nullable: false, identity: true), CreatedDate = c.DateTime(nullable: false, precision: 7, storeType: "datetime2"), IsActive = c.Boolean(nullable: false), IsDeleteable = c.Boolean(nullable: false), Version = c.String(), Description = c.String(), }) .PrimaryKey(t => t.ID); CreateTable( "dbo.ProductLCAReplyRequests", c => new { ID = c.Int(nullable: false), Distribute = c.String(), RepliedValue = c.Decimal(precision: 18, scale: 6), ReferenceFileLink = c.String(), DescriptionFromReceiver = c.String(), DescriptionFromSender = c.String(), CreatedDate = c.DateTime(nullable: false, precision: 7, storeType: "datetime2"), AcceptDate = c.DateTime(precision: 7, storeType: "datetime2"), ReplyDate = c.DateTime(precision: 7, storeType: "datetime2"), SenderCompanyName = c.String(nullable: false), Uid = c.Guid(nullable: false), RepliedLCAID = c.Int(), ReceiverCompanyID = c.Int(), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.ProductLCAProductSurveyForm_Materials", t => t.ID) .ForeignKey("dbo.ProductLCA", t => t.RepliedLCAID) .ForeignKey("dbo.NormalCompany", t => t.ReceiverCompanyID) .Index(t => t.ID) .Index(t => t.RepliedLCAID) .Index(t => t.ReceiverCompanyID); CreateTable( "dbo.ProductLCAFabSurveyForm_OtherCompounds", c => new { ID = c.Int(nullable: false, identity: true), ParameterID = c.Int(), LCAID = c.Int(nullable: false), ProcessName = c.String(), ResponsibleUnit = c.String(), Name = c.String(), Scalar = c.Decimal(nullable: false, precision: 18, scale: 6), KgCO2e = c.Decimal(nullable: false, precision: 18, scale: 6), CreatedTime = c.DateTime(nullable: false, precision: 7, storeType: "datetime2"), NoteDescription = c.String(), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.NonYearlyParameters", t => t.ParameterID) .ForeignKey("dbo.ProductLCA", t => t.LCAID) .Index(t => t.ParameterID) .Index(t => t.LCAID); CreateTable( "dbo.PCRs", c => new { ID = c.Int(nullable: false, identity: true), Percentage = c.Decimal(nullable: false, precision: 18, scale: 6), Description = c.String(), RecyclingParameterValue = c.Decimal(nullable: false, precision: 18, scale: 6), DisplayNameTW = c.String(nullable: false, maxLength: 200), DisplayNameCN = c.String(), DisplayNameEN = c.String(), }) .PrimaryKey(t => t.ID); CreateTable( "dbo.InventoryStageData", c => new { ID = c.Int(nullable: false, identity: true), WattInOperation = c.Decimal(nullable: false, precision: 18, scale: 6), WattInLowOperation = c.Decimal(nullable: false, precision: 18, scale: 6), TurnOnHourPerDayInWorkDay = c.Int(nullable: false), TurnOnHourPerDayInOffDay = c.Int(nullable: false), WorkDayPerYear = c.Int(nullable: false), ProductDevStageFunctionUnit = c.String(nullable: false), ProductDevStageDuringInventory = c.String(nullable: false), ProductDevStageCarbonFootprint = c.Decimal(nullable: false, precision: 18, scale: 6), ProductDevStageDescription = c.String(), ProductDevStageAddress = c.String(nullable: false), ProductUsageStagePowerFactor = c.Decimal(nullable: false, precision: 18, scale: 6), ProductUsageStageDescription = c.String(), ProductAbandonedStage = c.String(nullable: false), ProductAbandonedStageCarbonFootprint = c.Decimal(nullable: false, precision: 18, scale: 6), }) .PrimaryKey(t => t.ID); CreateTable( "dbo.Products", c => new { ID = c.Int(nullable: false, identity: true), Name = c.String(nullable: false, maxLength: 50), SpecDescription = c.String(nullable: false, maxLength: 300), Weight = c.Decimal(precision: 18, scale: 6), AreaSize = c.Decimal(precision: 18, scale: 6), PcsPerYear = c.Decimal(precision: 18, scale: 6), PhotoUrl = c.String(), EcoFriendlyDescription = c.String(), EcoFriendlySymbol = c.String(), SerialNumber = c.String(), CompanyID = c.Int(nullable: false), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.NormalCompany", t => t.CompanyID) .Index(t => t.CompanyID); CreateTable( "dbo.ProductLCAFabSurveyForm_Transports", c => new { ID = c.Int(nullable: false, identity: true), TransportDate = c.DateTime(nullable: false), JourneyNO = c.String(), StartLocation = c.String(), EndLocation = c.String(), TransportDistance = c.Decimal(nullable: false, precision: 18, scale: 6), TransportQuantity = c.Decimal(nullable: false, precision: 18, scale: 6), TransportWeight = c.Decimal(nullable: false, precision: 18, scale: 6), Scalar = c.Decimal(nullable: false, precision: 18, scale: 6), KgCO2e = c.Decimal(nullable: false, precision: 18, scale: 6), DQI = c.Int(nullable: false), ParameterID = c.Int(), LCAID = c.Int(nullable: false), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.NonYearlyParameters", t => t.ParameterID) .ForeignKey("dbo.ProductLCA", t => t.LCAID) .Index(t => t.ParameterID) .Index(t => t.LCAID); CreateTable( "dbo.ProductLCAFabSurveyForm_Wastes", c => new { ID = c.Int(nullable: false, identity: true), WaterBOD = c.Decimal(nullable: false, precision: 18, scale: 6), WaterCOD = c.Decimal(nullable: false, precision: 18, scale: 6), WaterCMD = c.Decimal(nullable: false, precision: 18, scale: 6), Scalar = c.Decimal(nullable: false, precision: 18, scale: 6), KgCO2e = c.Decimal(nullable: false, precision: 18, scale: 6), DQI = c.Int(nullable: false), DQIDescription = c.String(), Description = c.String(), Type = c.Int(nullable: false), ParameterID = c.Int(), LCAID = c.Int(nullable: false), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.NonYearlyParameters", t => t.ParameterID) .ForeignKey("dbo.ProductLCA", t => t.LCAID) .Index(t => t.ParameterID) .Index(t => t.LCAID); CreateTable( "dbo.ProductLCAFabSurveyForm_WasteTransports", c => new { ID = c.Int(nullable: false, identity: true), JourneyNO = c.String(), StartLocation = c.String(), EndLocation = c.String(), TransportDistance = c.Decimal(nullable: false, precision: 18, scale: 6), TransportWeight = c.Decimal(nullable: false, precision: 18, scale: 6), WasteName = c.String(), Scalar = c.Decimal(nullable: false, precision: 18, scale: 6), KgCO2e = c.Decimal(nullable: false, precision: 18, scale: 6), DQI = c.Int(nullable: false), ParameterID = c.Int(), LCAID = c.Int(nullable: false), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.NonYearlyParameters", t => t.ParameterID) .ForeignKey("dbo.ProductLCA", t => t.LCAID) .Index(t => t.ParameterID) .Index(t => t.LCAID); CreateTable( "dbo.ProductLCAFabSurveyForm_WaterUsages", c => new { ID = c.Int(nullable: false, identity: true), ReferenceFileLink = c.String(), Index = c.Int(nullable: false), Scalar = c.Decimal(nullable: false, precision: 18, scale: 6), KgCO2e = c.Decimal(nullable: false, precision: 18, scale: 6), Area = c.String(), Year = c.String(), ReferenceLink = c.String(), LCAID = c.Int(nullable: false), ParameterID = c.Int(), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.YearlyParameters", t => t.ParameterID) .ForeignKey("dbo.ProductLCA", t => t.LCAID) .Index(t => t.LCAID) .Index(t => t.ParameterID); CreateTable( "dbo.ProductLCAFabSurveyForm_WorkHours", c => new { ID = c.Int(nullable: false, identity: true), WorkerNumber = c.Int(nullable: false), WorkDay = c.Int(nullable: false), AverageHourPerDay = c.Decimal(nullable: false, precision: 18, scale: 6), Type = c.Int(nullable: false), Index = c.Int(nullable: false), Scalar = c.Decimal(nullable: false, precision: 18, scale: 6), KgCO2e = c.Decimal(nullable: false, precision: 18, scale: 6), LCAID = c.Int(nullable: false), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.ProductLCA", t => t.LCAID) .Index(t => t.LCAID); CreateTable( "dbo.Suppliers", c => new { ID = c.Int(nullable: false, identity: true), Name = c.String(), Address = c.String(), Phone = c.String(), ContactName = c.String(), ContactPhone = c.String(), ContactEmail = c.String(), Description = c.String(), CompanyID = c.Int(nullable: false), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.NormalCompany", t => t.CompanyID) .Index(t => t.CompanyID); 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); 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.AspNetUsers", t => t.UserId, cascadeDelete: true) .ForeignKey("dbo.AspNetRoles", t => t.RoleId, cascadeDelete: true) .Index(t => t.UserId) .Index(t => t.RoleId); CreateTable( "dbo.PublicMessages", c => new { ID = c.Int(nullable: false, identity: true), Note = c.String(), CreatedTime = c.DateTime(nullable: false), UpdatedTime = c.DateTime(nullable: false), DisplayNameTW = c.String(nullable: false, maxLength: 200), DisplayNameCN = c.String(), DisplayNameEN = c.String(), }) .PrimaryKey(t => t.ID); CreateTable( "dbo.PublicReferenceFiles", c => new { ID = c.Int(nullable: false, identity: true), CreatedTime = c.DateTime(nullable: false), UpdatedTime = c.DateTime(nullable: false), DownloadLink = c.String(), IsHidden = c.Boolean(nullable: false), DisplayNameTW = c.String(nullable: false, maxLength: 200), DisplayNameCN = c.String(), DisplayNameEN = c.String(), }) .PrimaryKey(t => t.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.SheetHeaders", c => new { LCAID = c.Int(nullable: false), Category = c.Int(nullable: false), SheetFillerName = c.String(), Phone = c.String(), Department = c.String(), }) .PrimaryKey(t => new { t.LCAID, t.Category }); CreateTable( "dbo.CertificationCompany", c => new { ID = c.Int(nullable: false), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.Companies", t => t.ID) .Index(t => t.ID); CreateTable( "dbo.NonYearlyParameters", c => new { ID = c.Int(nullable: false), Description = c.String(), IsHistory = c.Boolean(nullable: false), CreateTime = c.DateTime(nullable: false, precision: 7, storeType: "datetime2"), TypeID = c.Int(nullable: false), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.Parameters", t => t.ID) .ForeignKey("dbo.NonYearlyParameterTypes", t => t.TypeID, cascadeDelete: true) .Index(t => t.ID) .Index(t => t.TypeID); CreateTable( "dbo.NormalCompany", c => new { ID = c.Int(nullable: false), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.Companies", t => t.ID) .Index(t => t.ID); CreateTable( "dbo.OrganizationLCA", c => new { ID = c.Int(nullable: false), FabID = c.Int(), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.LCAs", t => t.ID) .ForeignKey("dbo.Fabs", t => t.FabID) .Index(t => t.ID) .Index(t => t.FabID); CreateTable( "dbo.ProductLCA", c => new { ID = c.Int(nullable: false), PCRID = c.Int(), ProductID = c.Int(), FabID = c.Int(), InventoryStageDataID = c.Int(), FabProductionWeight = c.Decimal(precision: 18, scale: 6), FabProductionArea = c.Decimal(precision: 18, scale: 6), FabProductionHour = c.Decimal(precision: 18, scale: 6), ProductProductionPcs = c.Decimal(precision: 18, scale: 6), ProductProductionHour = c.Decimal(precision: 18, scale: 6), DistributeKgCO2eInWeight = c.Decimal(precision: 18, scale: 6), DistributeKgCO2eInArea = c.Decimal(precision: 18, scale: 6), DistributeKgCO2eInWorkHour = c.Decimal(precision: 18, scale: 6), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.LCAs", t => t.ID) .ForeignKey("dbo.PCRs", t => t.PCRID) .ForeignKey("dbo.Products", t => t.ProductID) .ForeignKey("dbo.Fabs", t => t.FabID) .ForeignKey("dbo.InventoryStageData", t => t.InventoryStageDataID) .Index(t => t.ID) .Index(t => t.PCRID) .Index(t => t.ProductID) .Index(t => t.FabID) .Index(t => t.InventoryStageDataID); CreateTable( "dbo.SimaproParameters", c => new { ID = c.Int(nullable: false), Encoding = c.String(), Unit = c.String(), Remark = c.String(), Database = c.String(), Description = c.String(), CreateTime = c.DateTime(nullable: false, precision: 7, storeType: "datetime2"), TypeID = c.Int(nullable: false), DisplayNameTW = c.String(nullable: false, maxLength: 200), DisplayNameCN = c.String(), DisplayNameEN = c.String(), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.Parameters", t => t.ID) .ForeignKey("dbo.SimaproParameterTypes", t => t.TypeID, cascadeDelete: true) .Index(t => t.ID) .Index(t => t.TypeID); CreateTable( "dbo.YearlyParameters", c => new { ID = c.Int(nullable: false), Year = c.Int(nullable: false), CreateTime = c.DateTime(nullable: false, precision: 7, storeType: "datetime2"), Description = c.String(), IsHistory = c.Boolean(nullable: false), AreaID = c.Int(nullable: false), TypeID = c.Int(nullable: false), }) .PrimaryKey(t => t.ID) .ForeignKey("dbo.Parameters", t => t.ID) .ForeignKey("dbo.YearlyParameterAreas", t => t.AreaID, cascadeDelete: true) .ForeignKey("dbo.YearlyParameterTypes", t => t.TypeID, cascadeDelete: true) .Index(t => t.ID) .Index(t => t.AreaID) .Index(t => t.TypeID); } public override void Down() { DropForeignKey("dbo.YearlyParameters", "TypeID", "dbo.YearlyParameterTypes"); DropForeignKey("dbo.YearlyParameters", "AreaID", "dbo.YearlyParameterAreas"); DropForeignKey("dbo.YearlyParameters", "ID", "dbo.Parameters"); DropForeignKey("dbo.SimaproParameters", "TypeID", "dbo.SimaproParameterTypes"); DropForeignKey("dbo.SimaproParameters", "ID", "dbo.Parameters"); DropForeignKey("dbo.ProductLCA", "InventoryStageDataID", "dbo.InventoryStageData"); DropForeignKey("dbo.ProductLCA", "FabID", "dbo.Fabs"); DropForeignKey("dbo.ProductLCA", "ProductID", "dbo.Products"); DropForeignKey("dbo.ProductLCA", "PCRID", "dbo.PCRs"); DropForeignKey("dbo.ProductLCA", "ID", "dbo.LCAs"); DropForeignKey("dbo.OrganizationLCA", "FabID", "dbo.Fabs"); DropForeignKey("dbo.OrganizationLCA", "ID", "dbo.LCAs"); DropForeignKey("dbo.NormalCompany", "ID", "dbo.Companies"); DropForeignKey("dbo.NonYearlyParameters", "TypeID", "dbo.NonYearlyParameterTypes"); DropForeignKey("dbo.NonYearlyParameters", "ID", "dbo.Parameters"); DropForeignKey("dbo.CertificationCompany", "ID", "dbo.Companies"); DropForeignKey("dbo.AspNetUserRoles", "RoleId", "dbo.AspNetRoles"); DropForeignKey("dbo.LCAs", "VerifierCompanyID", "dbo.CertificationCompany"); DropForeignKey("dbo.AspNetUserRoles", "UserId", "dbo.AspNetUsers"); DropForeignKey("dbo.AspNetUserLogins", "UserId", "dbo.AspNetUsers"); DropForeignKey("dbo.Suppliers", "CompanyID", "dbo.NormalCompany"); DropForeignKey("dbo.ProductLCAReplyRequests", "ReceiverCompanyID", "dbo.NormalCompany"); DropForeignKey("dbo.Products", "CompanyID", "dbo.NormalCompany"); DropForeignKey("dbo.LCAs", "OwnerID", "dbo.NormalCompany"); DropForeignKey("dbo.Fabs", "CompanyID", "dbo.NormalCompany"); DropForeignKey("dbo.ProductLCAFabSurveyForm_WorkHours", "LCAID", "dbo.ProductLCA"); DropForeignKey("dbo.ProductLCAFabSurveyForm_WaterUsages", "LCAID", "dbo.ProductLCA"); DropForeignKey("dbo.ProductLCAFabSurveyForm_WaterUsages", "ParameterID", "dbo.YearlyParameters"); DropForeignKey("dbo.ProductLCAFabSurveyForm_WasteTransports", "LCAID", "dbo.ProductLCA"); DropForeignKey("dbo.ProductLCAFabSurveyForm_WasteTransports", "ParameterID", "dbo.NonYearlyParameters"); DropForeignKey("dbo.ProductLCAFabSurveyForm_Wastes", "LCAID", "dbo.ProductLCA"); DropForeignKey("dbo.ProductLCAFabSurveyForm_Wastes", "ParameterID", "dbo.NonYearlyParameters"); DropForeignKey("dbo.ProductLCAFabSurveyForm_Transports", "LCAID", "dbo.ProductLCA"); DropForeignKey("dbo.ProductLCAFabSurveyForm_Transports", "ParameterID", "dbo.NonYearlyParameters"); DropForeignKey("dbo.ProductLCAReplyRequests", "RepliedLCAID", "dbo.ProductLCA"); DropForeignKey("dbo.ProductLCAFabSurveyForm_OtherCompounds", "LCAID", "dbo.ProductLCA"); DropForeignKey("dbo.ProductLCAFabSurveyForm_OtherCompounds", "ParameterID", "dbo.NonYearlyParameters"); DropForeignKey("dbo.ProductLCAReplyRequests", "ID", "dbo.ProductLCAProductSurveyForm_Materials"); DropForeignKey("dbo.ProductLCAProductSurveyForm_Materials", "ParentMaterialID", "dbo.ProductLCAProductSurveyForm_Materials"); DropForeignKey("dbo.ProductLCAProductSurveyForm_Materials", "LCAID", "dbo.ProductLCA"); DropForeignKey("dbo.ProductLCAProductSurveyForm_Materials", "ParameterTypeID", "dbo.SimaproParameterCategories"); DropForeignKey("dbo.ProductLCAProductSurveyForm_Materials", "ParameterID", "dbo.SimaproParameters"); DropForeignKey("dbo.SimaproParameterTypes", "CategoryID", "dbo.SimaproParameterCategories"); DropForeignKey("dbo.SimaproParameterCategories", "VersionID", "dbo.SimaproVersions"); DropForeignKey("dbo.ProductLCAFabSurveyForm_Kitchens", "LCAID", "dbo.ProductLCA"); DropForeignKey("dbo.ProductLCAFabSurveyForm_Kitchens", "ParameterID", "dbo.YearlyParameters"); DropForeignKey("dbo.ProductLCAFabSurveyForm_GasolineEquipments", "LCAID", "dbo.ProductLCA"); DropForeignKey("dbo.ProductLCAFabSurveyForm_GasolineEquipments", "ParameterID", "dbo.YearlyParameters"); DropForeignKey("dbo.ProductLCAFabSurveyForm_FireEquipments", "LCAID", "dbo.ProductLCA"); DropForeignKey("dbo.ProductLCAFabSurveyForm_FireEquipments", "ParameterID", "dbo.NonYearlyParameters"); DropForeignKey("dbo.LCACommonSurveyForm_Vehicles", "LCAID", "dbo.LCAs"); DropForeignKey("dbo.LCACommonSurveyForm_Vehicles", "ParameterID", "dbo.YearlyParameters"); DropForeignKey("dbo.LCACommonSurveyForm_SteamUsages", "LCAID", "dbo.LCAs"); DropForeignKey("dbo.LCACommonSurveyForm_SteamUsages", "ParameterID", "dbo.YearlyParameters"); DropForeignKey("dbo.LCAStatusLogs", "LCAID", "dbo.LCAs"); DropForeignKey("dbo.LCACommonSurveyForm_Refrigerants", "LCAID", "dbo.LCAs"); DropForeignKey("dbo.LCACommonSurveyForm_Refrigerants", "ParameterID", "dbo.NonYearlyParameters"); DropForeignKey("dbo.LCACommonSurveyForm_Refrigerants", "ParameterID2", "dbo.NonYearlyParameters"); DropForeignKey("dbo.NonYearlyParameterTypes", "CategoryID", "dbo.NonYearlyParameterCategories"); DropForeignKey("dbo.LCACommonSurveyForm_PowerUsages", "LCAID", "dbo.LCAs"); DropForeignKey("dbo.LCACommonSurveyForm_PowerUsages", "ParameterID", "dbo.YearlyParameters"); DropForeignKey("dbo.YearlyParameterTypes", "CategoryID", "dbo.YearlyParameterCategories"); DropForeignKey("dbo.YearlyParameterAreas", "CategoryID", "dbo.YearlyParameterCategories"); DropForeignKey("dbo.Comments", "LCAID", "dbo.LCAs"); DropForeignKey("dbo.AspNetUsers", "CompanyID", "dbo.Companies"); DropForeignKey("dbo.AspNetUserClaims", "UserId", "dbo.AspNetUsers"); DropIndex("dbo.YearlyParameters", new[] { "TypeID" }); DropIndex("dbo.YearlyParameters", new[] { "AreaID" }); DropIndex("dbo.YearlyParameters", new[] { "ID" }); DropIndex("dbo.SimaproParameters", new[] { "TypeID" }); DropIndex("dbo.SimaproParameters", new[] { "ID" }); DropIndex("dbo.ProductLCA", new[] { "InventoryStageDataID" }); DropIndex("dbo.ProductLCA", new[] { "FabID" }); DropIndex("dbo.ProductLCA", new[] { "ProductID" }); DropIndex("dbo.ProductLCA", new[] { "PCRID" }); DropIndex("dbo.ProductLCA", new[] { "ID" }); DropIndex("dbo.OrganizationLCA", new[] { "FabID" }); DropIndex("dbo.OrganizationLCA", new[] { "ID" }); DropIndex("dbo.NormalCompany", new[] { "ID" }); DropIndex("dbo.NonYearlyParameters", new[] { "TypeID" }); DropIndex("dbo.NonYearlyParameters", new[] { "ID" }); DropIndex("dbo.CertificationCompany", new[] { "ID" }); DropIndex("dbo.AspNetRoles", "RoleNameIndex"); DropIndex("dbo.AspNetUserRoles", new[] { "RoleId" }); DropIndex("dbo.AspNetUserRoles", new[] { "UserId" }); DropIndex("dbo.AspNetUserLogins", new[] { "UserId" }); DropIndex("dbo.Suppliers", new[] { "CompanyID" }); DropIndex("dbo.ProductLCAFabSurveyForm_WorkHours", new[] { "LCAID" }); DropIndex("dbo.ProductLCAFabSurveyForm_WaterUsages", new[] { "ParameterID" }); DropIndex("dbo.ProductLCAFabSurveyForm_WaterUsages", new[] { "LCAID" }); DropIndex("dbo.ProductLCAFabSurveyForm_WasteTransports", new[] { "LCAID" }); DropIndex("dbo.ProductLCAFabSurveyForm_WasteTransports", new[] { "ParameterID" }); DropIndex("dbo.ProductLCAFabSurveyForm_Wastes", new[] { "LCAID" }); DropIndex("dbo.ProductLCAFabSurveyForm_Wastes", new[] { "ParameterID" }); DropIndex("dbo.ProductLCAFabSurveyForm_Transports", new[] { "LCAID" }); DropIndex("dbo.ProductLCAFabSurveyForm_Transports", new[] { "ParameterID" }); DropIndex("dbo.Products", new[] { "CompanyID" }); DropIndex("dbo.ProductLCAFabSurveyForm_OtherCompounds", new[] { "LCAID" }); DropIndex("dbo.ProductLCAFabSurveyForm_OtherCompounds", new[] { "ParameterID" }); DropIndex("dbo.ProductLCAReplyRequests", new[] { "ReceiverCompanyID" }); DropIndex("dbo.ProductLCAReplyRequests", new[] { "RepliedLCAID" }); DropIndex("dbo.ProductLCAReplyRequests", new[] { "ID" }); DropIndex("dbo.SimaproParameterCategories", new[] { "VersionID" }); DropIndex("dbo.SimaproParameterTypes", new[] { "CategoryID" }); DropIndex("dbo.ProductLCAProductSurveyForm_Materials", new[] { "ParentMaterialID" }); DropIndex("dbo.ProductLCAProductSurveyForm_Materials", new[] { "ParameterID" }); DropIndex("dbo.ProductLCAProductSurveyForm_Materials", new[] { "ParameterTypeID" }); DropIndex("dbo.ProductLCAProductSurveyForm_Materials", new[] { "LCAID" }); DropIndex("dbo.ProductLCAFabSurveyForm_Kitchens", new[] { "LCAID" }); DropIndex("dbo.ProductLCAFabSurveyForm_Kitchens", new[] { "ParameterID" }); DropIndex("dbo.ProductLCAFabSurveyForm_GasolineEquipments", new[] { "LCAID" }); DropIndex("dbo.ProductLCAFabSurveyForm_GasolineEquipments", new[] { "ParameterID" }); DropIndex("dbo.ProductLCAFabSurveyForm_FireEquipments", new[] { "LCAID" }); DropIndex("dbo.ProductLCAFabSurveyForm_FireEquipments", new[] { "ParameterID" }); DropIndex("dbo.LCACommonSurveyForm_Vehicles", new[] { "LCAID" }); DropIndex("dbo.LCACommonSurveyForm_Vehicles", new[] { "ParameterID" }); DropIndex("dbo.LCACommonSurveyForm_SteamUsages", new[] { "LCAID" }); DropIndex("dbo.LCACommonSurveyForm_SteamUsages", new[] { "ParameterID" }); DropIndex("dbo.LCAStatusLogs", new[] { "LCAID" }); DropIndex("dbo.NonYearlyParameterTypes", new[] { "CategoryID" }); DropIndex("dbo.LCACommonSurveyForm_Refrigerants", new[] { "LCAID" }); DropIndex("dbo.LCACommonSurveyForm_Refrigerants", new[] { "ParameterID2" }); DropIndex("dbo.LCACommonSurveyForm_Refrigerants", new[] { "ParameterID" }); DropIndex("dbo.YearlyParameterTypes", new[] { "CategoryID" }); DropIndex("dbo.YearlyParameterAreas", new[] { "CategoryID" }); DropIndex("dbo.LCACommonSurveyForm_PowerUsages", new[] { "ParameterID" }); DropIndex("dbo.LCACommonSurveyForm_PowerUsages", new[] { "LCAID" }); DropIndex("dbo.Comments", new[] { "LCAID" }); DropIndex("dbo.LCAs", new[] { "VerifierCompanyID" }); DropIndex("dbo.LCAs", new[] { "OwnerID" }); DropIndex("dbo.Fabs", new[] { "CompanyID" }); DropIndex("dbo.AspNetUserClaims", new[] { "UserId" }); DropIndex("dbo.AspNetUsers", new[] { "CompanyID" }); DropIndex("dbo.AspNetUsers", "UserNameIndex"); DropTable("dbo.YearlyParameters"); DropTable("dbo.SimaproParameters"); DropTable("dbo.ProductLCA"); DropTable("dbo.OrganizationLCA"); DropTable("dbo.NormalCompany"); DropTable("dbo.NonYearlyParameters"); DropTable("dbo.CertificationCompany"); DropTable("dbo.SheetHeaders"); DropTable("dbo.AspNetRoles"); DropTable("dbo.PublicReferenceFiles"); DropTable("dbo.PublicMessages"); DropTable("dbo.AspNetUserRoles"); DropTable("dbo.AspNetUserLogins"); DropTable("dbo.Suppliers"); DropTable("dbo.ProductLCAFabSurveyForm_WorkHours"); DropTable("dbo.ProductLCAFabSurveyForm_WaterUsages"); DropTable("dbo.ProductLCAFabSurveyForm_WasteTransports"); DropTable("dbo.ProductLCAFabSurveyForm_Wastes"); DropTable("dbo.ProductLCAFabSurveyForm_Transports"); DropTable("dbo.Products"); DropTable("dbo.InventoryStageData"); DropTable("dbo.PCRs"); DropTable("dbo.ProductLCAFabSurveyForm_OtherCompounds"); DropTable("dbo.ProductLCAReplyRequests"); DropTable("dbo.SimaproVersions"); DropTable("dbo.SimaproParameterCategories"); DropTable("dbo.SimaproParameterTypes"); DropTable("dbo.ProductLCAProductSurveyForm_Materials"); DropTable("dbo.ProductLCAFabSurveyForm_Kitchens"); DropTable("dbo.ProductLCAFabSurveyForm_GasolineEquipments"); DropTable("dbo.ProductLCAFabSurveyForm_FireEquipments"); DropTable("dbo.LCACommonSurveyForm_Vehicles"); DropTable("dbo.LCACommonSurveyForm_SteamUsages"); DropTable("dbo.LCAStatusLogs"); DropTable("dbo.NonYearlyParameterCategories"); DropTable("dbo.NonYearlyParameterTypes"); DropTable("dbo.LCACommonSurveyForm_Refrigerants"); DropTable("dbo.YearlyParameterTypes"); DropTable("dbo.YearlyParameterCategories"); DropTable("dbo.YearlyParameterAreas"); DropTable("dbo.Parameters"); DropTable("dbo.LCACommonSurveyForm_PowerUsages"); DropTable("dbo.Comments"); DropTable("dbo.LCAs"); DropTable("dbo.Fabs"); DropTable("dbo.AspNetUserClaims"); DropTable("dbo.AspNetUsers"); DropTable("dbo.Companies"); DropTable("dbo.ActionLogs"); } } }