Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: disable/enable foreign keys #866

Merged
merged 1 commit into from
Jul 13, 2024
Merged

feat: disable/enable foreign keys #866

merged 1 commit into from
Jul 13, 2024

Conversation

yajra
Copy link
Owner

@yajra yajra commented Jul 13, 2024

fix: #863
fix: #488

Test Script

class UsersSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        Schema::disableForeignKeyConstraints();
        // truncate all tables
        Permission::truncate();
        Role::truncate();
        User::truncate();

        // truncate pivot tables
        DB::table('role_user')->truncate();
        DB::table('permission_role')->truncate();
        DB::table('permission_user')->truncate();
        Schema::enableForeignKeyConstraints();
    }
}

Command

php artisan db:seed UsersSeeder

@yajra
Copy link
Owner Author

yajra commented Jul 13, 2024

Failing tests appear to be due to changes in Laravel 11.15.0, to be fixed on another PR.

@yajra yajra merged commit cc1c879 into master Jul 13, 2024
2 of 4 checks passed
@yajra yajra deleted the patch-fk branch July 13, 2024 04:56
yajra added a commit that referenced this pull request Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disabling foreign key constraints
1 participant