File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 11<?php
22
3+ use Pterodactyl \Models \Task ;
34use Illuminate \Support \Facades \Schema ;
45use Illuminate \Database \Schema \Blueprint ;
56use Illuminate \Database \Migrations \Migration ;
@@ -17,11 +18,22 @@ public function up()
1718 $ table ->dropForeign (['server ' ]);
1819
1920 $ table ->renameColumn ('server ' , 'server_id ' );
20- $ table ->unsignedInteger ('user_id ' )->after ('id ' );
21+ $ table ->unsignedInteger ('user_id ' )->nullable ()-> after ('id ' );
2122
2223 $ table ->foreign ('server_id ' )->references ('id ' )->on ('servers ' );
2324 $ table ->foreign ('user_id ' )->references ('id ' )->on ('users ' );
2425 });
26+
27+ DB ::transaction (function () {
28+ foreach (Task::all () as $ task ) {
29+ $ task ->user_id = $ task ->server ->owner_id ;
30+ $ task ->save ();
31+ }
32+ });
33+
34+ Schema::table ('tasks ' , function (Blueprint $ table ) {
35+ $ table ->unsignedInteger ('user_id ' )->nullable (false )->change ();
36+ });
2537 }
2638
2739 /**
You can’t perform that action at this time.
0 commit comments