/**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     $features = PropertyFeatures::getFeatureCodes();
     // drop the pivot tables
     foreach ($features as $feature) {
         $pivotName = $feature < 'property' ? $feature . '_property' : 'property_' . $feature;
         if (Schema::hasTable($pivotName)) {
             Schema::drop($pivotName);
         }
     }
     // drop the features tables
     foreach ($features as $feature) {
         $featureTable = $feature . 's';
         if (Schema::hasTable($featureTable)) {
             Schema::drop($featureTable);
         }
     }
 }
Exemple #2
0
 public function resetTables()
 {
     // reset the tables
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     // disable foreign key constraints
     foreach (PropertyFeatures::getFeatureCodes() as $feature) {
         $featureTable = $feature . 's';
         $pivotTable = $feature < 'property' ? $feature . '_property' : 'property_' . $feature;
         // truncate the pivot table
         DB::table($pivotTable)->truncate();
         // truncate the feature table
         DB::table($featureTable)->truncate();
     }
     DB::table('properties')->truncate();
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     // enable foreign key constraints
 }