소스 검색

Add missing Migration parameter update and a fix for boxes where the migration has already taken place without the update.

Brett Credo 8 년 전
부모
커밋
594eb7f36b
1개의 변경된 파일13개의 추가작업 그리고 4개의 파일을 삭제
  1. 13 4
      BulkPrinting/BulkPrinting/Migrations.cs

+ 13 - 4
BulkPrinting/BulkPrinting/Migrations.cs

@@ -132,6 +132,8 @@ namespace BulkPrinting
132 132
                 db,
133 133
                 "ALTER TABLE Orders ADD COLUMN InternalReference VARCHAR(32)",
134 134
                 "ALTER TABLE Batch ADD COLUMN InternalReference VARCHAR(32)",
135
+
136
+                // IMPORTANT
135 137
                 "INSERT INTO Parameters (Key, Value) VALUES ('Migration','1')"
136 138
             );
137 139
         }
@@ -150,7 +152,6 @@ namespace BulkPrinting
150 152
                 "CREATE UNIQUE INDEX Parameters_Key ON Parameters(Key)",
151 153
                 "CREATE INDEX Orders_OrderDate ON Orders(OrderDate)",
152 154
                 "CREATE INDEX OrderedItems_OrderId ON OrderedItems(OrderId)",
153
-                "UPDATE Parameters SET Value='2' WHERE Key='Migration'",
154 155
                 "UPDATE Batch SET Downloaded=(ReadyForDownload=1 AND DeliveredQuantity<=COALESCE((SELECT COUNT(*) FROM Voucher WHERE Voucher.BatchId=Batch.Id), 0))",
155 156
                 "INSERT INTO Parameters (Key, Value) VALUES ('LastSyncedBatchId', '0')",
156 157
                 "INSERT INTO Parameters (Key, Value) VALUES ('SyncBackwardsFromLogId', '0')",
@@ -165,7 +166,10 @@ namespace BulkPrinting
165 166
                 "INSERT INTO Logs_New (Id, UserId, VoucherId, EventDate, EventType, Retry) " +
166 167
                     "SELECT Id, UserId, VoucherId, EventDate, EventType, Retry FROM Logs",
167 168
                 "DROP TABLE Logs",
168
-                "ALTER TABLE Logs_New RENAME TO Logs"
169
+                "ALTER TABLE Logs_New RENAME TO Logs",
170
+
171
+                // IMPORTANT
172
+                "UPDATE Parameters SET Value='2' WHERE Key='Migration'"
169 173
             );
170 174
         }
171 175
 
@@ -173,8 +177,13 @@ namespace BulkPrinting
173 177
         {
174 178
             return ApplyMigrationQueries(
175 179
                 db,
176
-                "CREATE INDEX Logs_VoucherId_EventType_Id ON Logs(VoucherId, EventType, Id)"
177
-            );
180
+
181
+                // Forgot to update the migration value initially, hence the 'NOT EXISTS'
182
+                "CREATE INDEX IF NOT EXISTS Logs_VoucherId_EventType_Id ON Logs(VoucherId, EventType, Id)",
183
+
184
+                // IMPORTANT
185
+                "UPDATE Parameters SET Value='3' WHERE Key='Migration'"
186
+           );
178 187
         }
179 188
     }
180 189
 }