Test Setup Failed
Push — dev5 ( 73d054...92f243 )
by Ron
35:09
created
database/migrations/2019_10_19_175205_updates_for_version_5_0.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
     //  Added the ability to set an expiration date for user passwords - will force them to change after this expires
84 84
     private function addPasswordExpiresColumn()
85 85
     {
86
-        if (!Schema::hasColumn('users', 'password_expires')) {
87
-            Schema::table('users', function (Blueprint $table) {
86
+        if(!Schema::hasColumn('users', 'password_expires')) {
87
+            Schema::table('users', function(Blueprint $table) {
88 88
                 $table->timestamp('password_expires')
89 89
                     ->nullable()
90 90
                     ->after('active');
@@ -95,17 +95,17 @@  discard block
 block discarded – undo
95 95
     //  Add the is installer column to the users table
96 96
     private function addIsInstallerToUsers()
97 97
     {
98
-        if (!Schema::hasColumn('users', 'is_installer')) {
99
-            Schema::table('users', function (Blueprint $table) {
98
+        if(!Schema::hasColumn('users', 'is_installer')) {
99
+            Schema::table('users', function(Blueprint $table) {
100 100
                 $table->boolean('is_installer')->default(0)->after('active');
101 101
             });
102 102
 
103 103
             //  Migrate user roles from the 'user roles' table to the new 'user permissions' table
104
-            if (Schema::hasTable('user_permissions') && (UserPermissions::all()->isEmpty())) {
104
+            if(Schema::hasTable('user_permissions') && (UserPermissions::all()->isEmpty())) {
105 105
                 $userRoles = DB::select('SELECT * FROM `user_role` LEFT JOIN `roles` ON `user_role`.`role_id` = `roles`.`role_id`');
106 106
 
107
-                foreach ($userRoles as $user) {
108
-                    if ($user->name === 'Installer') {
107
+                foreach($userRoles as $user) {
108
+                    if($user->name === 'Installer') {
109 109
                         User::find($user->user_id)->update(
110 110
                             [
111 111
                                 'is_installer' => 1
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
                                 'modify_category'     => 1
127 127
                             ]
128 128
                         );
129
-                    } else if ($user->name === 'Admin') {
129
+                    } else if($user->name === 'Admin') {
130 130
                         UserPermissions::create(
131 131
                             [
132 132
                                 'user_id'             => $user->user_id,
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
                                 'modify_category'     => 1
143 143
                             ]
144 144
                         );
145
-                    } else if ($user->name === 'Report') {
145
+                    } else if($user->name === 'Report') {
146 146
                         UserPermissions::create(
147 147
                             [
148 148
                                 'user_id'             => $user->user_id,
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
     //  Added a 'hidden' attribute to system customer data types to allow passwords to not be viewed unless clicked or focus
184 184
     private function addHiddenColumn()
185 185
     {
186
-        if (!Schema::hasColumn('system_cust_data_types', 'hidden')) {
187
-            Schema::table('system_cust_data_types', function (Blueprint $table) {
186
+        if(!Schema::hasColumn('system_cust_data_types', 'hidden')) {
187
+            Schema::table('system_cust_data_types', function(Blueprint $table) {
188 188
                 $table->boolean('hidden')
189 189
                     ->default(0)
190 190
                     ->after('name');
@@ -195,8 +195,8 @@  discard block
 block discarded – undo
195 195
     //  Update the File links table - add cust_id and note column
196 196
     private function addColumnsToFileLinksTable()
197 197
     {
198
-        if (!Schema::hasColumn('file_links', 'cust_id')) {
199
-            Schema::table('file_links', function (Blueprint $table) {
198
+        if(!Schema::hasColumn('file_links', 'cust_id')) {
199
+            Schema::table('file_links', function(Blueprint $table) {
200 200
                 $table->integer('cust_id')
201 201
                     ->unsigned()
202 202
                     ->nullable()
@@ -204,15 +204,15 @@  discard block
 block discarded – undo
204 204
                 $table->foreign('cust_id')->references('cust_id')->on('customers')->onUpdate('cascade')->onDelete('cascade');
205 205
             });
206 206
         }
207
-        if (!Schema::hasColumn('file_links', 'note')) {
208
-            Schema::table('file_links', function (Blueprint $table) {
207
+        if(!Schema::hasColumn('file_links', 'note')) {
208
+            Schema::table('file_links', function(Blueprint $table) {
209 209
                 $table->longText('note')
210 210
                     ->nullable()
211 211
                     ->after('link_name');
212 212
             });
213 213
             //  Migrate the instructions from the old table to the new column
214 214
             $instructions = DB::select('SELECT * FROM `file_link_instructions`');
215
-            foreach ($instructions as $ins) {
215
+            foreach($instructions as $ins) {
216 216
                 FileLinks::find($ins->link_id)->update([
217 217
                     'note' => $ins->instruction
218 218
                 ]);
@@ -223,15 +223,15 @@  discard block
 block discarded – undo
223 223
     //  Add Notes column to the file links files table
224 224
     private function addNotesColumnToFileLinkFiles()
225 225
     {
226
-        if (!Schema::hasColumn('file_link_files', 'note')) {
227
-            Schema::table('file_link_files', function (Blueprint $table) {
226
+        if(!Schema::hasColumn('file_link_files', 'note')) {
227
+            Schema::table('file_link_files', function(Blueprint $table) {
228 228
                 $table->longText('note')
229 229
                     ->nullable()
230 230
                     ->after('upload');
231 231
             });
232 232
             //  Migrate the existing notes to the new table
233 233
             $notes = DB::select('SELECT * FROM `file_link_notes`');
234
-            foreach ($notes as $note) {
234
+            foreach($notes as $note) {
235 235
                 FileLinkFiles::where('file_id', $note->file_id)->update([
236 236
                     'note' => $note->note
237 237
                 ]);
@@ -242,14 +242,14 @@  discard block
 block discarded – undo
242 242
     //  Add the documentation column to the tech tips table
243 243
     private function addDocumentationColumnToTechTips()
244 244
     {
245
-        if (!Schema::hasColumn('tech_tips', 'documentation')) {
246
-            Schema::table('tech_tips', function (Blueprint $table) {
245
+        if(!Schema::hasColumn('tech_tips', 'documentation')) {
246
+            Schema::table('tech_tips', function(Blueprint $table) {
247 247
                 $table->boolean('documentation')->default(0)->nullable()->after('public');
248 248
             });
249 249
 
250 250
             //  Move all of the system files over to the tech tips table
251 251
             $sysFiles = DB::select('SELECT * FROM `system_files`');
252
-            foreach ($sysFiles as $sysFile) {
252
+            foreach($sysFiles as $sysFile) {
253 253
                 $newTip = TechTips::create([
254 254
                     'user_id'       => $sysFile->user_id,
255 255
                     'public'        => 0,
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
     //  Remove the active column from the customers table
286 286
     private function removeActiveFromCustomers()
287 287
     {
288
-        if (Schema::hasColumn('customers', 'active'))
288
+        if(Schema::hasColumn('customers', 'active'))
289 289
         {
290 290
             //  Migrate the existing disabled customers first
291 291
             $deactiveatedCustomers = Customers::where('active', 0);
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
                 Customers::find($cust->cust_id)->delete();
296 296
             }
297 297
 
298
-            Schema::table('customers', function (Blueprint $table) {
298
+            Schema::table('customers', function(Blueprint $table) {
299 299
                 $table->dropColumn('active');
300 300
             });
301 301
         }
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
     {
307 307
         if(Schema::hasTable('user_role'))
308 308
         {
309
-            Schema::table('user_role', function (Blueprint $table) {
309
+            Schema::table('user_role', function(Blueprint $table) {
310 310
                 $table->dropForeign(['user_id']);
311 311
                 $table->dropForeign(['role_id']);
312 312
             });
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
         if(Schema::hasTable('file_link_instructions'))
322 322
         {
323 323
             //  Remove the foreign key to allow for dropping the table
324
-            Schema::table('file_link_instructions', function (Blueprint $table) {
324
+            Schema::table('file_link_instructions', function(Blueprint $table) {
325 325
                 $table->dropForeign(['link_id']);
326 326
             });
327 327
             Schema::dropIfExists('file_link_instructions');
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
     {
334 334
         if(Schema::hasTable('file_link_notes'))
335 335
         {
336
-            Schema::table('file_link_notes', function (Blueprint $table) {
336
+            Schema::table('file_link_notes', function(Blueprint $table) {
337 337
                 $table->dropForeign(['link_id']);
338 338
                 $table->dropForeign(['file_id']);
339 339
             });
@@ -344,8 +344,8 @@  discard block
 block discarded – undo
344 344
     //  Remove the system files and system file types table
345 345
     private function removeSystemFilesTables()
346 346
     {
347
-        if (Schema::hasTable('system_files')) {
348
-            Schema::table('system_files', function (Blueprint $table) {
347
+        if(Schema::hasTable('system_files')) {
348
+            Schema::table('system_files', function(Blueprint $table) {
349 349
                 $table->dropForeign(['sys_id']);
350 350
                 $table->dropForeign(['type_id']);
351 351
                 $table->dropForeign(['file_id']);
Please login to merge, or discard this patch.