Created
July 4, 2019 06:14
-
-
Save iansltx/299d05d8776f1b096073bcb1fe1dcb36 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Support\Facades\Schema; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Database\Migrations\Migration; | |
class ModifyExistingEnum extends Migration | |
{ | |
public function up() | |
{ | |
$values = implode(', ', array_map(function ($type) { | |
return "'" . $type . "'"; | |
}, ['your', 'new', 'types', 'here'])); | |
DB::statement('ALTER TABLE my_table DROP CONSTRAINT my_table_my_column_check, | |
ADD CONSTRAINT my_table_my_column_check CHECK (my_column::text = ANY (ARRAY['. $values . ']::text[]))'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment