PostgreSQL Support (#4486)

Co-authored-by: Matthew Penner <matthew@pterodactyl.io>
This commit is contained in:
Lance Pioch 2022-11-25 15:29:04 -05:00 committed by GitHub
parent 21613fa602
commit 3bf5a71802
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
223 changed files with 912 additions and 1052 deletions

View file

@ -7,22 +7,41 @@ class RemoveUserInteraction extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
// Remove User Interaction from startup config
DB::table('eggs')->update([
'config_startup' => DB::raw('JSON_REMOVE(config_startup, \'$.userInteraction\')'),
]);
switch (DB::getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME)) {
case 'mysql':
DB::table('eggs')->update([
'config_startup' => DB::raw('JSON_REMOVE(config_startup, \'$.userInteraction\')'),
]);
break;
case 'pgsql':
DB::table('eggs')->update([
'config_startup' => DB::raw('config_startup::jsonb - \'userInteraction\''),
]);
break;
}
}
public function down()
/**
* Reverse the migrations.
*/
public function down(): void
{
// Add blank User Interaction array back to startup config
DB::table('eggs')->update([
'config_startup' => DB::raw('JSON_SET(config_startup, \'$.userInteraction\', JSON_ARRAY())'),
]);
switch (DB::getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME)) {
case 'mysql':
DB::table('eggs')->update([
'config_startup' => DB::raw('JSON_SET(config_startup, \'$.userInteraction\', JSON_ARRAY())'),
]);
break;
case 'pgsql':
DB::table('eggs')->update([
'config_startup' => DB::raw('jsonb_set(config_startup::jsonb, \'$.userInteraction\', jsonb_build_array())'),
]);
break;
}
}
}