瀏覽代碼

Add VoucherId index to Logs.
Bump version to 1.3.

Brett Credo 8 年之前
父節點
當前提交
83b735efb3
共有 2 個文件被更改,包括 23 次插入7 次删除
  1. 22 6
      BulkPrinting/BulkPrinting/Migrations.cs
  2. 1 1
      BulkPrinting/BulkPrinting/Properties/AssemblyInfo.cs

+ 22 - 6
BulkPrinting/BulkPrinting/Migrations.cs

4
 {
4
 {
5
     class Migrations
5
     class Migrations
6
     {
6
     {
7
-        public static void CheckMigrations(DBHelper db) {
7
+        public static void CheckMigrations(DBHelper db)
8
+        {
8
             var result = db.ExecuteScalar("SELECT Value FROM Parameters WHERE Key = 'Migration'");
9
             var result = db.ExecuteScalar("SELECT Value FROM Parameters WHERE Key = 'Migration'");
9
             int startingMigration;
10
             int startingMigration;
10
             if (result == null)
11
             if (result == null)
11
             {
12
             {
12
                 startingMigration = 0;
13
                 startingMigration = 0;
13
             }
14
             }
14
-            else if (! int.TryParse((string)result, out startingMigration))
15
+            else if (!int.TryParse((string)result, out startingMigration))
15
             {
16
             {
16
                 throw new Exception(String.Format("Invalid migration value: {0}", result));
17
                 throw new Exception(String.Format("Invalid migration value: {0}", result));
17
             }
18
             }
18
 
19
 
19
-            if (startingMigration > 2)
20
+            if (startingMigration > 3)
20
             {
21
             {
21
                 throw new Exception("Database is for a newer version of this application. Please upgrade and try again.");
22
                 throw new Exception("Database is for a newer version of this application. Please upgrade and try again.");
22
             }
23
             }
23
-            if (startingMigration < 1) {
24
+            if (startingMigration < 1)
25
+            {
24
                 Migration1(db);
26
                 Migration1(db);
25
             }
27
             }
26
             if (startingMigration < 2)
28
             if (startingMigration < 2)
27
             {
29
             {
28
                 Migration2(db);
30
                 Migration2(db);
29
             }
31
             }
32
+            if (startingMigration < 3)
33
+            {
34
+                Migration3(db);
35
+            }
30
             //Add further migration executions here - Migration = '1', '2', '3' etc
36
             //Add further migration executions here - Migration = '1', '2', '3' etc
31
 
37
 
32
             return;
38
             return;
51
             return true;
57
             return true;
52
         }
58
         }
53
 
59
 
54
-        public static bool InitialVersion(DBHelper db) {
60
+        public static bool InitialVersion(DBHelper db)
61
+        {
55
             return ApplyMigrationQueries(
62
             return ApplyMigrationQueries(
56
                 db,
63
                 db,
57
                 "CREATE TABLE Batch (" +
64
                 "CREATE TABLE Batch (" +
119
             );
126
             );
120
         }
127
         }
121
 
128
 
122
-        public static bool Migration1 (DBHelper db){
129
+        public static bool Migration1(DBHelper db)
130
+        {
123
             return ApplyMigrationQueries(
131
             return ApplyMigrationQueries(
124
                 db,
132
                 db,
125
                 "ALTER TABLE Orders ADD COLUMN InternalReference VARCHAR(32)",
133
                 "ALTER TABLE Orders ADD COLUMN InternalReference VARCHAR(32)",
160
                 "ALTER TABLE Logs_New RENAME TO Logs"
168
                 "ALTER TABLE Logs_New RENAME TO Logs"
161
             );
169
             );
162
         }
170
         }
171
+
172
+        public static bool Migration3(DBHelper db)
173
+        {
174
+            return ApplyMigrationQueries(
175
+                db,
176
+                "CREATE INDEX Logs_VoucherId_EventType_Id ON Logs(VoucherId, EventType, Id)"
177
+            );
178
+        }
163
     }
179
     }
164
 }
180
 }

+ 1 - 1
BulkPrinting/BulkPrinting/Properties/AssemblyInfo.cs

33
 // by using the '*' as shown below:
33
 // by using the '*' as shown below:
34
 // [assembly: AssemblyVersion("1.0.*")]
34
 // [assembly: AssemblyVersion("1.0.*")]
35
 [assembly: AssemblyVersion("1.0.*")]
35
 [assembly: AssemblyVersion("1.0.*")]
36
-[assembly: AssemblyFileVersion("1.2")]
36
+[assembly: AssemblyFileVersion("1.3")]