Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update bigint_user_keys migration to include the db_prefix. #264

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/migrations/2015_02_07_172633_create_role_user_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public function up()
$table->increments('id');

$table->integer('role_id')->unsigned()->index()->foreign()->references("id")->on("roles")->onDelete("cascade");
$table->bigInteger('user_id')
$table->bigInteger($this->prefix . 'user_id')
->unsigned()
->index()
->foreign()
->references("id")
->on(Config::usersTableName())
->on($this->prefix . Config::usersTableName())
->onDelete("cascade");

$table->timestamps();
Expand All @@ -42,7 +42,7 @@ public function up()
->on($this->prefix . 'roles')
->onDelete('cascade');

$table->foreign('user_id')
$table->foreign($this->prefix . 'user_id')
->references('id')
->on($this->prefix . Config::usersTableName())
->onDelete('cascade');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public function up()
Schema::create($this->prefix . 'permission_user', function (Blueprint $table) {
$table->increments('id');
$table->integer('permission_id')->unsigned()->index()->references('id')->on('permissions')->onDelete('cascade');
$table->bigInteger('user_id')
$table->bigInteger($this->prefix . 'user_id')
->unsigned()
->index()
->references('id')
->on(Config::usersTableName())
->on($this->prefix . Config::usersTableName())
->onDelete('cascade');
$table->timestamps();
});
Expand Down
15 changes: 13 additions & 2 deletions src/migrations/2015_11_30_232041_bigint_user_keys.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,28 @@

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Kodeine\Acl\Helper\Config;

class BigintUserKeys extends Migration
{
/**
* @var string
*/
public $prefix;

public function __construct()
{
$this->prefix = config('acl.db_prefix');
}

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('role_user', function (Blueprint $table) {
Schema::table($this->prefix . 'role_user', function (Blueprint $table) {
$table->bigInteger("user_id")->unsigned()->change();
});
}
Expand All @@ -24,7 +35,7 @@ public function up()
*/
public function down()
{
Schema::table('role_user', function (Blueprint $table) {
Schema::table($this->prefix . 'role_user', function (Blueprint $table) {
$table->integer("user_id")->unsigned()->change();
});
}
Expand Down