1
0
mirror of https://github.com/flarum/core.git synced 2025-08-04 15:37:51 +02:00

feat: messages extension (#4028)

* feat: private messages
This commit is contained in:
Sami Mazouz
2024-09-28 11:12:52 +01:00
committed by GitHub
parent bc4356a7f5
commit b74ecbfacf
186 changed files with 5331 additions and 605 deletions

View File

@@ -12,25 +12,55 @@ use Illuminate\Database\Schema\Builder;
return [
'up' => function (Builder $schema) {
$preferences = $schema->getConnection()->getSchemaGrammar()->wrap('preferences');
if ($schema->getConnection()->getDriverName() === 'pgsql') {
$users = $schema->getConnection()->getSchemaGrammar()->wrapTable('users');
$preferences = $schema->getConnection()->getSchemaGrammar()->wrap('preferences');
$schema->getConnection()->statement("ALTER TABLE $users ALTER COLUMN $preferences TYPE JSON USING preferences::TEXT::JSON");
$schema->getConnection()->statement("ALTER TABLE $users ALTER COLUMN $preferences TYPE JSON USING $preferences::TEXT::JSON");
} else {
$schema->table('users', function (Blueprint $table) {
$table->json('preferences')->nullable()->change();
$table->json('preferences_json')->nullable();
});
if ($schema->getConnection()->getDriverName() === 'mysql') {
$schema->getConnection()->table('users')->update([
'preferences_json' => $schema->getConnection()->raw("CAST(CONVERT($preferences USING utf8mb4) AS JSON)"),
]);
}
$schema->table('users', function (Blueprint $table) {
$table->dropColumn('preferences');
});
$schema->table('users', function (Blueprint $table) {
$table->renameColumn('preferences_json', 'preferences');
});
}
},
'down' => function (Builder $schema) {
$preferences = $schema->getConnection()->getSchemaGrammar()->wrap('preferences');
if ($schema->getConnection()->getDriverName() === 'pgsql') {
$users = $schema->getConnection()->getSchemaGrammar()->wrapTable('users');
$preferences = $schema->getConnection()->getSchemaGrammar()->wrap('preferences');
$schema->getConnection()->statement("ALTER TABLE $users ALTER COLUMN $preferences TYPE BYTEA USING preferences::TEXT::BYTEA");
} else {
$schema->table('users', function (Blueprint $table) {
$table->binary('preferences')->nullable()->change();
$table->binary('preferences_binary')->nullable();
});
if ($schema->getConnection()->getDriverName() === 'mysql') {
$schema->getConnection()->table('users')->update([
'preferences_binary' => $schema->getConnection()->raw($preferences),
]);
}
$schema->table('users', function (Blueprint $table) {
$table->dropColumn('preferences');
});
$schema->table('users', function (Blueprint $table) {
$table->renameColumn('preferences_binary', 'preferences');
});
}
}

View File

@@ -18,7 +18,21 @@ return [
$schema->getConnection()->statement("ALTER TABLE $notifications ALTER COLUMN $data TYPE JSON USING data::TEXT::JSON");
} else {
$schema->table('notifications', function (Blueprint $table) {
$table->json('data')->nullable()->change();
$table->json('data_json')->nullable();
});
if ($schema->getConnection()->getDriverName() === 'mysql') {
$schema->getConnection()->table('notifications')->update([
'data_json' => $schema->getConnection()->raw('CAST(CONVERT(data USING utf8mb4) AS JSON)'),
]);
}
$schema->table('notifications', function (Blueprint $table) {
$table->dropColumn('data');
});
$schema->table('notifications', function (Blueprint $table) {
$table->renameColumn('data_json', 'data');
});
}
},
@@ -30,7 +44,21 @@ return [
$schema->getConnection()->statement("ALTER TABLE $notifications ALTER COLUMN $data TYPE BYTEA USING data::TEXT::BYTEA");
} else {
$schema->table('notifications', function (Blueprint $table) {
$table->binary('data')->nullable()->change();
$table->binary('data_binary')->nullable();
});
if ($schema->getConnection()->getDriverName() === 'mysql') {
$schema->getConnection()->table('notifications')->update([
'data_binary' => $schema->getConnection()->raw('data'),
]);
}
$schema->table('notifications', function (Blueprint $table) {
$table->dropColumn('data');
});
$schema->table('notifications', function (Blueprint $table) {
$table->renameColumn('data_binary', 'data');
});
}
}