Passed
Push — dev5 ( e66ef8...5a922b )
by Ron
05:53
created
database/migrations/2019_10_19_175205_updates_for_version_5_0.php 1 patch
Braces   +38 added lines, -19 removed lines patch added patch discarded remove patch
@@ -85,7 +85,8 @@  discard block
 block discarded – undo
85 85
     //  Added the ability to set an expiration date for user passwords - will force them to change after this expires
86 86
     private function addPasswordExpiresColumn()
87 87
     {
88
-        if (!Schema::hasColumn('users', 'password_expires')) {
88
+        if (!Schema::hasColumn('users', 'password_expires'))
89
+        {
89 90
             Schema::table('users', function (Blueprint $table) {
90 91
                 $table->timestamp('password_expires')
91 92
                     ->nullable()
@@ -97,18 +98,22 @@  discard block
 block discarded – undo
97 98
     //  Add the is installer column to the users table
98 99
     private function addIsInstallerToUsers()
99 100
     {
100
-        if (!Schema::hasColumn('users', 'is_installer')) {
101
+        if (!Schema::hasColumn('users', 'is_installer'))
102
+        {
101 103
             Schema::table('users', function (Blueprint $table) {
102 104
                 $table->boolean('is_installer')->default(0)->after('active');
103 105
             });
104 106
 
105 107
             //  TODO - Clean this up, it does not work
106 108
             //  Migrate user roles from the 'user roles' table to the new 'user permissions' table
107
-            if (Schema::hasTable('user_permissions') && (UserPermissions::all()->isEmpty())) {
109
+            if (Schema::hasTable('user_permissions') && (UserPermissions::all()->isEmpty()))
110
+            {
108 111
                 $userRoles = DB::select('SELECT * FROM `user_role` LEFT JOIN `roles` ON `user_role`.`role_id` = `roles`.`role_id`');
109 112
 
110
-                foreach ($userRoles as $user) {
111
-                    if ($user->name === 'Installer') {
113
+                foreach ($userRoles as $user)
114
+                {
115
+                    if ($user->name === 'Installer')
116
+                    {
112 117
                         User::find($user->user_id)->update(
113 118
                             [
114 119
                                 'is_installer' => 1
@@ -129,7 +134,9 @@  discard block
 block discarded – undo
129 134
                                 'modify_category'     => 1
130 135
                             ]
131 136
                         );
132
-                    } else if ($user->name === 'Admin') {
137
+                    }
138
+                    else if ($user->name === 'Admin')
139
+                    {
133 140
                         UserPermissions::create(
134 141
                             [
135 142
                                 'user_id'             => $user->user_id,
@@ -145,7 +152,9 @@  discard block
 block discarded – undo
145 152
                                 'modify_category'     => 1
146 153
                             ]
147 154
                         );
148
-                    } else if ($user->name === 'Report') {
155
+                    }
156
+                    else if ($user->name === 'Report')
157
+                    {
149 158
                         UserPermissions::create(
150 159
                             [
151 160
                                 'user_id'             => $user->user_id,
@@ -161,7 +170,9 @@  discard block
 block discarded – undo
161 170
                                 'modify_category'     => 0
162 171
                             ]
163 172
                         );
164
-                    } else {
173
+                    }
174
+                    else
175
+                    {
165 176
                         UserPermissions::create(
166 177
                             [
167 178
                                 'user_id'             => $user->user_id,
@@ -186,7 +197,8 @@  discard block
 block discarded – undo
186 197
     //  Added a 'hidden' attribute to system customer data types to allow passwords to not be viewed unless clicked or focus
187 198
     private function addHiddenColumn()
188 199
     {
189
-        if (!Schema::hasColumn('system_data_field_types', 'hidden')) {
200
+        if (!Schema::hasColumn('system_data_field_types', 'hidden'))
201
+        {
190 202
             Schema::table('system_cust_data_types', function (Blueprint $table) {
191 203
                 $table->boolean('hidden')
192 204
                     ->default(0)
@@ -198,7 +210,8 @@  discard block
 block discarded – undo
198 210
     //  Update the File links table - add cust_id and note column
199 211
     private function addColumnsToFileLinksTable()
200 212
     {
201
-        if (!Schema::hasColumn('file_links', 'cust_id')) {
213
+        if (!Schema::hasColumn('file_links', 'cust_id'))
214
+        {
202 215
             Schema::table('file_links', function (Blueprint $table) {
203 216
                 $table->integer('cust_id')
204 217
                     ->unsigned()
@@ -207,7 +220,8 @@  discard block
 block discarded – undo
207 220
                 $table->foreign('cust_id')->references('cust_id')->on('customers')->onUpdate('cascade')->onDelete('cascade');
208 221
             });
209 222
         }
210
-        if (!Schema::hasColumn('file_links', 'note')) {
223
+        if (!Schema::hasColumn('file_links', 'note'))
224
+        {
211 225
             Schema::table('file_links', function (Blueprint $table) {
212 226
                 $table->longText('note')
213 227
                     ->nullable()
@@ -215,7 +229,8 @@  discard block
 block discarded – undo
215 229
             });
216 230
             //  Migrate the instructions from the old table to the new column
217 231
             $instructions = DB::select('SELECT * FROM `file_link_instructions`');
218
-            foreach ($instructions as $ins) {
232
+            foreach ($instructions as $ins)
233
+            {
219 234
                 FileLinks::find($ins->link_id)->update([
220 235
                     'note' => $ins->instruction
221 236
                 ]);
@@ -226,7 +241,8 @@  discard block
 block discarded – undo
226 241
     //  Add Notes column to the file links files table
227 242
     private function addNotesColumnToFileLinkFiles()
228 243
     {
229
-        if (!Schema::hasColumn('file_link_files', 'note')) {
244
+        if (!Schema::hasColumn('file_link_files', 'note'))
245
+        {
230 246
             Schema::table('file_link_files', function (Blueprint $table) {
231 247
                 $table->longText('note')
232 248
                     ->nullable()
@@ -234,7 +250,8 @@  discard block
 block discarded – undo
234 250
             });
235 251
             //  Migrate the existing notes to the new table
236 252
             $notes = DB::select('SELECT * FROM `file_link_notes`');
237
-            foreach ($notes as $note) {
253
+            foreach ($notes as $note)
254
+            {
238 255
                 FileLinkFiles::where('file_id', $note->file_id)->update([
239 256
                     'note' => $note->note
240 257
                 ]);
@@ -245,14 +262,16 @@  discard block
 block discarded – undo
245 262
     //  Add the documentation column to the tech tips table
246 263
     private function addDocumentationColumnToTechTips()
247 264
     {
248
-        if (!Schema::hasColumn('tech_tips', 'documentation')) {
265
+        if (!Schema::hasColumn('tech_tips', 'documentation'))
266
+        {
249 267
             Schema::table('tech_tips', function (Blueprint $table) {
250 268
                 $table->boolean('documentation')->default(0)->nullable()->after('public');
251 269
             });
252 270
 
253 271
             //  Move all of the system files over to the tech tips table
254 272
             $sysFiles = DB::select('SELECT * FROM `system_files`');
255
-            foreach ($sysFiles as $sysFile) {
273
+            foreach ($sysFiles as $sysFile)
274
+            {
256 275
                 $newTip = TechTips::create([
257 276
                     'user_id'       => $sysFile->user_id,
258 277
                     'public'        => 0,
@@ -347,7 +366,8 @@  discard block
 block discarded – undo
347 366
     //  Remove the system files and system file types table
348 367
     private function removeSystemFilesTables()
349 368
     {
350
-        if (Schema::hasTable('system_files')) {
369
+        if (Schema::hasTable('system_files'))
370
+        {
351 371
             Schema::table('system_files', function (Blueprint $table) {
352 372
                 $table->dropForeign(['sys_id']);
353 373
                 $table->dropForeign(['type_id']);
@@ -384,8 +404,7 @@  discard block
 block discarded – undo
384 404
     {
385 405
         if(!Schema::hasColumn('customer_systems', 'deleted_at'))
386 406
         {
387
-            Schema::table('customer_systems', function(Blueprint $table)
388
-            {
407
+            Schema::table('customer_systems', function(Blueprint $table) {
389 408
                 $table->softDeletes()->after('sys_id');
390 409
             });
391 410
         }
Please login to merge, or discard this patch.