@@ -16,18 +16,24 @@ public function up()
1616 {
1717 Schema::dropIfExists ('ticketit_departments_persons ' );
1818
19- Schema::rename ('ticketit_departments ' , 'panichd_departments ' );
19+ if (Schema::hasTable ('ticketit_departments ' )){
20+ Schema::rename ('ticketit_departments ' , 'panichd_departments ' );
2021
21- foreach (Department::whereNotNull ('sub1 ' )->get () as $ dep ){
22- $ dep ->department = $ dep ->sub1 ;
23- $ dep ->shortening = null ;
24- $ dep ->save ();
22+ foreach (Department::whereNotNull ('sub1 ' )->get () as $ dep ){
23+ $ dep ->department = $ dep ->sub1 ;
24+ $ dep ->shortening = null ;
25+ $ dep ->save ();
26+ }
2527 }
2628
29+ if (Schema::hasColumn ('panichd_departments ' , 'department ' )){
30+ Schema::table ('panichd_departments ' , function (Blueprint $ table ) {
31+ $ table ->renameColumn ('department ' , 'name ' );
32+ });
33+ }
2734 Schema::table ('panichd_departments ' , function (Blueprint $ table ) {
28- $ table ->renameColumn ('department ' , 'name ' );
2935 $ table ->dropColumn ('sub1 ' );
30- });
36+ });
3137 }
3238
3339 /**
@@ -37,7 +43,9 @@ public function up()
3743 */
3844 public function down ()
3945 {
40- Schema::rename ('panichd_departments ' , 'ticketit_departments ' );
46+ if (Schema::hasTable ('panichd_departments ' )){
47+ Schema::rename ('panichd_departments ' , 'ticketit_departments ' );
48+ }
4149
4250 Schema::table ('ticketit_departments ' , function (Blueprint $ table ) {
4351 $ table ->renameColumn ('name ' , 'department ' );
0 commit comments