You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In addition to the Laravel methods to drop indexes, methods to drop indexes if they exist have been added.
396
397
The methods `dropFullTextIfExists`, `dropIndexIfExists`, `dropPrimaryIfExists`, `dropSpatialIndexIfExists` and `dropSpatialIndexIfExists` match the semantics of their laravel originals.
397
398
399
+
#### Concurrently
400
+
401
+
With PostgreSQL, you can say goodbye to half-executed migrations on errors and the tedious effort to restore the database to a stable state.
402
+
This is all thanks to its transactional approach: either all changes of a migration to your database will succeed or will be rolled back.
403
+
Yay!
404
+
Because of that, creating an index on a big table will take a long time and block all SQL queries during that time.
405
+
You can now instruct PostgreSQL to create the index in the background without blocking any SQL query, but you must opt out of running those changes in a transaction.
406
+
407
+
```php
408
+
<?php
409
+
410
+
use Illuminate\Database\Migrations\Migration;
411
+
use Tpetry\PostgresqlEnhanced\Schema\Blueprint;
412
+
use Tpetry\PostgresqlEnhanced\Support\Facades\Schema;
413
+
414
+
return new class extends Migration
415
+
{
416
+
public $withinTransaction = false;
417
+
418
+
public function up(): void
419
+
{
420
+
Schema::table('blog_visits', function (Blueprint $table) {
$this->assertEquals([], $this->getConnection()->returningStatement('update example set str = ? where str = ? returning str', ['IS7PD2jn', '8lnreu2H']));
30
-
});
31
-
32
-
// The pretend mode has been changed in Laravel 10.30.0 to include the bindings in the query string
33
-
if (Comparator::greaterThanOrEqualTo($this->app->version(), '10.30.0')) {
34
-
$this->assertEquals(["update example set str = 'IS7PD2jn' where str = '8lnreu2H' returning str"], array_column($queries, 'query'));
35
-
} else {
36
-
$this->assertEquals(['update example set str = ? where str = ? returning str'], array_column($queries, 'query'));
$this->assertEquals([], $this->getConnection()->returningStatement('update example set str = ? where str = ? returning str', ['IS7PD2jn', '8lnreu2H']));
29
+
}, pretend: true);
30
+
31
+
// The pretend mode has been changed in Laravel 10.30.0 to include the bindings in the query string
32
+
match (Comparator::greaterThanOrEqualTo($this->app->version(), '10.30.0')) {
33
+
true => $this->assertEquals(["update example set str = 'IS7PD2jn' where str = '8lnreu2H' returning str"], array_column($queries, 'query')),
34
+
false => $this->assertEquals(['update example set str = ? where str = ? returning str'], array_column($queries, 'query')),
35
+
};
40
36
$this->assertEquals(1, $this->getConnection()->selectOne('SELECT COUNT(*) AS count FROM example WHERE str = ?', ['8lnreu2H'])->count);
Schema::table('test_260745', function (Blueprint$table): void {
26
+
$table->fullText(['col_818827'])->concurrently();
27
+
});
28
+
}, pretend: true);
29
+
$this->assertEquals(['create index concurrently "test_260745_col_818827_fulltext" on "test_260745" using gin ((to_tsvector(\'english\', "col_818827")))'], array_column($queries, 'query'));
$this->assertEquals(['create index concurrently "index_495761" on "test_406163" using gin ((to_tsvector(\'english\', "col_833985")))'], array_column($queries, 'query'));
$this->assertEquals(['create index concurrently "test_734987_col_617117_spatialindex" on "test_734987" using gist ("col_617117")'], array_column($queries, 'query'));
$this->assertEquals(['create unique index concurrently "test_144373_col_988745_unique" on "test_144373" ("col_988745")'], array_column($queries, 'query'));
if (Comparator::lessThan($this->app->version(), '8.74.0')) {
@@ -25,7 +154,7 @@ public function testIfNotExistsFulltextByColumn(): void
25
154
Schema::table('test_806712', function (Blueprint$table): void {
26
155
$table->fullText(['col_274742'])->ifNotExists();
27
156
});
28
-
});
157
+
}, pretend: true);
29
158
$this->assertEquals(['create index if not exists "test_806712_col_274742_fulltext" on "test_806712" using gin ((to_tsvector(\'english\', "col_274742")))'], array_column($queries, 'query'));
0 commit comments