fix
This commit is contained in:
@@ -8,12 +8,20 @@ return new class extends Migration
|
||||
{
|
||||
public function getConnection(): ?string
|
||||
{
|
||||
return app()->environment('testing') ? config('database.default') : 'vmangos_auth';
|
||||
return app()->environment('testing') ? config('database.default') : config('moonwell.auth_connection');
|
||||
}
|
||||
|
||||
public function up(): void
|
||||
{
|
||||
Schema::connection($this->getConnection())->create('site_credentials', function (Blueprint $table): void {
|
||||
$schema = Schema::connection($this->getConnection());
|
||||
|
||||
// Restoring the web database can lose migration history while realmd
|
||||
// still contains credentials from an earlier deployment.
|
||||
if ($schema->hasTable('site_credentials')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$schema->create('site_credentials', function (Blueprint $table): void {
|
||||
$table->unsignedInteger('account_id')->primary();
|
||||
$table->unsignedInteger('legacy_account_id')->nullable()->unique();
|
||||
$table->char('salt_hex', 64);
|
||||
@@ -27,6 +35,6 @@ return new class extends Migration
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::connection($this->getConnection())->dropIfExists('site_credentials');
|
||||
// The table can predate this migration. Preserve shared credentials.
|
||||
}
|
||||
};
|
||||
|
||||
+11
-7
@@ -13,9 +13,16 @@ return new class extends Migration
|
||||
|
||||
public function up(): void
|
||||
{
|
||||
Schema::connection($this->getConnection())->table('site_credentials', function (Blueprint $table): void {
|
||||
// web.users lives in another database, so no cross-database foreign key.
|
||||
$table->unsignedBigInteger('web_user_id')->nullable()->unique();
|
||||
$schema = Schema::connection($this->getConnection());
|
||||
|
||||
if (! $schema->hasColumn('site_credentials', 'web_user_id')) {
|
||||
$schema->table('site_credentials', function (Blueprint $table): void {
|
||||
// web.users lives in another database, so no cross-database foreign key.
|
||||
$table->unsignedBigInteger('web_user_id')->nullable()->unique();
|
||||
});
|
||||
}
|
||||
|
||||
$schema->table('site_credentials', function (Blueprint $table): void {
|
||||
$table->char('salt_hex', 64)->nullable()->change();
|
||||
$table->char('verifier_hex', 64)->nullable()->change();
|
||||
});
|
||||
@@ -23,9 +30,6 @@ return new class extends Migration
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::connection($this->getConnection())->table('site_credentials', function (Blueprint $table): void {
|
||||
$table->dropUnique(['web_user_id']);
|
||||
$table->dropColumn('web_user_id');
|
||||
});
|
||||
// The column can predate this migration. Preserve existing web mappings.
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user