File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -353,6 +353,20 @@ public function disableForeignKeyConstraints(): bool
353353 );
354354 }
355355
356+ /**
357+ * Disable foreign key constraints during the execution of a callback.
358+ */
359+ public function withoutForeignKeyConstraints (Closure $ callback ): mixed
360+ {
361+ $ this ->disableForeignKeyConstraints ();
362+
363+ try {
364+ return $ callback ();
365+ } finally {
366+ $ this ->enableForeignKeyConstraints ();
367+ }
368+ }
369+
356370 /**
357371 * Get the foreign keys for a given table.
358372 */
Original file line number Diff line number Diff line change 4444 * @method static void rename(string $from, string $to)
4545 * @method static bool enableForeignKeyConstraints()
4646 * @method static bool disableForeignKeyConstraints()
47+ * @method static mixed withoutForeignKeyConstraints(\Closure $callback)
4748 * @method static \Hyperf\Database\Connection getConnection()
4849 * @method static Builder setConnection(\Hyperf\Database\Connection $connection)
4950 * @method static void blueprintResolver(\Closure $resolver)
You can’t perform that action at this time.
0 commit comments