1: | <?php |
2: | |
3: | use Illuminate\Database\Migrations\Migration; |
4: | use Illuminate\Database\Schema\Blueprint; |
5: | use Illuminate\Database\Capsule\Manager as Capsule; |
6: | |
7: | class CreateContactsFulltextIndexes extends Migration |
8: | { |
9: | |
10: | |
11: | |
12: | |
13: | |
14: | public function up() |
15: | { |
16: | $prefix = Capsule::connection()->getTablePrefix(); |
17: | |
18: | Capsule::schema()->table('contacts', function (Blueprint $table) use ($prefix) { |
19: | $table->index('Storage'); |
20: | $table->index('Frequency'); |
21: | |
22: | Capsule::statement( |
23: | "CREATE FULLTEXT INDEX contacts_fullname_index ON {$prefix}contacts (FullName)" |
24: | ); |
25: | Capsule::statement( |
26: | "CREATE FULLTEXT INDEX contacts_viewemail_index ON {$prefix}contacts (ViewEmail)" |
27: | ); |
28: | Capsule::statement( |
29: | "CREATE FULLTEXT INDEX contacts_personalemail_index ON {$prefix}contacts (PersonalEmail)" |
30: | ); |
31: | Capsule::statement( |
32: | "CREATE FULLTEXT INDEX contacts_businessemail_index ON {$prefix}contacts (BusinessEmail)" |
33: | ); |
34: | Capsule::statement( |
35: | "CREATE FULLTEXT INDEX contacts_businesscompany_index ON {$prefix}contacts (BusinessCompany)" |
36: | ); |
37: | Capsule::statement( |
38: | "CREATE FULLTEXT INDEX contacts_otheremail_index ON {$prefix}contacts (OtherEmail)" |
39: | ); |
40: | }); |
41: | |
42: | Capsule::schema()->table('contacts_groups', function (Blueprint $table) use ($prefix) { |
43: | Capsule::statement( |
44: | "CREATE FULLTEXT INDEX contacts_groups_name_index ON {$prefix}contacts_groups (Name)" |
45: | ); |
46: | }); |
47: | } |
48: | |
49: | |
50: | |
51: | |
52: | |
53: | |
54: | public function down() |
55: | { |
56: | Capsule::schema()->table('contacts', function (Blueprint $table) { |
57: | $table->dropIndex(['Storage']); |
58: | $table->dropIndex(['Frequency']); |
59: | $table->dropIndex(['FullName']); |
60: | $table->dropIndex(['PersonalEmail']); |
61: | $table->dropIndex(['ViewEmail']); |
62: | $table->dropIndex(['BusinessEmail']); |
63: | $table->dropIndex(['BusinessCompany']); |
64: | $table->dropIndex(['OtherEmail']); |
65: | }); |
66: | |
67: | Capsule::schema()->table('contacts_groups', function (Blueprint $table) { |
68: | $table->dropIndex(['Name']); |
69: | }); |
70: | } |
71: | } |
72: | |