Laravel has a great mechanism of migrations, but what if you want to visualize your DB schema to see all in one place - to discuss with colleagues, for example. There is a great tool for that - here's a brief overview of Laravel Schema Designer.
Created by Thomas Roelens back in 2013, it still remains an active project - in 2015 it was updated for Laravel 5 version.
In short, LaravelSD is a place where you can create your database schema just by playing with tables/columns/relationships, and then - most important - generate your migration files from the visual schema.
Basically, you register (takes 30 seconds), then go to the main page, enter your database name and start creating a schema.
You start from a clear canvas and can add elements by clicking buttons on the top.
When you click Add Table, you get a popup to fill table name and other parameters.
You fill them in and here's the result - table appears on our canvas, with a lot of buttons to change, basically, anything you want: table, columns, order etc.
As you can see, there are Laravel increments and timestamps already prepared for you.
You can also drag-drop fields to change the order.
Let's add another column title. Again, as you can see - a lot of options, related to Laravel functionality.
And another important feature - foreign keys and relationships between tables. Let's create another table called clients and then link those two together.
First - we create an unsigned integer column with foreign key.
Then - create a relationship: there is a first button on the top.
And here we have also quite a lot of things to choose from. All related to good old Laravel. Really impressive.
And ta-daaa! The result:
So this way you create tables, columns and relationships one-by-one, and here comes the most important/impressive part: as soon as you're ready, you can export the schema. And not only schema - there are a lot of things to export on the menu:
Let's take a schema import as an example - you just get a ZIP archive, which has database/migrations folder with these files in it:
With a real Laravel code:
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateProjectsTable extends Migration {
public function up() {
Schema::create('projects', function(Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->string('title', 255);
$table->integer('client_id')->unsigned();
});
}
public function down() {
Schema::drop('projects');
}
}
So huge respect to the author again for such a tool - there are more functions to explore, so feel free to play with it and use for your projects.
A link once again: LaravelSD.com - Laravel Schema Designer
No comments or questions yet...