/**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Role::create(['name' => 'p_edit_disable_delete', 'description' => 'Edit whether a page can be deleted']);
     Schema::table('pages', function ($table) {
         $table->boolean('disable_delete')->default(false);
     });
     DB::table('pages')->whereNull('parent_id')->update(['disable_delete' => true]);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('page_acl', function (Blueprint $table) {
         $table->integer('page_id')->unsigned()->references('id')->on('pages')->onUpdate('CASCADE')->onDelete('CASCADE');
         $table->integer('group_id')->unsigned()->references('id')->on('groups')->onUpdate('CASCADE')->onDelete('CASCADE');
         $table->primary(['page_id', 'group_id']);
     });
     Schema::table('pages', function (Blueprint $table) {
         $table->boolean(Page::ATTR_ENABLE_ACL)->default(false);
     });
     Role::create(['name' => 'editAcl', 'tree' => true]);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('sites', function (Blueprint $table) {
         $table->increments(Site::ATTR_ID);
         $table->string(Site::ATTR_NAME, 100);
         $table->string(Site::ATTR_HOSTNAME)->unique();
         $table->string(Site::ATTR_ADMIN_EMAIL, 250);
         $table->text(Site::ATTR_ANALYTICS)->nullable();
         $table->boolean(Site::ATTR_DEFAULT)->default(false);
         $table->string(Site::ATTR_SCHEME, 10);
         $table->softDeletes();
     });
     Schema::table('pages', function (Blueprint $table) {
         $table->integer(Page::ATTR_SITE)->unsigned()->references(Site::ATTR_ID)->on('sites')->onUpdate('CASCADE')->onDelete('CASCADE');
     });
     Schema::table('page_urls', function (Blueprint $table) {
         $table->integer(URL::ATTR_SITE)->unsigned()->references(Site::ATTR_ID)->on('sites')->onUpdate('CASCADE')->onDelete('CASCADE');
     });
     Schema::table('groups', function (Blueprint $table) {
         $table->integer(Group::ATTR_SITE)->unsigned()->references(Site::ATTR_ID)->on('sites')->onUpdate('CASCADE')->onDelete('CASCADE');
     });
     Schema::create('asset_site', function (Blueprint $table) {
         $table->integer('asset_id')->unsigned()->references(Asset::ATTR_ID)->on('assets')->onUpdate('CASCADE')->onDelete('CASCADE');
         $table->integer('site_id')->unsigned()->references(Site::ATTR_ID)->on('sites')->onUpdate('CASCADE')->onDelete('CASCADE');
         $table->unique(['asset_id', 'site_id']);
     });
     Schema::create('person_site', function (Blueprint $table) {
         $table->integer('person_id')->unsigned()->references(Person::ATTR_ID)->on('people')->onUpdate('CASCADE')->onDelete('CASCADE');
         $table->integer('site_id')->unsigned()->references(Site::ATTR_ID)->on('sites')->onUpdate('CASCADE')->onDelete('CASCADE');
         $table->unique(['person_id', 'site_id']);
     });
     Schema::table('tags', function (Blueprint $table) {
         $table->integer(Tag::ATTR_SITE)->unsigned()->references(Site::ATTR_ID)->on('sites')->onUpdate('CASCADE')->onDelete('CASCADE');
     });
     $filename = storage_path() . '/boomcms/settings.json';
     if (file_exists($filename)) {
         $settings = (array) json_decode(file_get_contents($filename));
         $site = Site::create([Site::ATTR_DEFAULT => true, Site::ATTR_NAME => $settings['site.name'], Site::ATTR_ADMIN_EMAIL => $settings['site.admin.email'], Site::ATTR_HOSTNAME => '']);
         foreach (['pages', 'page_urls', 'groups', 'tags'] as $table) {
             DB::table($table)->update(['site_id' => $site->getId()]);
         }
         DB::statement("insert into asset_site (asset_id, site_id) select id, '{$site->getId()}' from assets");
         DB::statement("insert into person_site (person_id, site_id) select id, '{$site->getId()}' from people");
     }
     Role::create(['name' => 'manageSites', 'description' => 'Manage sites']);
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Role::create(['name' => 'editDeletable', 'description' => 'Edit whether a page can be deleted']);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Role::create(['name' => 'manage_settings', 'description' => 'View the site settings editor']);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $upload = Role::create(['name' => 'uploadAssets']);
     $manage = Role::where('name', 'manageAssets')->first();
     DB::statement('insert into group_role (role_id, group_id, allowed) select "' . $upload->getId() . '", group_id, allowed from group_role where role_id = ' . $manage->getId());
 }