---
title: "Database schema & key types — Permissions for Laravel | Roundly"
description: "The five tables, their fixed columns, and how key_type types model_id for bigint, UUID or ULID holder models."
url: https://roundly-consulting.com/open-source/docs/permissions-for-laravel/database-schema
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Permissions for Laravel](https://roundly-consulting.com/open-source/docs/permissions-for-laravel.md)

# Database schema & key types

Five tables back the package. Table names come from table\_names; column names are fixed:

| Table | Columns | Keys |
| --- | --- | --- |
| `permissions` | id, name (unique), description (jsonb, nullable), timestamps | Auto-incrementing id. |
| `roles` | id, name (unique), description (jsonb, nullable), timestamps | Auto-incrementing id. |
| `permission_role` | permission\_id, role\_id | Both foreign keys cascade on delete; primary key (permission\_id, role\_id). |
| `model_roles` | role\_id, model\_type, model\_id | role\_id cascades on delete; index (model\_id, model\_type); primary key (role\_id, model\_id, model\_type). |
| `model_permissions` | permission\_id, model\_type, model\_id | permission\_id cascades on delete; index (model\_id, model\_type); primary key (permission\_id, model\_id, model\_type). |

Holder links are polymorphic (model\_type + model\_id), so any Eloquent model can hold roles and permissions — not just users. Custom morph-map aliases are stored in the pivots as they are everywhere else in Laravel.

## Holder key type

key\_type describes the models that hold roles and permissions — never this package’s own tables, which always keep an auto-incrementing key. It types the model\_id column on the two polymorphic pivots:

| key\_type | model\_id column | Use when your holders… |
| --- | --- | --- |
| `bigint` | unsignedBigInteger | use Laravel’s default auto-incrementing keys (the default) |
| `uuid` | uuid | use HasUuids |
| `ulid` | ulid | use HasUlids |

Set it before you publish and run the migrations — the schema freezes at release:

```bash
PERMISSIONS_KEY_TYPE=uuid
```

```php
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Foundation\Auth\User as Authenticatable;
use RoundlyConsulting\Permissions\Concerns\HasRoles;

class User extends Authenticatable
{
    use HasRoles;
    use HasUuids; // pairs with PERMISSIONS_KEY_TYPE=uuid
}
```

Unset or blank reads as bigint; an unrecognized value throws the toolkit’s InvalidConfigurationException rather than silently building bigint keys.

## Hard deletes by design

Roles and permissions do not use soft deletes: the unique name index would clash with soft-deleted rows, and every pivot cascades on delete — removing a role or permission removes its grants with it.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/permissions-for-laravel.md)
