Files
cms_thermo_active/Step.Database/Migrations/201802051555548_InitCreate.cs
T
Lucio Maranta 6cc4d8290e + Added functions access
* Change db and added PLC_ID
2018-02-06 17:36:12 +01:00

107 lines
4.3 KiB
C#

namespace Step.Database.Migrations
{
using System;
using System.Data.Entity.Migrations;
public partial class InitCreate : DbMigration
{
public override void Up()
{
CreateTable(
"dbo.function_access",
c => new
{
id = c.Int(nullable: false, identity: true),
name = c.String(unicode: false),
write_level_min = c.Int(nullable: false),
read_level_min = c.Int(nullable: false),
area = c.String(unicode: false),
enabled = c.Boolean(nullable: false),
plc_id = c.Int(nullable: false),
})
.PrimaryKey(t => t.id);
CreateTable(
"dbo.machine",
c => new
{
id = c.Int(nullable: false, identity: true),
name = c.String(unicode: false),
unique_id = c.String(unicode: false),
})
.PrimaryKey(t => t.id);
CreateTable(
"dbo.machine_user",
c => new
{
id = c.Int(nullable: false, identity: true),
machine_id = c.Int(nullable: false),
user_id = c.Int(nullable: false),
role_id = c.Int(nullable: false),
})
.PrimaryKey(t => t.id)
.ForeignKey("dbo.machine", t => t.machine_id, cascadeDelete: true)
.ForeignKey("dbo.role", t => t.role_id, cascadeDelete: true)
.ForeignKey("dbo.user", t => t.user_id, cascadeDelete: true)
.Index(t => new { t.machine_id, t.user_id }, unique: true, clustered: true, name: "unique_machine_user")
.Index(t => t.role_id);
CreateTable(
"dbo.role",
c => new
{
id = c.Int(nullable: false, identity: true),
name = c.String(unicode: false),
level = c.Int(nullable: false),
})
.PrimaryKey(t => t.id);
CreateTable(
"dbo.user",
c => new
{
id = c.Int(nullable: false, identity: true),
username = c.String(nullable: false, unicode: false),
first_name = c.String(unicode: false),
last_name = c.String(unicode: false),
password = c.String(unicode: false),
security_stamp = c.String(unicode: false),
language = c.String(unicode: false),
role_id = c.Int(nullable: false),
})
.PrimaryKey(t => t.id);
CreateTable(
"dbo.session",
c => new
{
id = c.Int(nullable: false, identity: true),
token = c.String(unicode: false),
machine_user_id = c.Int(nullable: false),
})
.PrimaryKey(t => t.id)
.ForeignKey("dbo.machine_user", t => t.machine_user_id, cascadeDelete: true)
.Index(t => t.machine_user_id);
}
public override void Down()
{
DropForeignKey("dbo.session", "machine_user_id", "dbo.machine_user");
DropForeignKey("dbo.machine_user", "user_id", "dbo.user");
DropForeignKey("dbo.machine_user", "role_id", "dbo.role");
DropForeignKey("dbo.machine_user", "machine_id", "dbo.machine");
DropIndex("dbo.session", new[] { "machine_user_id" });
DropIndex("dbo.machine_user", new[] { "role_id" });
DropIndex("dbo.machine_user", "unique_machine_user");
DropTable("dbo.session");
DropTable("dbo.user");
DropTable("dbo.role");
DropTable("dbo.machine_user");
DropTable("dbo.machine");
DropTable("dbo.function_access");
}
}
}