Export from Sequel Pro to a Laravel Migration

Developer Tools

November 16th, 2016

sequel-pro-valet.png

The two primary ways developers create their database scheme is either by building migrations first or building out their database structure in a tool like Sequel Pro first, then once they are happy, create the migrations.

If you are in the second camp and use Sequel Pro, Colin Viebrock created a Laravel Migration exporter tool that hooks right into the app.

It works by cloning or downloading the package and then installing by double clicking on the included “ExportToLaravelMigration.spBundle” file.

Next, connect to a database, and select a table in the left-hand column. From the application menu, choose Bundles › Export › Export to Laravel Migration, or use the keyboard shortcut ⌃⌥⌘M (CTRL + OPTION + CMD + M).

Export to Laravel Migrations

Here is an example of a migration it created for a category table:

1<?php
2
3use Illuminate\Support\Facades\Schema;
4use Illuminate\Database\Schema\Blueprint;
5use Illuminate\Database\Migrations\Migration;
6
7/**
8 * Migration auto-generated by Sequel Pro Laravel Export
9 * @see https://github.com/cviebrock/sequel-pro-laravel-export
10 */
11class CreateCategoriesTable extends Migration
12{
13 /**
14 * Run the migrations.
15 *
16 * @return void
17 */
18 public function up()
19 {
20 Schema::create('categories', function (Blueprint $table) {
21 $table->increments('id');
22 $table->integer('wp_id');
23 $table->string('name', 255);
24 $table->string('slug', 255);
25 $table->text('description');
26 $table->nullableTimestamps();
27
28 $table->unique('slug', 'categories_slug_unique');
29 });
30 }
31
32 /**
33 * Reverse the migrations.
34 *
35 * @return void
36 */
37 public function down()
38 {
39 Schema::dropIfExists('categories');
40 }
41}

The migration file will then be saved to your desktop, and you can move it to your projects migrations directory, so it’s ready to be used through the Artisan command.

**Download:** [GitHub](https://github.com/cviebrock/sequel-pro-laravel-export) **License:** MIT

Filed in:

Eric L. Barnes

Eric is the creator of Laravel News and has been covering Laravel since 2012.

Laravel News Partners