mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Fix migrations
This commit is contained in:
parent
88fcb8f36b
commit
4d1180b1c1
14 changed files with 39 additions and 76 deletions
|
@ -5,13 +5,6 @@ use Illuminate\Support\Facades\Schema;
|
|||
|
||||
class UpdateStatusTableChangeCaptionToText extends Migration
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
DB::getDoctrineSchemaManager()
|
||||
->getDatabasePlatform()
|
||||
->registerDoctrineTypeMapping('enum', 'string');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
|
|
|
@ -6,11 +6,6 @@ use Illuminate\Database\Migrations\Migration;
|
|||
|
||||
class AddSnowflakeidsToUsersTable extends Migration
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
|
|
|
@ -6,11 +6,6 @@ use Illuminate\Database\Migrations\Migration;
|
|||
|
||||
class AddLayoutToProfilesTable extends Migration
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
|
|
|
@ -6,11 +6,6 @@ use Illuminate\Database\Migrations\Migration;
|
|||
|
||||
class AddSnowflakeIdsToCollectionsTable extends Migration
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
|
|
|
@ -6,11 +6,6 @@ use Illuminate\Database\Migrations\Migration;
|
|||
|
||||
class AddUniqueToStatusesTable extends Migration
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
|
|
|
@ -6,11 +6,6 @@ use Illuminate\Database\Migrations\Migration;
|
|||
|
||||
class AddObjectIdToStatusesTable extends Migration
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
|
|
|
@ -6,10 +6,6 @@ use Illuminate\Support\Facades\Schema;
|
|||
|
||||
class UpdateStoriesTable extends Migration
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
|
||||
}
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
|
|
|
@ -41,15 +41,15 @@ class AddComposeSettingsToUserSettingsTable extends Migration
|
|||
Schema::table('media', function (Blueprint $table) {
|
||||
$table->string('caption')->change();
|
||||
|
||||
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$indexesFound = $schemaManager->listTableIndexes('media');
|
||||
if (array_key_exists('media_profile_id_index', $indexesFound)) {
|
||||
$indexes = Schema::getIndexes('media');
|
||||
$indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray();
|
||||
if (in_array('media_profile_id_index', $indexesFound)) {
|
||||
$table->dropIndex('media_profile_id_index');
|
||||
}
|
||||
if (array_key_exists('media_mime_index', $indexesFound)) {
|
||||
if (in_array('media_mime_index', $indexesFound)) {
|
||||
$table->dropIndex('media_mime_index');
|
||||
}
|
||||
if (array_key_exists('media_license_index', $indexesFound)) {
|
||||
if (in_array('media_license_index', $indexesFound)) {
|
||||
$table->dropIndex('media_license_index');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -14,10 +14,9 @@ class UpdateStoriesTableFixExpiresAtColumn extends Migration
|
|||
public function up()
|
||||
{
|
||||
Schema::table('stories', function (Blueprint $table) {
|
||||
$sm = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$doctrineTable = $sm->listTableDetails('stories');
|
||||
|
||||
if($doctrineTable->hasIndex('stories_expires_at_index')) {
|
||||
$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');
|
||||
}
|
||||
$table->timestamp('expires_at')->default(null)->index()->nullable()->change();
|
||||
|
@ -37,10 +36,9 @@ class UpdateStoriesTableFixExpiresAtColumn extends Migration
|
|||
public function down()
|
||||
{
|
||||
Schema::table('stories', function (Blueprint $table) {
|
||||
$sm = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$doctrineTable = $sm->listTableDetails('stories');
|
||||
|
||||
if($doctrineTable->hasIndex('stories_expires_at_index')) {
|
||||
$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');
|
||||
}
|
||||
$table->timestamp('expires_at')->default(null)->index()->nullable()->change();
|
||||
|
|
|
@ -14,8 +14,9 @@ class RemoveOldCompoundIndexFromStatusesTable extends Migration
|
|||
public function up()
|
||||
{
|
||||
Schema::table('statuses', function (Blueprint $table) {
|
||||
$sc = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
if(array_key_exists('statuses_in_reply_to_id_reblog_of_id_index', $sc->listTableIndexes('statuses'))) {
|
||||
$indexes = Schema::getIndexes('statuses');
|
||||
$indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray();
|
||||
if (in_array('statuses_in_reply_to_id_reblog_of_id_index', $indexesFound)) {
|
||||
$table->dropIndex('statuses_in_reply_to_id_reblog_of_id_index');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -14,9 +14,9 @@ return new class extends Migration
|
|||
public function up()
|
||||
{
|
||||
Schema::table('avatars', function (Blueprint $table) {
|
||||
$sm = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$indexesFound = $sm->listTableIndexes('avatars');
|
||||
if(array_key_exists("avatars_cdn_url_unique", $indexesFound)) {
|
||||
$indexes = Schema::getIndexes('avatars');
|
||||
$indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray();
|
||||
if (in_array('avatars_cdn_url_unique', $indexesFound)) {
|
||||
$table->dropUnique('avatars_cdn_url_unique');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -25,9 +25,9 @@ return new class extends Migration
|
|||
});
|
||||
|
||||
Schema::table('user_roles', function (Blueprint $table) {
|
||||
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$indexesFound = $schemaManager->listTableIndexes('user_roles');
|
||||
if (array_key_exists('user_roles_profile_id_unique', $indexesFound)) {
|
||||
$indexes = Schema::getIndexes('user_roles');
|
||||
$indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray();
|
||||
if (in_array('user_roles_profile_id_unique', $indexesFound)) {
|
||||
$table->dropUnique('user_roles_profile_id_unique');
|
||||
}
|
||||
$table->unsignedBigInteger('profile_id')->unique()->nullable()->index()->change();
|
||||
|
@ -42,9 +42,9 @@ return new class extends Migration
|
|||
Schema::dropIfExists('parental_controls');
|
||||
|
||||
Schema::table('user_roles', function (Blueprint $table) {
|
||||
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$indexesFound = $schemaManager->listTableIndexes('user_roles');
|
||||
if (array_key_exists('user_roles_profile_id_unique', $indexesFound)) {
|
||||
$indexes = Schema::getIndexes('user_roles');
|
||||
$indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray();
|
||||
if (in_array('user_roles_profile_id_unique', $indexesFound)) {
|
||||
$table->dropUnique('user_roles_profile_id_unique');
|
||||
}
|
||||
$table->unsignedBigInteger('profile_id')->unique()->index()->change();
|
||||
|
|
|
@ -12,9 +12,9 @@ return new class extends Migration
|
|||
public function up(): void
|
||||
{
|
||||
Schema::table('instances', function (Blueprint $table) {
|
||||
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$indexesFound = $schemaManager->listTableIndexes('instances');
|
||||
if (! array_key_exists('instances_nodeinfo_last_fetched_index', $indexesFound)) {
|
||||
$indexes = Schema::getIndexes('instances');
|
||||
$indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray();
|
||||
if (!in_array('instances_nodeinfo_last_fetched_index', $indexesFound)) {
|
||||
$table->index('nodeinfo_last_fetched');
|
||||
}
|
||||
});
|
||||
|
@ -26,9 +26,9 @@ return new class extends Migration
|
|||
public function down(): void
|
||||
{
|
||||
Schema::table('instances', function (Blueprint $table) {
|
||||
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$indexesFound = $schemaManager->listTableIndexes('instances');
|
||||
if (array_key_exists('instances_nodeinfo_last_fetched_index', $indexesFound)) {
|
||||
$indexes = Schema::getIndexes('instances');
|
||||
$indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray();
|
||||
if (in_array('instances_nodeinfo_last_fetched_index', $indexesFound)) {
|
||||
$table->dropIndex('instances_nodeinfo_last_fetched_index');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -12,9 +12,9 @@ return new class extends Migration
|
|||
public function up(): void
|
||||
{
|
||||
Schema::table('statuses', function (Blueprint $table) {
|
||||
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$indexesFound = $schemaManager->listTableIndexes('statuses');
|
||||
if (! array_key_exists('statuses_url_index', $indexesFound)) {
|
||||
$indexes = Schema::getIndexes('statuses');
|
||||
$indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray();
|
||||
if (!in_array('statuses_url_index', $indexesFound)) {
|
||||
$table->index('url');
|
||||
}
|
||||
});
|
||||
|
@ -26,9 +26,9 @@ return new class extends Migration
|
|||
public function down(): void
|
||||
{
|
||||
Schema::table('statuses', function (Blueprint $table) {
|
||||
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$indexesFound = $schemaManager->listTableIndexes('statuses');
|
||||
if (array_key_exists('statuses_url_index', $indexesFound)) {
|
||||
$indexes = Schema::getIndexes('statuses');
|
||||
$indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray();
|
||||
if (in_array('statuses_url_index', $indexesFound)) {
|
||||
$table->dropIndex('statuses_url_index');
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue