Skip to content

Commit

Permalink
Change precheck order in migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
korridor committed Nov 5, 2024
1 parent 3b3f593 commit 95c1bcd
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ public function up(): void
if ($foreignKeyProblems->count() > 0) {
throw new Exception('There are organizations with non-existing owners, check the logs for more information');
}
Schema::table('organizations', function (Blueprint $table): void {
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('restrict')
->onUpdate('cascade');
});
$foreignKeyProblems = DB::table('members')
->select(['members.id', 'members.organization_id'])
->whereNotExists(function (Builder $query): void {
Expand Down Expand Up @@ -63,6 +56,13 @@ public function up(): void
if ($foreignKeyProblems->count() > 0) {
throw new Exception('There are members with non-existing users, check the logs for more information');
}
Schema::table('organizations', function (Blueprint $table): void {
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('restrict')
->onUpdate('cascade');
});
Schema::table('members', function (Blueprint $table): void {
$table->foreign('organization_id')
->references('id')
Expand Down

0 comments on commit 95c1bcd

Please sign in to comment.