3 use Illuminate\Database\Migrations\Migration;
4 use Illuminate\Database\Schema\Blueprint;
5 use Illuminate\Support\Facades\DB;
7 return new class extends Migration
10 public static $timestamp_fields = [
38 'discord_bot_commands' => [
43 'discord_channels' => [
64 'episode_players' => [
77 'guessing_guesses' => [
81 'guessing_winners' => [
93 'password_resets' => [
96 'personal_access_tokens' => [
117 'technique_chapter' => [
121 'technique_maps' => [
125 'technique_relations' => [
129 'technique_translations' => [
137 'twitch_bot_commands' => [
154 * Run the migrations.
158 public function up() {
159 foreach (static::$timestamp_fields as $table => $fields) {
161 foreach ($fields as $field) {
162 $updates[$field] = DB::raw('CONVERT_TZ(`'.$field.'`, \'+00:00\', \'SYSTEM\')');
165 DB::table($table)->update($updates);
166 } catch (\Exception $e) {
167 echo $e->getMessage(), PHP_EOL;
173 * Reverse the migrations.
177 public function down() {
178 foreach (static::$timestamp_fields as $table => $fields) {
180 foreach ($fields as $field) {
181 $updates[$field] = DB::raw('CONVERT_TZ(`'.$field.'`, \'SYSTEM\', \'+00:00\')');
184 DB::table($table)->update($updates);
185 } catch (\Exception $e) {
186 echo $e->getMessage(), PHP_EOL;