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