Skip to content

Instantly share code, notes, and snippets.

@Rijen
Created November 19, 2015 14:23
Show Gist options
  • Save Rijen/3e561197d28fbf181093 to your computer and use it in GitHub Desktop.
Save Rijen/3e561197d28fbf181093 to your computer and use it in GitHub Desktop.
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateDownloadsStructure extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up() {
Schema::create('downloads_donors', function(Blueprint $table) {
$table->increments('id')->unsigned();
$table->string('name');
$table->char('lang', 3);
$table->string('baseurl');
$table->timestamps();
});
Schema::create('downloads_channels', function(Blueprint $table) {
$table->increments('id')->unsigned();
$table->integer('donor_id')->unsigned();
$table->string('name')->unique();
$table->string('url');
$table->timestamps();
$table->foreign('donor_id')->references('id')->on('downloads_donors');
});
Schema::create('downloads_serials', function(Blueprint $table) {
$table->increments('id')->unsigned();
$table->integer('channel_id')->unsigned();
$table->string('name')->unique();
$table->string('url');
$table->timestamps();
$table->foreign('channel_id')->references('id')->on('downloads_channels');
});
Schema::create('downloads_episodes', function(Blueprint $table) {
$table->increments('id')->unsigned();
$table->integer('serial_id')->unsigned();
$table->string('name', 40)->unique(); //sha1-identifier
$table->string('url');
$table->string('date');
$table->boolean('downloaded')->default(false);
$table->timestamps();
$table->foreign('serial_id')->references('id')->on('downloads_serials');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down() {
Schema::drop('downloads_episodes');
Schema::drop('downloads_serials');
Schema::drop('downloads_channels');
Schema::drop('downloads_donors');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment