Created
May 4, 2019 07:24
-
-
Save ultramarshall/db4441918f1cfee72cd7f6e76e77223d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Table name: users Migration File: 2019_05_04_000000_create_users_table.php | |
<?php | |
use Illuminate\Support\Facades\Schema; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Database\Migrations\Migration; | |
class CreateUsersTable extends Migration | |
{ | |
/** | |
* Schema table name to migrate | |
* @var string | |
*/ | |
public $tableName = 'users'; | |
/** | |
* Run the migrations. | |
* @table users | |
* | |
* @return void | |
*/ | |
public function up() | |
{ | |
Schema::create($this->tableName, function (Blueprint $table) { | |
$table->engine = 'InnoDB'; | |
$table->increments('id'); | |
$table->string('email', 45)->nullable(); | |
$table->string('username', 45)->nullable(); | |
$table->string('password', 45)->nullable(); | |
$table->timestamp('CREATE_DATE')->nullable()->default(DB::raw('CURRENT_TIMESTAMP')); | |
$table->string('CREATE_USER', 45)->nullable(); | |
$table->dateTime('UPDATE_DATE')->nullable(); | |
$table->string('UPDATE_USER', 45)->nullable(); | |
}); | |
} | |
/** | |
* Reverse the migrations. | |
* | |
* @return void | |
*/ | |
public function down() | |
{ | |
Schema::dropIfExists($this->tableName); | |
} | |
} | |
Table name: groups Migration File: 2019_05_04_000000_create_groups_table.php | |
<?php | |
use Illuminate\Support\Facades\Schema; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Database\Migrations\Migration; | |
class CreateGroupsTable extends Migration | |
{ | |
/** | |
* Schema table name to migrate | |
* @var string | |
*/ | |
public $tableName = 'groups'; | |
/** | |
* Run the migrations. | |
* @table groups | |
* | |
* @return void | |
*/ | |
public function up() | |
{ | |
Schema::create($this->tableName, function (Blueprint $table) { | |
$table->engine = 'InnoDB'; | |
$table->increments('id'); | |
$table->string('group_name')->nullable(); | |
$table->tinyInteger('aktif')->nullable(); | |
$table->timestamp('create_date')->nullable()->default(DB::raw('CURRENT_TIMESTAMP')); | |
$table->string('create_user', 45)->nullable(); | |
$table->dateTime('update_date')->nullable(); | |
$table->string('update_user', 45)->nullable(); | |
}); | |
} | |
/** | |
* Reverse the migrations. | |
* | |
* @return void | |
*/ | |
public function down() | |
{ | |
Schema::dropIfExists($this->tableName); | |
} | |
} | |
Table name: tbl_news_category Migration File: 2019_05_04_000000_create_tbl_news_category_table.php | |
<?php | |
use Illuminate\Support\Facades\Schema; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Database\Migrations\Migration; | |
class CreateTblNewsCategoryTable extends Migration | |
{ | |
/** | |
* Schema table name to migrate | |
* @var string | |
*/ | |
public $tableName = 'tbl_news_category'; | |
/** | |
* Run the migrations. | |
* @table tbl_news_category | |
* | |
* @return void | |
*/ | |
public function up() | |
{ | |
Schema::create($this->tableName, function (Blueprint $table) { | |
$table->engine = 'InnoDB'; | |
$table->increments('id'); | |
$table->string('news_category_name', 45)->nullable(); | |
}); | |
} | |
/** | |
* Reverse the migrations. | |
* | |
* @return void | |
*/ | |
public function down() | |
{ | |
Schema::dropIfExists($this->tableName); | |
} | |
} | |
Table name: news_category Migration File: 2019_05_04_000000_create_news_category_table.php | |
<?php | |
use Illuminate\Support\Facades\Schema; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Database\Migrations\Migration; | |
class CreateNewsCategoryTable extends Migration | |
{ | |
/** | |
* Schema table name to migrate | |
* @var string | |
*/ | |
public $tableName = 'news_category'; | |
/** | |
* Run the migrations. | |
* @table news_category | |
* | |
* @return void | |
*/ | |
public function up() | |
{ | |
Schema::create($this->tableName, function (Blueprint $table) { | |
$table->engine = 'InnoDB'; | |
$table->increments('id'); | |
$table->string('category_name', 45)->nullable(); | |
$table->timestamp('create_date')->nullable(); | |
$table->string('create_user', 45)->nullable(); | |
$table->dateTime('update_date')->nullable(); | |
$table->string('update_user', 45)->nullable(); | |
}); | |
} | |
/** | |
* Reverse the migrations. | |
* | |
* @return void | |
*/ | |
public function down() | |
{ | |
Schema::dropIfExists($this->tableName); | |
} | |
} | |
Table name: news Migration File: 2019_05_04_000000_create_news_table.php | |
<?php | |
use Illuminate\Support\Facades\Schema; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Database\Migrations\Migration; | |
class CreateNewsTable extends Migration | |
{ | |
/** | |
* Schema table name to migrate | |
* @var string | |
*/ | |
public $tableName = 'news'; | |
/** | |
* Run the migrations. | |
* @table news | |
* | |
* @return void | |
*/ | |
public function up() | |
{ | |
Schema::create($this->tableName, function (Blueprint $table) { | |
$table->engine = 'InnoDB'; | |
$table->increments('id'); | |
$table->string('title', 45)->nullable(); | |
$table->string('body', 45)->nullable(); | |
$table->integer('news_category_id'); | |
$table->integer('users_id'); | |
$table->index(["users_id"], 'fk_news_users1_idx'); | |
$table->index(["news_category_id"], 'fk_news_news_category1_idx'); | |
$table->foreign('news_category_id', 'fk_news_news_category1_idx') | |
->references('id')->on('news_category') | |
->onDelete('no action') | |
->onUpdate('no action'); | |
$table->foreign('users_id', 'fk_news_users1_idx') | |
->references('id')->on('users') | |
->onDelete('no action') | |
->onUpdate('no action'); | |
}); | |
} | |
/** | |
* Reverse the migrations. | |
* | |
* @return void | |
*/ | |
public function down() | |
{ | |
Schema::dropIfExists($this->tableName); | |
} | |
} | |
Table name: group_privalege Migration File: 2019_05_04_000000_create_group_privalege_table.php | |
<?php | |
use Illuminate\Support\Facades\Schema; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Database\Migrations\Migration; | |
class CreateGroupPrivalegeTable extends Migration | |
{ | |
/** | |
* Schema table name to migrate | |
* @var string | |
*/ | |
public $tableName = 'group_privalege'; | |
/** | |
* Run the migrations. | |
* @table group_privalege | |
* | |
* @return void | |
*/ | |
public function up() | |
{ | |
Schema::create($this->tableName, function (Blueprint $table) { | |
$table->engine = 'InnoDB'; | |
$table->increments('id'); | |
$table->integer('read')->nullable(); | |
$table->integer('add')->nullable(); | |
$table->integer('edit')->nullable(); | |
$table->integer('delete')->nullable(); | |
$table->integer('print')->nullable(); | |
$table->integer('send')->nullable(); | |
$table->integer('tbl_groups_id'); | |
$table->timestamp('CREATE_DATE')->nullable(); | |
$table->string('CREATE_USER', 45)->nullable(); | |
$table->dateTime('UPDATE_DATE')->nullable(); | |
$table->string('UPDATE_USER', 45)->nullable(); | |
$table->index(["tbl_groups_id"], 'fk_tbl_group_privalege_tbl_groups1_idx'); | |
$table->foreign('tbl_groups_id', 'fk_tbl_group_privalege_tbl_groups1_idx') | |
->references('id')->on('groups') | |
->onDelete('no action') | |
->onUpdate('no action'); | |
}); | |
} | |
/** | |
* Reverse the migrations. | |
* | |
* @return void | |
*/ | |
public function down() | |
{ | |
Schema::dropIfExists($this->tableName); | |
} | |
} | |
Table name: tbl_group_user Migration File: 2019_05_04_000000_create_tbl_group_user_table.php | |
<?php | |
use Illuminate\Support\Facades\Schema; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Database\Migrations\Migration; | |
class CreateTblGroupUserTable extends Migration | |
{ | |
/** | |
* Schema table name to migrate | |
* @var string | |
*/ | |
public $tableName = 'tbl_group_user'; | |
/** | |
* Run the migrations. | |
* @table tbl_group_user | |
* | |
* @return void | |
*/ | |
public function up() | |
{ | |
Schema::create($this->tableName, function (Blueprint $table) { | |
$table->engine = 'InnoDB'; | |
$table->increments('id'); | |
$table->integer('tbl_users_id'); | |
$table->index(["tbl_users_id"], 'fk_tbl_group_user_tbl_users_idx'); | |
$table->foreign('tbl_users_id', 'fk_tbl_group_user_tbl_users_idx') | |
->references('id')->on('users') | |
->onDelete('no action') | |
->onUpdate('no action'); | |
}); | |
} | |
/** | |
* Reverse the migrations. | |
* | |
* @return void | |
*/ | |
public function down() | |
{ | |
Schema::dropIfExists($this->tableName); | |
} | |
} | |
Table name: group_user Migration File: 2019_05_04_000000_create_group_user_table.php | |
<?php | |
use Illuminate\Support\Facades\Schema; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Database\Migrations\Migration; | |
class CreateGroupUserTable extends Migration | |
{ | |
/** | |
* Schema table name to migrate | |
* @var string | |
*/ | |
public $tableName = 'group_user'; | |
/** | |
* Run the migrations. | |
* @table group_user | |
* | |
* @return void | |
*/ | |
public function up() | |
{ | |
Schema::create($this->tableName, function (Blueprint $table) { | |
$table->engine = 'InnoDB'; | |
$table->integer('tbl_users_id'); | |
$table->integer('tbl_groups_id'); | |
$table->timestamp('create_date')->nullable(); | |
$table->string('create_user', 45)->nullable(); | |
$table->dateTime('update_date')->nullable(); | |
$table->string('update_user', 45)->nullable(); | |
$table->index(["tbl_groups_id"], 'fk_tbl_group_user_tbl_groups1_idx'); | |
$table->index(["tbl_users_id"], 'fk_tbl_group_user_tbl_users1_idx'); | |
$table->foreign('tbl_users_id', 'fk_tbl_group_user_tbl_users1_idx') | |
->references('id')->on('users') | |
->onDelete('no action') | |
->onUpdate('no action'); | |
$table->foreign('tbl_groups_id', 'fk_tbl_group_user_tbl_groups1_idx') | |
->references('id')->on('groups') | |
->onDelete('no action') | |
->onUpdate('no action'); | |
}); | |
} | |
/** | |
* Reverse the migrations. | |
* | |
* @return void | |
*/ | |
public function down() | |
{ | |
Schema::dropIfExists($this->tableName); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment