Changeset View
Changeset View
Standalone View
Standalone View
src/database/migrations/2021_11_16_100000_create_resources_tables.php
Show All 39 Lines | public function up() | ||||
$table->timestamps(); | $table->timestamps(); | ||||
$table->foreign('resource_id')->references('id')->on('resources') | $table->foreign('resource_id')->references('id')->on('resources') | ||||
->onDelete('cascade')->onUpdate('cascade'); | ->onDelete('cascade')->onUpdate('cascade'); | ||||
$table->unique(['resource_id', 'key']); | $table->unique(['resource_id', 'key']); | ||||
} | } | ||||
); | ); | ||||
\App\Sku::where('title', 'resource')->update([ | |||||
'active' => true, | |||||
'cost' => 0, | |||||
]); | |||||
if (!\App\Sku::where('title', 'beta-resources')->first()) { | |||||
\App\Sku::create([ | |||||
'title' => 'beta-resources', | |||||
'name' => 'Calendaring resources', | |||||
'description' => 'Access to calendaring resources', | |||||
'cost' => 0, | |||||
'units_free' => 0, | |||||
'period' => 'monthly', | |||||
'handler_class' => 'App\Handlers\Beta\Resources', | |||||
'active' => true, | |||||
]); | |||||
} | |||||
} | } | ||||
/** | /** | ||||
* Reverse the migrations. | * Reverse the migrations. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function down() | public function down() | ||||
{ | { | ||||
Schema::dropIfExists('resource_settings'); | Schema::dropIfExists('resource_settings'); | ||||
Schema::dropIfExists('resources'); | Schema::dropIfExists('resources'); | ||||
// there's no need to remove the SKU | // there's no need to remove the SKU | ||||
} | } | ||||
} | } |