summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2019-11-10 23:26:23 +0100
committerIgor Scheller <igor.scheller@igorshp.de>2019-11-11 00:05:41 +0100
commit68afc74b03f83bb072944911c15af60433280ace (patch)
tree1217a5cbfa75c01d35e8e0d743da379725816bf2 /db
parentb878740f80ce7cfe2a0bc53956e3f7e4e0aa2f78 (diff)
Formatting to follow PSR-12
Diffstat (limited to 'db')
-rw-r--r--db/migrations/2018_01_01_000001_import_install_sql.php3
-rw-r--r--db/migrations/2018_01_01_000003_fix_old_tables.php3
-rw-r--r--db/migrations/2018_10_01_000000_create_users_tables.php25
-rw-r--r--db/migrations/ChangesReferences.php6
4 files changed, 23 insertions, 14 deletions
diff --git a/db/migrations/2018_01_01_000001_import_install_sql.php b/db/migrations/2018_01_01_000001_import_install_sql.php
index eae8c810..7f1619e3 100644
--- a/db/migrations/2018_01_01_000001_import_install_sql.php
+++ b/db/migrations/2018_01_01_000001_import_install_sql.php
@@ -47,8 +47,7 @@ class ImportInstallSql extends Migration
/**
* Reverse the migration
*/
- public
- function down()
+ public function down()
{
$this->schema->getConnection()->statement('SET FOREIGN_KEY_CHECKS=0;');
diff --git a/db/migrations/2018_01_01_000003_fix_old_tables.php b/db/migrations/2018_01_01_000003_fix_old_tables.php
index 0ae9a1a5..822846db 100644
--- a/db/migrations/2018_01_01_000003_fix_old_tables.php
+++ b/db/migrations/2018_01_01_000003_fix_old_tables.php
@@ -18,7 +18,8 @@ class FixOldTables extends Migration
[
'User' => 'CreateDate',
'NewsComments' => 'Datum',
- ] as $table => $column) {
+ ] as $table => $column
+ ) {
if (!$this->schema->hasTable($table)) {
continue;
}
diff --git a/db/migrations/2018_10_01_000000_create_users_tables.php b/db/migrations/2018_10_01_000000_create_users_tables.php
index 52b3658f..40721286 100644
--- a/db/migrations/2018_10_01_000000_create_users_tables.php
+++ b/db/migrations/2018_10_01_000000_create_users_tables.php
@@ -83,8 +83,10 @@ class CreateUsersTables extends Migration
});
if ($this->schema->hasTable('User')) {
+ $emptyDates = ['0000-00-00 00:00:00', '0001-01-01 00:00:00', '1000-01-01 00:00:00'];
/** @var stdClass[] $users */
$users = $this->schema->getConnection()->table('User')->get();
+
foreach ($users as $data) {
$user = new User([
'name' => $data->Nick,
@@ -94,10 +96,7 @@ class CreateUsersTables extends Migration
'last_login_at' => Carbon::createFromTimestamp($data->lastLogIn),
]);
$user->setAttribute('id', $data->UID);
- if (!in_array(
- $data->CreateDate,
- ['0000-00-00 00:00:00', '0001-01-01 00:00:00', '1000-01-01 00:00:00']
- )) {
+ if (!in_array($data->CreateDate, $emptyDates)) {
$user->setAttribute('created_at', new Carbon($data->CreateDate));
}
$user->save();
@@ -114,8 +113,12 @@ class CreateUsersTables extends Migration
'first_name' => $data->Vorname ?: null,
'last_name' => $data->Name ?: null,
'shirt_size' => $data->Size ?: null,
- 'planned_arrival_date' => $data->planned_arrival_date ? Carbon::createFromTimestamp($data->planned_arrival_date) : null,
- 'planned_departure_date' => $data->planned_departure_date ? Carbon::createFromTimestamp($data->planned_departure_date) : null,
+ 'planned_arrival_date' => $data->planned_arrival_date
+ ? Carbon::createFromTimestamp($data->planned_arrival_date)
+ : null,
+ 'planned_departure_date' => $data->planned_departure_date
+ ? Carbon::createFromTimestamp($data->planned_departure_date)
+ : null,
]);
$personalData->user()
->associate($user)
@@ -181,7 +184,7 @@ class CreateUsersTables extends Migration
$table->string('DECT', 5)->nullable();
$table->string('Handy', 40)->nullable();
$table->string('email', 123)->nullable();
- $table->boolean('email_shiftinfo')->default(false)->comment('User wants to be informed by mail about changes in his shifts');
+ $table->boolean('email_shiftinfo')->default(false);
$table->string('jabber', 200)->nullable();
$table->string('Size', 4)->nullable();
$table->string('Passwort', 128)->nullable();
@@ -244,8 +247,12 @@ class CreateUsersTables extends Migration
'api_key' => $user->api_key,
'got_voucher' => $state->got_voucher,
'arrival_date' => $state->arrival_date ? $state->arrival_date->getTimestamp() : null,
- 'planned_arrival_date' => $personal->planned_arrival_date ? $personal->planned_arrival_date->getTimestamp() : null,
- 'planned_departure_date' => $personal->planned_departure_date ? $personal->planned_departure_date->getTimestamp() : null,
+ 'planned_arrival_date' => $personal->planned_arrival_date
+ ? $personal->planned_arrival_date->getTimestamp()
+ : null,
+ 'planned_departure_date' => $personal->planned_departure_date
+ ? $personal->planned_departure_date->getTimestamp()
+ : null,
'email_by_human_allowed' => $settings->email_human,
]);
}
diff --git a/db/migrations/ChangesReferences.php b/db/migrations/ChangesReferences.php
index 6bdd187d..1e7a5f10 100644
--- a/db/migrations/ChangesReferences.php
+++ b/db/migrations/ChangesReferences.php
@@ -24,14 +24,16 @@ trait ChangesReferences
$table->dropForeign($reference->constraint);
});
- $this->schema->table($reference->table,
+ $this->schema->table(
+ $reference->table,
function (Blueprint $table) use ($reference, $targetTable, $targetColumn, $type) {
$table->{$type}($reference->column)->change();
$table->foreign($reference->column)
->references($targetColumn)->on($targetTable)
->onDelete('cascade');
- });
+ }
+ );
}
}