Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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