Skip to content

Commit 562fde4

Browse files
committed
Allow Laravel to generate timestamps on migration
1 parent 7c1e341 commit 562fde4

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
<?php
22

3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
35
use Illuminate\Support\Facades\DB;
46
use Illuminate\Support\Facades\Schema;
5-
use Illuminate\Database\Schema\Blueprint;
6-
use Illuminate\Database\Migrations\Migration;
77

8-
class AddLdapColumnsToUsersTable extends Migration
8+
return new class extends Migration
99
{
1010
/**
1111
* Run the migrations.
12-
*
13-
* @return void
1412
*/
15-
public function up()
13+
public function up(): void
1614
{
1715
$driver = Schema::getConnection()->getDriverName();
1816

@@ -34,10 +32,8 @@ public function up()
3432

3533
/**
3634
* Reverse the migrations.
37-
*
38-
* @return void
3935
*/
40-
public function down()
36+
public function down(): void
4137
{
4238
Schema::table('users', function (Blueprint $table) {
4339
$table->dropColumn(['guid', 'domain']);
@@ -46,13 +42,8 @@ public function down()
4642

4743
/**
4844
* Compile a compatible "unique" SQL Server index constraint.
49-
*
50-
* @param string $table
51-
* @param string $column
52-
*
53-
* @return string
5445
*/
55-
protected function compileUniqueSqlServerIndexStatement($table, $column)
46+
protected function compileUniqueSqlServerIndexStatement(string $table, string $column): string
5647
{
5748
return sprintf('create unique index %s on %s (%s) where %s is not null',
5849
implode('_', [$table, $column, 'unique']),
@@ -61,4 +52,4 @@ protected function compileUniqueSqlServerIndexStatement($table, $column)
6152
$column
6253
);
6354
}
64-
}
55+
};

src/LdapAuthServiceProvider.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,9 @@ protected function registerMigrations(): void
4343
return;
4444
}
4545

46-
if (! class_exists('AddLdapColumnsToUsersTable')) {
47-
$this->publishes([
48-
__DIR__.'/../database/migrations/add_ldap_columns_to_users_table.php.stub' => database_path('migrations/'.date('Y_m_d_His', time()).'_add_ldap_columns_to_users_table.php'),
49-
], 'migrations');
50-
}
46+
$this->publishesMigrations([
47+
__DIR__.'/../database/migrations' => database_path('migrations'),
48+
]);
5149
}
5250

5351
/**

0 commit comments

Comments
 (0)