Coverted script import to laravel

This commit is contained in:
Deon George
2016-06-22 15:49:20 +10:00
parent a2357435e1
commit b1d7cfe616
36 changed files with 1619 additions and 299 deletions

View File

@@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreatePhotoTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('photo', function(Blueprint $table)
{
$table->bigInteger('id', true);
$table->timestamps();
$table->integer('date_taken')->nullable();
$table->smallInteger('subsectime')->nullable();
$table->string('filename', 128);
$table->string('signature', 64)->nullable();
$table->string('make', 32)->nullable();
$table->string('model', 32)->nullable();
$table->integer('height')->nullable();
$table->integer('width')->nullable();
$table->integer('orientation')->nullable();
$table->float('gps_lat', 10, 0)->nullable();
$table->float('gps_lon', 10, 0)->nullable();
$table->binary('thumbnail', 65535)->nullable();
$table->boolean('duplicate')->nullable();
$table->boolean('remove')->nullable();
$table->boolean('flag')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('photo');
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreatePeopleTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('people', function(Blueprint $table)
{
$table->integer('id', true);
$table->string('tag', 16)->unique('tag_UNIQUE');
$table->string('name', 64)->nullable();
$table->integer('date_birth')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('people');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreatePhotoPeopleTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('photo_people', function(Blueprint $table)
{
$table->bigInteger('id', true);
$table->timestamps();
$table->integer('people_id');
$table->bigInteger('photo_id')->index('fk_pp_ph_idx');
$table->unique(['people_id','photo_id'], 'UNIQUE');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('photo_people');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreatePhotoTagTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('photo_tag', function(Blueprint $table)
{
$table->bigInteger('id', true);
$table->timestamps();
$table->bigInteger('photo_id');
$table->bigInteger('tag_id')->index('pt_t_idx');
$table->unique(['photo_id','tag_id'], 'UNIQUE');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('photo_tag');
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateTagsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tags', function(Blueprint $table)
{
$table->bigInteger('id', true);
$table->string('tag', 16)->unique('tag_UNIQUE');
$table->string('description', 45)->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('tags');
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddForeignKeysToPhotoPeopleTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('photo_people', function(Blueprint $table)
{
$table->foreign('people_id', 'fk_pp_p')->references('id')->on('people')->onUpdate('NO ACTION')->onDelete('NO ACTION');
$table->foreign('photo_id', 'fk_pp_ph')->references('id')->on('photo')->onUpdate('NO ACTION')->onDelete('NO ACTION');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('photo_people', function(Blueprint $table)
{
$table->dropForeign('fk_pp_p');
$table->dropForeign('fk_pp_ph');
});
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddForeignKeysToPhotoTagTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('photo_tag', function(Blueprint $table)
{
$table->foreign('photo_id', 'fk_pt_p')->references('id')->on('photo')->onUpdate('NO ACTION')->onDelete('NO ACTION');
$table->foreign('tag_id', 'fk_pt_t')->references('id')->on('tags')->onUpdate('NO ACTION')->onDelete('NO ACTION');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('photo_tag', function(Blueprint $table)
{
$table->dropForeign('fk_pt_p');
$table->dropForeign('fk_pt_t');
});
}
}