Skip to content

Commit

Permalink
Fixed : #175 Error on install: Syntax error or access violation: 1071…
Browse files Browse the repository at this point in the history
… Specified key was too long;
  • Loading branch information
cuneytsenturk committed Jan 13, 2018
1 parent b22885b commit 0d495fe
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
use App\Events\UpdateFinished;
use App\Models\Auth\Role;
use App\Models\Auth\Permission;
use Illuminate\Support\Facades\Schema;
use MediaUploader;
use Storage;
use Artisan;

class Version117 extends Listener
class Version118 extends Listener
{
const ALIAS = 'core';

const VERSION = '1.1.7';
const VERSION = '1.1.8';

/**
* Handle the event.
Expand All @@ -28,24 +29,34 @@ public function handle(UpdateFinished $event)
return;
}

if (Schema::hasTable('mediables')) {
return;
}

if (Schema::hasTable('media')) {
Schema::drop('media');
}

// Create permission
$permission = Permission::firstOrCreate([
'name' => 'delete-common-uploads',
'display_name' => 'Delete Common Uploads',
'description' => 'Delete Common Uploads',
]);
if (!Permission::where('name', 'delete-common-uploads')->first()->value('id')) {
$permission = Permission::firstOrCreate([
'name' => 'delete-common-uploads',
'display_name' => 'Delete Common Uploads',
'description' => 'Delete Common Uploads',
]);

// Attach permission to roles
$roles = Role::all();
// Attach permission to roles
$roles = Role::all();

foreach ($roles as $role) {
$allowed = ['admin'];

if (!in_array($role->name, $allowed)) {
continue;
}
foreach ($roles as $role) {
if (!in_array($role->name, $allowed)) {
continue;
}

$role->attachPermission($permission);
$role->attachPermission($permission);
}
}

$data = [];
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class EventServiceProvider extends ServiceProvider
'App\Listeners\Updates\Version110',
'App\Listeners\Updates\Version112',
'App\Listeners\Updates\Version113',
'App\Listeners\Updates\Version117',
'App\Listeners\Updates\Version118',
],
'Illuminate\Auth\Events\Login' => [
'App\Listeners\Auth\Login',
Expand Down
10 changes: 5 additions & 5 deletions database/migrations/2017_12_30_000000_create_mediable_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public function up()
Schema::create('media', function (Blueprint $table) {
$table->increments('id');
$table->string('disk', 32);
$table->string('directory');
$table->string('filename');
$table->string('extension', 32);
$table->string('directory', 68);
$table->string('filename', 121);
$table->string('extension', 28);
$table->string('mime_type', 128);
$table->string('aggregate_type', 32);
$table->integer('size')->unsigned();
Expand All @@ -32,9 +32,9 @@ public function up()

Schema::create('mediables', function (Blueprint $table) {
$table->integer('media_id')->unsigned();
$table->string('mediable_type');
$table->string('mediable_type', 152);
$table->integer('mediable_id')->unsigned();
$table->string('tag');
$table->string('tag', 68);
$table->integer('order')->unsigned();

$table->primary(['media_id', 'mediable_type', 'mediable_id', 'tag']);
Expand Down

0 comments on commit 0d495fe

Please sign in to comment.