pixelfed/database/migrations/2021_08_23_062246_update_stories_table_fix_expires_at_column.php

53 lines
1.7 KiB
PHP
Raw Normal View History

2021-08-28 02:34:47 +00:00
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateStoriesTableFixExpiresAtColumn extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('stories', function (Blueprint $table) {
2024-07-01 08:39:42 +00:00
$indexes = Schema::getIndexes('stories');
$indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray();
if (in_array('stories_expires_at_index', $indexesFound)) {
$table->dropIndex('stories_expires_at_index');
}
2021-08-28 02:34:47 +00:00
$table->timestamp('expires_at')->default(null)->index()->nullable()->change();
$table->boolean('can_reply')->default(true);
$table->boolean('can_react')->default(true);
2021-09-04 02:47:14 +00:00
$table->string('object_id')->nullable()->unique();
$table->string('object_uri')->nullable()->unique();
$table->string('bearcap_token')->nullable();
2021-08-28 02:34:47 +00:00
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('stories', function (Blueprint $table) {
2024-07-01 08:39:42 +00:00
$indexes = Schema::getIndexes('stories');
$indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray();
if (in_array('stories_expires_at_index', $indexesFound)) {
$table->dropIndex('stories_expires_at_index');
}
2021-08-28 02:34:47 +00:00
$table->timestamp('expires_at')->default(null)->index()->nullable()->change();
$table->dropColumn('can_reply');
$table->dropColumn('can_react');
2021-09-04 02:47:14 +00:00
$table->dropColumn('object_id');
$table->dropColumn('object_uri');
$table->dropColumn('bearcap_token');
2021-08-28 02:34:47 +00:00
});
}
}