Fix broken users table in database causing validation errors.
This commit is contained in:
parent
8daf97021a
commit
4cfb8941d5
4 changed files with 72 additions and 0 deletions
|
@ -6,6 +6,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
|
|||
## v0.7.3 (Derelict Dermodactylus)
|
||||
### Fixed
|
||||
* Fixes server creation API endpoint not passing the provided `external_id` to the creation service.
|
||||
* Fixes a bug causing users to be un-editable on new installations once more than one user exists.
|
||||
|
||||
### Added
|
||||
* Adds ability to modify the external ID for a server through the API.
|
||||
|
|
|
@ -121,6 +121,7 @@ class User extends Model implements
|
|||
* @var array
|
||||
*/
|
||||
protected $attributes = [
|
||||
'external_id' => null,
|
||||
'root_admin' => false,
|
||||
'language' => 'en',
|
||||
'use_totp' => false,
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class RemoveDefaultNullValueOnTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('external_id')->default(null)->change();
|
||||
});
|
||||
|
||||
DB::transaction(function () {
|
||||
DB::table('users')->where('external_id', '=' , 'NULL')->update([
|
||||
'external_id' => null,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
// This should not be rolled back.
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class DefineUniqueIndexOnUsersExternalId extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->index(['external_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropIndex(['external_id']);
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue