Skip to content

Commit

Permalink
Add migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
magnobiet committed Feb 6, 2016
1 parent bc0fc39 commit 4f4e27c
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
41 changes: 41 additions & 0 deletions database/migrations/2016_02_05_000000_create_cities_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateCitiesTable extends Migration
{

/**
* Run the migrations.
*
* @return void
*/
public function up()
{

Schema::create('cities', function (Blueprint $table) {

$table->increments('id');
$table->integer('state_id')->unsigned();
$table->foreign('state_id')->references('id')->on('states');
$table->string('name', 64);
$table->timestamps();

});

}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{

Schema::drop('cities');

}

}
40 changes: 40 additions & 0 deletions database/migrations/2016_02_05_000000_create_states_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateStatesTable extends Migration
{

/**
* Run the migrations.
*
* @return void
*/
public function up()
{

Schema::create('states', function (Blueprint $table) {

$table->increments('id');
$table->string('name', 64)->unique();
$table->string('abbr', 2)->unique();
$table->timestamps();

});

}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{

Schema::drop('states');

}

}

0 comments on commit 4f4e27c

Please sign in to comment.