2015-08-30 14:29:12 +02:00
|
|
|
<?php
|
|
|
|
|
2015-10-25 06:17:45 +01:00
|
|
|
/**
|
|
|
|
* Pony.fm - A community for pony fan music.
|
|
|
|
* Copyright (C) 2015 Peter Deltchev
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2015-08-30 14:29:12 +02:00
|
|
|
use Illuminate\Database\Migrations\Migration;
|
2015-12-25 03:08:49 +01:00
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
2015-08-30 14:29:12 +02:00
|
|
|
|
2015-08-31 14:35:47 +02:00
|
|
|
class CreateAlbums extends Migration
|
|
|
|
{
|
|
|
|
public function up()
|
|
|
|
{
|
2015-12-25 03:08:49 +01:00
|
|
|
Schema::create('albums', function (Blueprint $table) {
|
2015-08-31 14:35:47 +02:00
|
|
|
$table->increments('id');
|
|
|
|
$table->integer('user_id')->unsigned();
|
|
|
|
$table->string('title')->index();
|
|
|
|
$table->string('slug')->index();
|
|
|
|
$table->text('description');
|
|
|
|
$table->integer('cover_id')->unsigned()->nullable();
|
|
|
|
|
|
|
|
$table->integer('track_count')->unsigned();
|
|
|
|
$table->integer('view_count')->unsigned();
|
|
|
|
$table->integer('download_count')->unsigned();
|
|
|
|
$table->integer('favourite_count')->unsigned();
|
|
|
|
$table->integer('comment_count')->unsigned();
|
|
|
|
|
|
|
|
$table->timestamps();
|
|
|
|
$table->timestamp('deleted_at')->nullable()->index();
|
|
|
|
|
|
|
|
$table->foreign('cover_id')->references('id')->on('images');
|
|
|
|
$table->foreign('user_id')->references('id')->on('users');
|
|
|
|
});
|
|
|
|
|
|
|
|
Schema::table('tracks', function ($table) {
|
|
|
|
$table->integer('album_id')->unsigned()->nullable();
|
|
|
|
$table->integer('track_number')->unsigned()->nullable();
|
|
|
|
|
|
|
|
$table->foreign('album_id')->references('id')->on('albums');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function down()
|
|
|
|
{
|
2015-12-25 03:08:49 +01:00
|
|
|
// These are separated to prevent weirdness with SQLite.
|
|
|
|
Schema::table('tracks', function (Blueprint $table) {
|
2015-08-31 14:35:47 +02:00
|
|
|
$table->dropForeign('tracks_album_id_foreign');
|
2015-12-25 03:08:49 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
Schema::table('tracks', function (Blueprint $table) {
|
2015-08-31 14:35:47 +02:00
|
|
|
$table->dropColumn('album_id');
|
2015-12-25 03:08:49 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
Schema::table('tracks', function (Blueprint $table) {
|
2015-08-31 14:35:47 +02:00
|
|
|
$table->dropColumn('track_number');
|
|
|
|
});
|
|
|
|
|
|
|
|
Schema::drop('albums');
|
|
|
|
}
|
2015-10-25 06:17:45 +01:00
|
|
|
}
|