fa485d902b
* Added first centralized database config and added machine self-registration into db * Fix database migration with new database * Refactor
43 lines
1.7 KiB
C#
43 lines
1.7 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;
|
|
|
|
public sealed class Configuration : DbMigrationsConfiguration<DatabaseContext>
|
|
{
|
|
private readonly bool _pendingMigrations;
|
|
|
|
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(
|
|
new FunctionAccessModel() { FunctionAccessId = 1, Name = "test", Area = "production", Enabled = true, WriteLevelMin = 7, ReadLevelMin = 1 },
|
|
new FunctionAccessModel() { FunctionAccessId = 2, Name = "userData", Area = "production", Enabled = true, WriteLevelMin = 1, ReadLevelMin = 1 },
|
|
new FunctionAccessModel() { FunctionAccessId = 3, Name = "ncData", Area = "production", Enabled = true, WriteLevelMin = 100, ReadLevelMin = 1 },
|
|
new FunctionAccessModel() { FunctionAccessId = 4, Name = "functionAccess", Area = "production", Enabled = true, WriteLevelMin = 100, ReadLevelMin = 1 }
|
|
);
|
|
|
|
context.SaveChanges();
|
|
}
|
|
}
|
|
}
|