Twill's generated migrations are standard Laravel migrations, enhanced with helpers to create the default fields any module will use:
1<?php 2 3// main table, holds all non translated fields 4Schema::create('table_name_plural', function (Blueprint $table) { 5 createDefaultTableFields($table); 6 // will add the following instructions to your migration file 7 // $table->increments('id'); 8 // $table->softDeletes(); 9 // $table->timestamps();10 // $table->boolean('published');11});12 13// translation table, holds translated fields14Schema::create('table_name_singular_translations', function (Blueprint $table) {15 createDefaultTranslationsTableFields($table, 'tableNameSingular');16 // will add the following instructions to your migration file17 // createDefaultTableFields($table);18 // $table->string('locale', 6)->index();19 // $table->boolean('active');20 // $table->integer("{$tableNameSingular}_id")->unsigned();21 // $table->foreign("{$tableNameSingular}_id", "fk_{$tableNameSingular}_translations_{$tableNameSingular}_id")->references('id')->on($table)->onDelete('CASCADE');22 // $table->unique(["{$tableNameSingular}_id", 'locale']);23});24 25// slugs table, holds slugs history26Schema::create('table_name_singular_slugs', function (Blueprint $table) {27 createDefaultSlugsTableFields($table, 'tableNameSingular');28 // will add the following instructions to your migration file29 // createDefaultTableFields($table);30 // $table->string('slug');31 // $table->string('locale', 6)->index();32 // $table->boolean('active');33 // $table->integer("{$tableNameSingular}_id")->unsigned();34 // $table->foreign("{$tableNameSingular}_id", "fk_{$tableNameSingular}_translations_{$tableNameSingular}_id")->references('id')->on($table)->onDelete('CASCADE')->onUpdate('NO ACTION');35});36 37// revisions table, holds revision history38Schema::create('table_name_singular_revisions', function (Blueprint $table) {39 createDefaultRevisionTableFields($table, 'tableNameSingular');40 // will add the following instructions to your migration file41 // $table->increments('id');42 // $table->timestamps();43 // $table->json('payload');44 // $table->integer("{$tableNameSingular}_id")->unsigned()->index();45 // $table->integer('user_id')->unsigned()->nullable();46 // $table->foreign("{$tableNameSingular}_id")->references('id')->on("{$tableNamePlural}")->onDelete('cascade');47 // $table->foreign('user_id')->references('id')->on('users')->onDelete('set null');48});49 50// related content table, holds many to many association between 2 tables51Schema::create('table_name_singular1_table_name_singular2', function (Blueprint $table) {52 createDefaultRelationshipTableFields($table, $table1NameSingular, $table2NameSingular);53 // will add the following instructions to your migration file54 // $table->integer("{$table1NameSingular}_id")->unsigned();55 // $table->foreign("{$table1NameSingular}_id")->references('id')->on($table1NamePlural)->onDelete('cascade');56 // $table->integer("{$table2NameSingular}_id")->unsigned();57 // $table->foreign("{$table2NameSingular}_id")->references('id')->on($table2NamePlural)->onDelete('cascade');58 // $table->index(["{$table2NameSingular}_id", "{$table1NameSingular}_id"]);59});
A few CRUD controllers require that your model have a field in the database with a specific name: published
, publish_start_date
, publish_end_date
, public
, and position
, so stick with those column names if you are going to use publication status, timeframe and reorderable listings.