Skip to content

Commit

Permalink
Added creation of 'admin' & 'user' roles if they do not exist to the …
Browse files Browse the repository at this point in the history
…migration for protected roles.
  • Loading branch information
Zack Halloran committed Jun 28, 2016
1 parent 5a93b7f commit cc18896
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions migrations/20160623184725_set_protected_roles.php
Expand Up @@ -10,6 +10,22 @@ class SetProtectedRoles extends AbstractMigration
*/
public function up()
{
$admin = $this->fetchRow("SELECT COUNT(*) FROM roles WHERE name = 'admin'", 0);
if (! $admin[0]) {
$this->execute("INSERT INTO roles (name, display_name, description)
VALUES
( 'admin', 'Admin', 'Administrator' )
");
}

$user = $this->fetchRow("SELECT COUNT(*) FROM roles WHERE name = 'user'", 0);
if (! $user[0]) {
$this->execute("INSERT INTO roles (name, display_name, description)
VALUES
( 'user', 'User', 'Registered member' )
");
}

$this->execute("UPDATE roles
SET protected = 1
WHERE
Expand Down

0 comments on commit cc18896

Please sign in to comment.