-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathupdate_senhaunica_users_table.php.stub
40 lines (37 loc) · 1.19 KB
/
update_senhaunica_users_table.php.stub
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateSenhaunicaUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// Caso necessário, ajuste para refletir suas necessidades
Schema::table('users', function (Blueprint $table) {
$table->string('password')->nullable()->change(); # deixar opcional
if (!Schema::hasColumn('users', 'codpes')) {
// https://stackoverflow.com/questions/20822159/laravel-migration-with-sqlite-cannot-add-a-not-null-column-with-default-value-n
if ('sqlite' === Schema::connection($this->getConnection())->getConnection()->getDriverName()) {
$table->integer('codpes')->nullable();
} else {
$table->integer('codpes');
}
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
// Não vamos remover as colunas para preservar os dados
//$table->dropColumn('codpes');
}
}