Files
cms_thermo_active/Step.Database/Migrations/201801161604529_InitCreate.cs
T
Lucio Maranta fa485d902b * Added machine model, and new database relations
* Added first centralized database config and  added machine self-registration into db
* Fix database migration with new database
* Refactor
2018-01-17 10:24:18 +01:00

92 lines
3.6 KiB
C#

namespace Step.Database.Migrations
{
using System;
using System.Data.Entity.Migrations;
public partial class InitCreate : DbMigration
{
public override void Up()
{
CreateTable(
"dbo.functions_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),
})
.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.machines_users",
c => new
{
machine_id = c.Int(nullable: false),
user_id = c.Int(nullable: false),
role_id = c.Int(nullable: false),
})
.PrimaryKey(t => new { t.machine_id, t.user_id, t.role_id })
.ForeignKey("dbo.machine", t => t.machine_id, cascadeDelete: true)
.ForeignKey("dbo.roles", t => t.role_id, cascadeDelete: true)
.ForeignKey("dbo.users", t => t.user_id, cascadeDelete: true)
.Index(t => t.machine_id)
.Index(t => t.user_id)
.Index(t => t.role_id);
CreateTable(
"dbo.roles",
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.users",
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);
}
public override void Down()
{
DropForeignKey("dbo.machines_users", "user_id", "dbo.users");
DropForeignKey("dbo.machines_users", "role_id", "dbo.roles");
DropForeignKey("dbo.machines_users", "machine_id", "dbo.machine");
DropIndex("dbo.machines_users", new[] { "role_id" });
DropIndex("dbo.machines_users", new[] { "user_id" });
DropIndex("dbo.machines_users", new[] { "machine_id" });
DropTable("dbo.users");
DropTable("dbo.roles");
DropTable("dbo.machines_users");
DropTable("dbo.machine");
DropTable("dbo.functions_access");
}
}
}