PHPackages                             eyf/laravel-exodus - 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. eyf/laravel-exodus

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

eyf/laravel-exodus
==================

Laravel YAML migrations

v0.2.2(2y ago)81084[1 issues](https://github.com/eightyfive/laravel-exodus/issues)MITPHPPHP &gt;=7.4.28CI failing

Since Jun 5Pushed 2y ago1 watchersCompare

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

READMEChangelog (3)Dependencies (4)Versions (7)Used By (0)

laravel-exodus
==============

[](#laravel-exodus)

Converts YAML to actual Laravel migration files.

Install
-------

[](#install)

```
composer require --dev eyf/laravel-exodus
```

Usage
-----

[](#usage)

### Step 1: Create `database/migrations.yaml` file

[](#step-1-create-databasemigrationsyaml-file)

Define a `posts` table:

```
# database/migrations.yaml

posts:
    id: true
    timestamps: true
    softDeletes: true
    slug: string(100).unique
    title: string
    content: text
    excerpt: string.nullable
    author_id: foreignId.constrained('users')
```

### Step 2: Make migrations (command)

[](#step-2-make-migrations-command)

Run `exodus` command to translate the `yaml` file into actual Laravel migration files:

```
php artisan exodus

Created Migration: 2020_05_05_100005_create_posts_table
```

### Step 3: `migrate` as normal

[](#step-3-migrate-as-normal)

```
php artisan migrate
```

Workflow
--------

[](#workflow)

Exodus is a DEV package, it is meant to ease / speed up development time.

A normal workflow while DEV'ing could be:

1. Create `migrations.yaml` file (Add a `posts` table)
2. `php artisan exodus`
3. `php artisan migrate`
4. Edit `migrations.yaml` file (Add a `users` table)
5. `php artisan exodus`
6. `php artisan migrate:refresh (--seed)`
7. Edit `migrations.yaml` file
8. ... (Repeat)

### The `exodus.lock` file

[](#the-exoduslock-file)

By default the migration file names won't change between multiple `exodus` runs.

This is because Exodus keeps track of the initial migration file name in `database/exodus.lock` (to commit in your repository).

This makes sure `git` sees the edits in the same migration file throughout the whole DEV.

### The `force` option

[](#the-force-option)

Sometimes you may want to bypass the `exodus.lock` file (For example when you want to change the table order creation).

```
php artisan exodus --force
```

What happens:

1. All "old" migration files will be deleted (the ones in current `exodus.lock`)
2. New migration files will be generated (with newest date in filename)

Syntax
------

[](#syntax)

### Column

[](#column)

Any column can be written fluently exactly like in the Laravel migration syntax. In fact Exodus is just a light translator of a "dot notation" `array` to the actual PHP syntax.

```
my_table:
    my_column_name: string(50).nullable.unique
```

### Special column

[](#special-column)

Special column types are the "sugar" methods provided by Laravel for a better developer experience: `id()`, `timestamps()`, `softDeletes()`, `rememberToken()`, etc...

Since these column types don't have a column name (name is in the convention), just specify `true` as their value:

```
my_table:
    id: true
    timestamps: true
    softDeletes: true
```

### Pivot tables

[](#pivot-tables)

For generating a pivot table, just use two table names as follow:

```
users:
    id: true
    name: string

posts:
    id: true
    title: string

"@users @posts": []
```

This will create the following pivot migration file:

```
