85 lines
2.8 KiB
PHP
85 lines
2.8 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
use Phinx\Migration\AbstractMigration;
|
|
|
|
final class CalendarAddFields extends AbstractMigration
|
|
{
|
|
public function up(): void
|
|
{
|
|
if($this->getEnvironment() == "thetool") {
|
|
$table = $this->table('Calendar');
|
|
if (!$table->hasColumn('calendar_name')) {
|
|
$table->addColumn('calendar_name', 'string', [
|
|
'limit' => 255,
|
|
'null' => true,
|
|
'after' => 'user_id',
|
|
]);
|
|
}
|
|
if (!$table->hasColumn('calendar_firstname')) {
|
|
$table->addColumn('calendar_firstname', 'string', [
|
|
'limit' => 100,
|
|
'null' => true,
|
|
'after' => 'calendar_name',
|
|
]);
|
|
}
|
|
if (!$table->hasColumn('calendar_lastname')) {
|
|
$table->addColumn('calendar_lastname', 'string', [
|
|
'limit' => 100,
|
|
'null' => true,
|
|
'after' => 'calendar_firstname',
|
|
]);
|
|
}
|
|
if (!$table->hasColumn('calendar_email')) {
|
|
$table->addColumn('calendar_email', 'string', [
|
|
'limit' => 255,
|
|
'null' => true,
|
|
'after' => 'calendar_name', // wie in deinem SQL
|
|
]);
|
|
}
|
|
if ($table->hasColumn('user_id')) {
|
|
$table->changeColumn('user_id', 'integer', [
|
|
'null' => true,
|
|
'default' => null,
|
|
]);
|
|
}
|
|
if ($table->hasColumn('microsoft_id')) {
|
|
$table->changeColumn('microsoft_id', 'text', [
|
|
'null' => true,
|
|
'encoding' => 'utf8mb4',
|
|
'collation' => 'utf8mb4_unicode_ci',
|
|
]);
|
|
}
|
|
$table->update();
|
|
}
|
|
|
|
if($this->getEnvironment() == "addressdb") {
|
|
|
|
}
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
if($this->getEnvironment() == "thetool") {
|
|
$table = $this->table('Calendar');
|
|
if ($table->hasColumn('calendar_email')) {
|
|
$table->removeColumn('calendar_email');
|
|
}
|
|
if ($table->hasColumn('calendar_lastname')) {
|
|
$table->removeColumn('calendar_lastname');
|
|
}
|
|
if ($table->hasColumn('calendar_firstname')) {
|
|
$table->removeColumn('calendar_firstname');
|
|
}
|
|
if ($table->hasColumn('calendar_name')) {
|
|
$table->removeColumn('calendar_name');
|
|
}
|
|
$table->update();
|
|
}
|
|
|
|
if($this->getEnvironment() == "addressdb") {
|
|
|
|
}
|
|
}
|
|
}
|