mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-18 12:31:27 +00:00
Merge pull request #505 from pixelfed/frontend-ui-refactor
Update migration to add pgsql support
This commit is contained in:
commit
47339bd5ae
1 changed files with 24 additions and 1 deletions
|
@ -13,7 +13,30 @@ class UpdateStatusVisibilityDefaults extends Migration
|
||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
DB::statement("ALTER TABLE statuses CHANGE COLUMN visibility visibility ENUM('public','unlisted','private','direct', 'draft') NOT NULL DEFAULT 'public'");
|
$type = config('database.default');
|
||||||
|
switch($type)
|
||||||
|
{
|
||||||
|
case 'mysql':
|
||||||
|
DB::statement("ALTER TABLE statuses CHANGE COLUMN visibility visibility ENUM('public','unlisted','private','direct', 'draft') NOT NULL DEFAULT 'public'");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'pgsql':
|
||||||
|
$sql = <<<'SQL'
|
||||||
|
# rename the existing type
|
||||||
|
ALTER TYPE visibility_enum RENAME TO visibility_enum_old;
|
||||||
|
|
||||||
|
# create the new type
|
||||||
|
CREATE TYPE visibility_enum AS ENUM('public','unlisted','private','direct', 'draft');
|
||||||
|
|
||||||
|
# update the columns to use the new type
|
||||||
|
ALTER TABLE statuses ALTER COLUMN visibility TYPE visibility_enum USING visibility::text::visibility_enum;
|
||||||
|
|
||||||
|
# remove the old type
|
||||||
|
DROP TYPE visibility_enum_old;
|
||||||
|
SQL;
|
||||||
|
DB::statement($sql);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue