Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanthammar/b5abf6e31296503e0dcc34c18c7cbbed to your computer and use it in GitHub Desktop.
Save tanthammar/b5abf6e31296503e0dcc34c18c7cbbed to your computer and use it in GitHub Desktop.
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddIndexToTranslatedNamesTable extends Migration
{
protected $tables = ['organizers', 'events', 'bookers',
'categories', 'terms', 'tabs', 'helps',
'products', 'rentals', 'services', 'articles'];
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$tables = $this->tables;
foreach ($tables as $table) {
Schema::table($table, function (Blueprint $table) {
$table->string('name_sv')->virtualAs('name->>"$.sv"');
$table->index('name_sv');
$table->string('name_en')->virtualAs('name->>"$.en"');
$table->index('name_en');
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment