50 lines
1.4 KiB
PHP
Executable File
50 lines
1.4 KiB
PHP
Executable File
<?php
|
|
|
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
|
|
|
/**
|
|
* Migration 006: Add attachments to notes table.
|
|
*
|
|
* This migration adds columns for images and files to the notes table.
|
|
*/
|
|
class AddAttachmentsToNotes
|
|
{
|
|
/**
|
|
* Run the migration.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function up()
|
|
{
|
|
if (Capsule::schema()->hasTable('notes')) {
|
|
Capsule::schema()->table('notes', function ($table) {
|
|
if (!Capsule::schema()->hasColumn('notes', 'notes_image')) {
|
|
$table->string('notes_image')->nullable()->after('notes_color');
|
|
}
|
|
if (!Capsule::schema()->hasColumn('notes', 'notes_file')) {
|
|
$table->string('notes_file')->nullable()->after('notes_image');
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Reverse the migration.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function down()
|
|
{
|
|
if (Capsule::schema()->hasTable('notes')) {
|
|
Capsule::schema()->table('notes', function ($table) {
|
|
if (Capsule::schema()->hasColumn('notes', 'notes_image')) {
|
|
$table->dropColumn('notes_image');
|
|
}
|
|
if (Capsule::schema()->hasColumn('notes', 'notes_file')) {
|
|
$table->dropColumn('notes_file');
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|