Repository: laravel-shift/blueprint (php)

Issue:
Laravel 9, Scout fullText index
<!-- PLEASE COMPLETE THIS TEMPLATE -->

### Synopsis:
Laravel 9 comes with a database driver for Laravel Scout. It would be great if we could add support for `fullText` indexes which is one of the recommended data types.

### Proposed Syntax:

`foo: fullText` should output `$table->fullText('foo')` in migrations

### Expected Behavior:

I hoped it was enough to add `'fullText' => 'fullText', ` to the `ModelLexer->dataTypes` array, but it didn't do it :)


Pull request description:
Support `fullText` column data type
Continuation of #550.

---
Closes #548

Patch:
diff --git a/composer.json b/composer.json
index 6d0a93f..47162c5 100644
--- a/composer.json
+++ b/composer.json
@@ -12,7 +12,7 @@
         "illuminate/console": "^9.0",
         "illuminate/filesystem": "^9.0",
         "illuminate/support": "^9.0",
-        "laravel-shift/faker-registry": "^0.1",
+        "laravel-shift/faker-registry": "^0.2.0",
         "symfony/yaml": "^6.0"
     },
     "require-dev": {
diff --git a/src/Lexers/ModelLexer.php b/src/Lexers/ModelLexer.php
index bddd90a..3e7d073 100644
--- a/src/Lexers/ModelLexer.php
+++ b/src/Lexers/ModelLexer.php
@@ -35,6 +35,7 @@ class ModelLexer implements Lexer
         'double' => 'double',
         'enum' => 'enum',
         'float' => 'float',
+        'fulltext' => 'fullText',
         'geometry' => 'geometry',
         'geometrycollection' => 'geometryCollection',
         'increments' => 'increments',
diff --git a/src/Translators/Rules.php b/src/Translators/Rules.php
index c6b594e..a2b0e24 100644
--- a/src/Translators/Rules.php
+++ b/src/Translators/Rules.php
@@ -34,7 +34,7 @@ class Rules
         }
 
         // hack for tests...
-        if (in_array($column->dataType(), ['string', 'char', 'text', 'longText'])) {
+        if (in_array($column->dataType(), ['string', 'char', 'text', 'longText', 'fullText'])) {
             array_push($rules, self::overrideStringRuleForSpecialNames($column->name()));
         }
 


Test patch:
diff --git a/tests/Feature/Generators/MigrationGeneratorTest.php b/tests/Feature/Generators/MigrationGeneratorTest.php
index 5e15904..86d49f9 100644
--- a/tests/Feature/Generators/MigrationGeneratorTest.php
+++ b/tests/Feature/Generators/MigrationGeneratorTest.php
@@ -685,6 +685,7 @@ class MigrationGeneratorTest extends TestCase
             ['drafts/columns-with-comments.yaml', 'database/migrations/timestamp_create_professions_table.php', 'migrations/columns-with-comments.php'],
             ['drafts/boolean-column-default.yaml', 'database/migrations/timestamp_create_posts_table.php', 'migrations/boolean-column-default.php'],
             ['drafts/foreign-with-class.yaml', 'database/migrations/timestamp_create_events_table.php', 'migrations/foreign-with-class.php'],
+            ['drafts/full-text.yaml', 'database/migrations/timestamp_create_posts_table.php', 'migrations/full-text.php'],
         ];
     }
 }
diff --git a/tests/Feature/Lexers/ModelLexerTest.php b/tests/Feature/Lexers/ModelLexerTest.php
index 2a60b05..c139e83 100644
--- a/tests/Feature/Lexers/ModelLexerTest.php
+++ b/tests/Feature/Lexers/ModelLexerTest.php
@@ -225,6 +225,7 @@ class ModelLexerTest extends TestCase
                 'Model' => [
                     'sequence' => 'unsignedbiginteger autoincrement',
                     'content' => 'longtext',
+                    'search' => 'fulltext',
                     'saved_at' => 'timestamptz usecurrent',
                     'updated_at' => 'timestamptz usecurrent usecurrentOnUpdate',
                 ],
@@ -242,7 +243,7 @@ class ModelLexerTest extends TestCase
         $this->assertFalse($model->usesSoftDeletes());
 
         $columns = $model->columns();
-        $this->assertCount(5, $columns);
+        $this->assertCount(6, $columns);
         $this->assertEquals('id', $columns['id']->name());
         $this->assertEquals('id', $columns['id']->dataType());
         $this->assertEquals([], $columns['id']->attributes());
@@ -255,6 +256,10 @@ class ModelLexerTest extends TestCase
         $this->assertEquals('longText', $columns['content']->dataType());
         $this->assertEquals([], $columns['content']->attributes());
         $this->assertEquals([], $columns['content']->modifiers());
+        $this->assertEquals('search', $columns['search']->name());
+        $this->assertEquals('fullText', $columns['search']->dataType());
+        $this->assertEquals([], $columns['search']->attributes());
+        $this->assertEquals([], $columns['search']->modifiers());
         $this->assertEquals('saved_at', $columns['saved_at']->name());
         $this->assertEquals('timestampTz', $columns['saved_at']->dataType());
         $this->assertEquals([], $columns['saved_at']->attributes());
diff --git a/tests/fixtures/drafts/all-column-types.yaml b/tests/fixtures/drafts/all-column-types.yaml
index 9a9f6f0..123d44f 100644
--- a/tests/fixtures/drafts/all-column-types.yaml
+++ b/tests/fixtures/drafts/all-column-types.yaml
@@ -12,6 +12,7 @@ models:
     double: double
     enum: enum:1,2,3
     float: float
+    fullText: fullText
     geometry: geometry
     geometryCollection: geometryCollection
     integer: integer
diff --git a/tests/fixtures/drafts/full-text.yaml b/tests/fixtures/drafts/full-text.yaml
new file mode 100644
index 0000000..3ce83a0
--- /dev/null
+++ b/tests/fixtures/drafts/full-text.yaml
@@ -0,0 +1,4 @@
+models:
+  Post:
+    title: string
+    content: fullText
diff --git a/tests/fixtures/factories/all-column-types.php b/tests/fixtures/factories/all-column-types.php
index 4769949..9c85b11 100644
--- a/tests/fixtures/factories/all-column-types.php
+++ b/tests/fixtures/factories/all-column-types.php
@@ -34,6 +34,7 @@ class AllTypeFactory extends Factory
             'double' => $this->faker->randomFloat(0, 0, 9999999999.),
             'enum' => $this->faker->randomElement(["1","2","3"]),
             'float' => $this->faker->randomFloat(0, 0, 9999999999.),
+            'fullText' => $this->faker->text,
             'geometry' => $this->faker->word,
             'geometryCollection' => $this->faker->word,
             'integer' => $this->faker->numberBetween(-10000, 10000),
diff --git a/tests/fixtures/migrations/full-text.php b/tests/fixtures/migrations/full-text.php
new file mode 100644
index 0000000..96583e9
--- /dev/null
+++ b/tests/fixtures/migrations/full-text.php
@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreatePostsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('posts', function (Blueprint $table) {
+            $table->id();
+            $table->string('title');
+            $table->fullText('content');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('posts');
+    }
+}
diff --git a/tests/fixtures/models/all-column-types.php b/tests/fixtures/models/all-column-types.php
index fdc404e..be6427b 100644
--- a/tests/fixtures/models/all-column-types.php
+++ b/tests/fixtures/models/all-column-types.php
@@ -26,6 +26,7 @@ class AllType extends Model
         'double',
         'enum',
         'float',
+        'fullText',
         'geometry',
         'geometryCollection',
         'integer',