Explorar el Código

Add VoucherId index to Logs.
Bump version to 1.3.

Brett Credo hace 8 años
padre
commit
83b735efb3

+ 22 - 6
BulkPrinting/BulkPrinting/Migrations.cs

@@ -4,29 +4,35 @@ namespace BulkPrinting
4 4
 {
5 5
     class Migrations
6 6
     {
7
-        public static void CheckMigrations(DBHelper db) {
7
+        public static void CheckMigrations(DBHelper db)
8
+        {
8 9
             var result = db.ExecuteScalar("SELECT Value FROM Parameters WHERE Key = 'Migration'");
9 10
             int startingMigration;
10 11
             if (result == null)
11 12
             {
12 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 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 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 26
                 Migration1(db);
25 27
             }
26 28
             if (startingMigration < 2)
27 29
             {
28 30
                 Migration2(db);
29 31
             }
32
+            if (startingMigration < 3)
33
+            {
34
+                Migration3(db);
35
+            }
30 36
             //Add further migration executions here - Migration = '1', '2', '3' etc
31 37
 
32 38
             return;
@@ -51,7 +57,8 @@ namespace BulkPrinting
51 57
             return true;
52 58
         }
53 59
 
54
-        public static bool InitialVersion(DBHelper db) {
60
+        public static bool InitialVersion(DBHelper db)
61
+        {
55 62
             return ApplyMigrationQueries(
56 63
                 db,
57 64
                 "CREATE TABLE Batch (" +
@@ -119,7 +126,8 @@ namespace BulkPrinting
119 126
             );
120 127
         }
121 128
 
122
-        public static bool Migration1 (DBHelper db){
129
+        public static bool Migration1(DBHelper db)
130
+        {
123 131
             return ApplyMigrationQueries(
124 132
                 db,
125 133
                 "ALTER TABLE Orders ADD COLUMN InternalReference VARCHAR(32)",
@@ -160,5 +168,13 @@ namespace BulkPrinting
160 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,4 +33,4 @@ using System.Runtime.InteropServices;
33 33
 // by using the '*' as shown below:
34 34
 // [assembly: AssemblyVersion("1.0.*")]
35 35
 [assembly: AssemblyVersion("1.0.*")]
36
-[assembly: AssemblyFileVersion("1.2")]
36
+[assembly: AssemblyFileVersion("1.3")]