PHPackages                             stidges/laravel-fk-migration - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. stidges/laravel-fk-migration

ActiveLibrary[Database &amp; ORM](/categories/database)

stidges/laravel-fk-migration
============================

Helpful base migration for creating all your foreign key without worrying about the order of your migrations.

1.1.0(11y ago)394.2k1MITPHPPHP &gt;=5.4.0

Since Jun 22Pushed 11y ago4 watchersCompare

[ Source](https://github.com/stidges/laravel-fk-migration)[ Packagist](https://packagist.org/packages/stidges/laravel-fk-migration)[ Docs](https://github.com/stidges/laravel-fk-migration)[ RSS](/packages/stidges-laravel-fk-migration/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Laravel FK Migration
====================

[](#laravel-fk-migration)

[![Latest Stable Version](https://camo.githubusercontent.com/3f3ed54d2212cd477ca5d8e08c76cb01a7c612ffe184811a9d35a49e1399d3c7/68747470733a2f2f706f7365722e707567782e6f72672f737469646765732f6c61726176656c2d666b2d6d6967726174696f6e2f76657273696f6e2e706e67)](https://packagist.org/packages/stidges/laravel-fk-migration) [![Total Downloads](https://camo.githubusercontent.com/525abea3005e39a2880036a3068c3568ca91449ee767965aaf0fe60ccc95caa5/68747470733a2f2f706f7365722e707567782e6f72672f737469646765732f6c61726176656c2d666b2d6d6967726174696f6e2f646f776e6c6f6164732e706e67)](https://packagist.org/packages/stidges/laravel-fk-migration) [![Build Status](https://camo.githubusercontent.com/a94aaaa962abba5efd598fea5a854b3023a44fed900ddc18ef47f0df3359f4fc/68747470733a2f2f7472617669732d63692e6f72672f737469646765732f6c61726176656c2d666b2d6d6967726174696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/stidges/laravel-fk-migration) [![License](https://camo.githubusercontent.com/6966b134252f70b876fff7c1329ac8dfbf12ac4749e4696fd3032d3007042373/68747470733a2f2f706f7365722e707567782e6f72672f737469646765732f6c61726176656c2d666b2d6d6967726174696f6e2f6c6963656e73652e706e67)](https://packagist.org/packages/stidges/laravel-fk-migration)

This [Laravel](http://www.laravel.com) package provides a base migration for you to extend to easily create all your foreign keys. If you ever ran into the problem where you had to reorganize all your migrations due to failing foreign key constraints, this is the package for you!

Getting Started
---------------

[](#getting-started)

This package can be installed through [Composer](http://www.getcomposer.org), just add it to your composer.json file:

```
{
    "require": {
        "stidges/laravel-fk-migration": "1.*"
    }
}
```

After you have added it to your composer.json file, make sure you update your dependencies:

```
composer update
```

Basic Usage
-----------

[](#basic-usage)

To get started, create a new class in your `app/database/migrations/` directory. If you want to make sure this migration gets executed last, you can name it something like `9999_99_99_999999_create_foreign_keys.php` (this might be slightly overdone, but you get the idea).

Next, add the following content to the empty class you just created:

```
