56 lines
1.9 KiB
PHP
Executable File
56 lines
1.9 KiB
PHP
Executable File
<?php
|
|
|
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
class AddAllowCommentsToContentTables
|
|
{
|
|
public function up()
|
|
{
|
|
if (Capsule::schema()->hasTable('blog_posts')) {
|
|
if (!Capsule::schema()->hasColumn('blog_posts', 'posts_allow_comments')) {
|
|
Capsule::schema()->table('blog_posts', function (Blueprint $table) {
|
|
$table->boolean('posts_allow_comments')->default(true);
|
|
});
|
|
}
|
|
}
|
|
|
|
if (Capsule::schema()->hasTable('news')) {
|
|
if (!Capsule::schema()->hasColumn('news', 'news_allow_comments')) {
|
|
Capsule::schema()->table('news', function (Blueprint $table) {
|
|
$table->boolean('news_allow_comments')->default(true);
|
|
});
|
|
}
|
|
}
|
|
|
|
if (Capsule::schema()->hasTable('photos_albums')) {
|
|
if (!Capsule::schema()->hasColumn('photos_albums', 'photos_albums_allow_comments')) {
|
|
Capsule::schema()->table('photos_albums', function (Blueprint $table) {
|
|
$table->boolean('photos_albums_allow_comments')->default(true);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
if (Capsule::schema()->hasTable('blog_posts')) {
|
|
Capsule::schema()->table('blog_posts', function (Blueprint $table) {
|
|
$table->dropColumn('posts_allow_comments');
|
|
});
|
|
}
|
|
|
|
if (Capsule::schema()->hasTable('news')) {
|
|
Capsule::schema()->table('news', function (Blueprint $table) {
|
|
$table->dropColumn('news_allow_comments');
|
|
});
|
|
}
|
|
|
|
if (Capsule::schema()->hasTable('photos_albums')) {
|
|
Capsule::schema()->table('photos_albums', function (Blueprint $table) {
|
|
$table->dropColumn('photos_albums_allow_comments');
|
|
});
|
|
}
|
|
}
|
|
}
|