Created frames table with migration
This commit is contained in:
79
database/migrations/2018_12_03_104758_init_database.php
Normal file
79
database/migrations/2018_12_03_104758_init_database.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class InitDatabase extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$this->down();
|
||||
|
||||
Schema::create('modes', function (Blueprint $table) {
|
||||
$table->timestamps();
|
||||
$table->integer('id')->autoIncrement();
|
||||
$table->string('name',16);
|
||||
$table->string('note',255);
|
||||
|
||||
$table->unique(['name']);
|
||||
});
|
||||
|
||||
Schema::create('cugs', function (Blueprint $table) {
|
||||
$table->timestamps();
|
||||
$table->integer('id');
|
||||
$table->string('name',16);
|
||||
$table->string('note',255);
|
||||
$table->integer('parent_id')->nullable();
|
||||
|
||||
$table->primary('id');
|
||||
$table->foreign('parent_id')->references('id')->on('cugs');
|
||||
$table->unique(['name']);
|
||||
});
|
||||
|
||||
Schema::create('frames', function (Blueprint $table) {
|
||||
$table->timestamps();
|
||||
$table->integer('id')->autoIncrement();
|
||||
$table->integer('frame');
|
||||
$table->char('index',1);
|
||||
$table->integer('mode_id');
|
||||
$table->char('type',2);
|
||||
$table->smallInteger('cost')->default(0);
|
||||
$table->integer('cug_id')->default(0);
|
||||
$table->boolean('public')->default(FALSE);
|
||||
$table->binary('content');
|
||||
$table->string('note',255)->nullable();
|
||||
|
||||
//$table->unique(['frame','index','mode_id']); // Not needed since we have timewarp
|
||||
|
||||
$table->foreign('mode_id')->references('id')->on('modes');
|
||||
$table->foreign('cug_id')->references('id')->on('cugs');
|
||||
});
|
||||
|
||||
Schema::create('routes', function (Blueprint $table) {
|
||||
$table->integer('id')->autoIncrement();
|
||||
$table->char('key',1);
|
||||
$table->integer('route');
|
||||
|
||||
$table->foreign('route')->references('id')->on('frames');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('routes');
|
||||
Schema::dropIfExists('frames');
|
||||
Schema::dropIfExists('cugs');
|
||||
Schema::dropIfExists('modes');
|
||||
}
|
||||
}
|
@@ -11,6 +11,7 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// $this->call(UsersTableSeeder::class);
|
||||
$this->call(SeedMode::class);
|
||||
$this->call(SeedCUG::class);
|
||||
}
|
||||
}
|
||||
}
|
21
database/seeds/SeedCUG.php
Normal file
21
database/seeds/SeedCUG.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class SeedCUG extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('cugs')->insert([
|
||||
'created_at' => now(),
|
||||
'id' => 0,
|
||||
'name' => 'Public Frames',
|
||||
'note' => 'All frames belong to this CUG if not any other.',
|
||||
]);
|
||||
}
|
||||
}
|
20
database/seeds/SeedMode.php
Normal file
20
database/seeds/SeedMode.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class SeedMode extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('modes')->insert([
|
||||
'created_at' => now(),
|
||||
'name' => 'ViewData',
|
||||
'note' => 'Original ViewData/VideoTex 40x25 char mode.',
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user