1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- use App\Classes\LegacySettingsMigration;
- use Illuminate\Support\Facades\DB;
- class CreateTicketSettings extends LegacySettingsMigration
- {
- public function up(): void
- {
- $table_exists = DB::table('settings_old')->exists();
- // Get the user-set configuration values from the old table.
- $this->migrator->add('ticket.enabled', $table_exists ? $this->getOldValue('SETTINGS::TICKET:ENABLED') : 'true');
- $this->migrator->add('ticket.notify', $table_exists ? $this->getOldValue('SETTINGS::TICKET:NOTIFY') : 'all');
- }
- public function down(): void
- {
- DB::table('settings_old')->insert([
- [
- 'key' => 'SETTINGS::TICKET:NOTIFY',
- 'value' => $this->getNewValue('notify', 'ticket'),
- 'type' => 'string',
- 'description' => 'The notification type for tickets.',
- ],
- [
- 'key' => 'SETTINGS::TICKET:ENABLED',
- 'value' => $this->getNewValue('enabled', 'ticket'),
- 'type' => 'boolean',
- 'description' => 'Enable or disable the ticket system.',
- ]
- ]);
- try {
- $this->migrator->delete('ticket.enabled');
- $this->migrator->delete('ticket.notify');
- } catch (Exception $e) {
- // Do nothing.
- }
- }
- }
|