Coverted script import to laravel
This commit is contained in:
48
database/migrations/2016_06_03_055603_create_photo_table.php
Normal file
48
database/migrations/2016_06_03_055603_create_photo_table.php
Normal 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');
|
||||
}
|
||||
|
||||
}
|
@@ -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');
|
||||
}
|
||||
|
||||
}
|
@@ -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');
|
||||
}
|
||||
|
||||
}
|
@@ -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');
|
||||
}
|
||||
|
||||
}
|
34
database/migrations/2016_06_03_055604_create_tags_table.php
Normal file
34
database/migrations/2016_06_03_055604_create_tags_table.php
Normal 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');
|
||||
}
|
||||
|
||||
}
|
@@ -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');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@@ -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');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user