Files
cms_thermo_active/Step.Database/Migrations/Configuration.cs
T
Lucio Maranta 6071a96d11 Fix migration
Fix login with sessions
2018-01-29 12:43:29 +01:00

44 lines
1.9 KiB
C#

namespace Step.Database.Migrations
{
using Step.Database.Controllers;
using Step.Model.DatabaseModels;
using System;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Globalization;
using System.Linq;
using static Step.Utils.Constants;
public sealed class Configuration : DbMigrationsConfiguration<DatabaseContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = true;
AutomaticMigrationDataLossAllowed = true;
ContextKey = "Step.Database.DatabaseContext";
}
protected override void Seed(DatabaseContext context)
{
// This method will be called after migrating to the latest version.
context.Roles.AddOrUpdate(
new RoleModel() { RoleId = 1, Level = 10, Name = "Admin" },
new RoleModel() { RoleId = 2, Level = 1, Name = "Guest" }
);
context.FunctionsAccess.AddOrUpdate(
// General Function
new FunctionAccessModel() { FunctionAccessId = 1, Name = "test", Area = AREAS.GENERAL_KEY, Enabled = true, WriteLevelMin = 7, ReadLevelMin = 1 },
new FunctionAccessModel() { FunctionAccessId = 2, Name = "functionAccess", Area = AREAS.GENERAL_KEY, Enabled = true, WriteLevelMin = 100, ReadLevelMin = 1 },
new FunctionAccessModel() { FunctionAccessId = 3, Name = "logout", Area = AREAS.GENERAL_KEY, Enabled = true, WriteLevelMin = 1, ReadLevelMin = 1 },
// Production function
new FunctionAccessModel() { FunctionAccessId = 4, Name = "userData", Area = AREAS.PRODUCTION_KEY, Enabled = true, WriteLevelMin = 1, ReadLevelMin = 1 },
new FunctionAccessModel() { FunctionAccessId = 5, Name = "ncData", Area = AREAS.PRODUCTION_KEY, Enabled = true, WriteLevelMin = 100, ReadLevelMin = 1 }
);
context.SaveChanges();
}
}
}