/**
  * Run the migrations.
  */
 public function up()
 {
     Schema::create('character_set_structure', function (Blueprint $table) {
         $table->increments('id');
         $table->unsignedInteger('character_set_id')->index();
         $table->unsignedInteger('version_number_id')->index();
         $table->string('description');
         $table->string('mysql_character_set');
         // Composite keys
         $table->unique(['character_set_id', 'version_number_id'], uniqid());
         // Foreign keys
         $table->foreign('character_set_id')->references('id')->on('character_set');
         $table->foreign('version_number_id')->references('id')->on('version_number');
     });
     DB::transaction(function () {
         CharacterSetStructure::unguard();
         foreach ($this->data as $datum) {
             $character_set = CharacterSet::where(['value' => $datum['character_set']])->firstOrFail();
             $version_number = VersionNumber::where(['value' => $datum['version_number']])->firstOrFail();
             $character_set_structure = new CharacterSetStructure();
             $character_set_structure->description = $datum['description'];
             $character_set_structure->mysql_character_set = $datum['mysql_character_set'];
             $character_set_structure->characterSet()->associate($character_set);
             $character_set_structure->versionNumber()->associate($version_number);
             $character_set_structure->save();
         }
         CharacterSetStructure::reguard();
     });
 }
 /**
  * Run the migrations.
  */
 public function up()
 {
     Schema::create('gedcom_form_structure', function (Blueprint $table) {
         $table->increments('id');
         $table->unsignedInteger('gedcom_form_id')->index();
         $table->unsignedInteger('version_number_id')->index();
         // Composite keys
         $table->unique(['gedcom_form_id', 'version_number_id']);
         // Foreign keys
         $table->foreign('gedcom_form_id')->references('id')->on('gedcom_form');
         $table->foreign('version_number_id')->references('id')->on('version_number');
     });
     DB::transaction(function () {
         GedcomFormStructure::unguard();
         foreach ($this->data as $datum) {
             $gedcom_form = GedcomForm::where(['value' => $datum['gedcom_form']])->firstOrFail();
             $version_number = VersionNumber::where(['value' => $datum['version_number']])->firstOrFail();
             $gedcom_form_structure = new GedcomFormStructure();
             $gedcom_form_structure->gedcomForm()->associate($gedcom_form);
             $gedcom_form_structure->versionNumber()->associate($version_number);
             $gedcom_form_structure->save();
         }
         GedcomFormStructure::reguard();
     });
 }
 /**
  * Run the migrations.
  */
 public function up()
 {
     Schema::create('version_number', function (Blueprint $table) {
         $table->increments('id');
         // We are obliged to store over-long character set versions so that we can
         // correctly import files that use WINDOWS-1250 and WINDOWS-1252.  <sigh>
         $table->string('value', GedcomSpecification::LENGTH_CHARACTER_SET + 4);
         $table->boolean('standard')->default(false);
     });
     DB::transaction(function () {
         VersionNumber::unguard();
         foreach ($this->data as $datum) {
             VersionNumber::create($datum);
         }
         VersionNumber::reguard();
     });
 }