summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrations/2018_12_21_000000_change_users_contact_dect_field_size.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/db/migrations/2018_12_21_000000_change_users_contact_dect_field_size.php b/db/migrations/2018_12_21_000000_change_users_contact_dect_field_size.php
new file mode 100644
index 00000000..0478b138
--- /dev/null
+++ b/db/migrations/2018_12_21_000000_change_users_contact_dect_field_size.php
@@ -0,0 +1,47 @@
+<?php
+
+namespace Engelsystem\Migrations;
+
+use Engelsystem\Database\Migration\Migration;
+use Illuminate\Database\Schema\Blueprint;
+
+class ChangeUsersContactDectFieldSize extends Migration
+{
+ /** @var array */
+ protected $tables = [
+ 'AngelTypes' => 'contact_dect',
+ 'users_contact' => 'dect',
+ ];
+
+ /**
+ * Run the migration
+ */
+ public function up()
+ {
+ $this->changeDectTo(40);
+ }
+
+ /**
+ * Reverse the migration
+ */
+ public function down()
+ {
+ $this->changeDectTo(5);
+ }
+
+ /**
+ * @param int $length
+ */
+ protected function changeDectTo(int $length)
+ {
+ foreach ($this->tables as $table => $column) {
+ if (!$this->schema->hasTable($table)) {
+ continue;
+ }
+
+ $this->schema->table($table, function (Blueprint $table) use ($column, $length) {
+ $table->string($column, $length)->change();
+ });
+ }
+ }
+}