Blame view

Vrh.iScheduler/Migrations/201705161917087_InitialDB.cs 3.87 KB
ab9f2fbe   Schwirg László   Add project files.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
  namespace Vrh.iScheduler.Migrations
  {
      using System;
      using System.Data.Entity.Migrations;
      
      public partial class InitialDB : DbMigration
      {
          public override void Up()
          {
              CreateTable(
                  "iScheduler.ScheduleObjects",
                  c => new
                      {
                          Id = c.Int(nullable: false, identity: true),
                          ObjectType = c.String(nullable: false, maxLength: 100),
                          ObjectId = c.String(nullable: false, maxLength: 100),
                          ObjectName = c.String(nullable: false, maxLength: 200),
                          ObjectGroupId = c.String(nullable: false, maxLength: 100),
                      })
                  .PrimaryKey(t => t.Id)
                  .Index(t => new { t.ObjectType, t.ObjectId }, unique: true, name: "IX_ScheduleObject_ObjectTypeObjectId");
              
              CreateTable(
                  "iScheduler.Schedules",
                  c => new
                      {
                          Id = c.Int(nullable: false, identity: true),
                          ScheduleObjectId = c.Int(nullable: false),
                          ScheduleOperationId = c.Short(nullable: false),
                          OperationTime = c.DateTime(nullable: false),
                          State = c.Byte(nullable: false),
                          ScheduleSeriesId = c.Int(),
                      })
                  .PrimaryKey(t => t.Id)
                  .ForeignKey("iScheduler.ScheduleObjects", t => t.ScheduleObjectId)
                  .ForeignKey("iScheduler.ScheduleOperations", t => t.ScheduleOperationId)
                  .ForeignKey("iScheduler.ScheduleSeries", t => t.ScheduleSeriesId)
                  .Index(t => t.ScheduleObjectId)
                  .Index(t => t.ScheduleOperationId)
                  .Index(t => t.ScheduleSeriesId);
              
              CreateTable(
                  "iScheduler.ScheduleOperations",
                  c => new
                      {
                          Id = c.Short(nullable: false, identity: true),
                          ObjectType = c.String(nullable: false, maxLength: 100),
                          OperationId = c.String(nullable: false, maxLength: 100),
                          OperationName = c.String(nullable: false, maxLength: 200),
                      })
                  .PrimaryKey(t => t.Id)
                  .Index(t => new { t.ObjectType, t.OperationId }, unique: true, name: "IX_ScheduleOperation_ObjectTypeOperationId");
              
              CreateTable(
                  "iScheduler.ScheduleSeries",
                  c => new
                      {
                          Id = c.Int(nullable: false, identity: true),
                          SeriesType = c.String(nullable: false, maxLength: 100),
                          SeriesColor = c.String(maxLength: 30),
                      })
                  .PrimaryKey(t => t.Id);
              
          }
          
          public override void Down()
          {
              DropForeignKey("iScheduler.Schedules", "ScheduleSeriesId", "iScheduler.ScheduleSeries");
              DropForeignKey("iScheduler.Schedules", "ScheduleOperationId", "iScheduler.ScheduleOperations");
              DropForeignKey("iScheduler.Schedules", "ScheduleObjectId", "iScheduler.ScheduleObjects");
              DropIndex("iScheduler.ScheduleOperations", "IX_ScheduleOperation_ObjectTypeOperationId");
              DropIndex("iScheduler.Schedules", new[] { "ScheduleSeriesId" });
              DropIndex("iScheduler.Schedules", new[] { "ScheduleOperationId" });
              DropIndex("iScheduler.Schedules", new[] { "ScheduleObjectId" });
              DropIndex("iScheduler.ScheduleObjects", "IX_ScheduleObject_ObjectTypeObjectId");
              DropTable("iScheduler.ScheduleSeries");
              DropTable("iScheduler.ScheduleOperations");
              DropTable("iScheduler.Schedules");
              DropTable("iScheduler.ScheduleObjects");
          }
      }
  }