You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.9 KiB

  1. <?php
  2. use Movim\Migration;
  3. use App\Contact;
  4. use App\Presence;
  5. use App\Roster;
  6. use App\Conference;
  7. use Illuminate\Database\Schema\Blueprint;
  8. /**
  9. * Required after the behavior change introduced in
  10. * https://laravel.com/docs/11.x/upgrade#modifying-columns
  11. */
  12. class ReconciliateNullableInTables extends Migration
  13. {
  14. public function up()
  15. {
  16. $this->schema->table('presences', function (Blueprint $table) {
  17. $table->text('status')->nullable()->change();
  18. });
  19. $this->schema->table('rosters', function (Blueprint $table) {
  20. $table->string('name', 256)->nullable()->change();
  21. });
  22. $this->schema->table('conferences', function (Blueprint $table) {
  23. $table->string('nick', 256)->nullable()->change();
  24. });
  25. $this->schema->table('contacts', function (Blueprint $table) {
  26. $table->string('nickname', 256)->nullable()->change();
  27. $table->string('fn', 256)->nullable()->change();
  28. });
  29. }
  30. public function down()
  31. {
  32. Presence::whereNull('status')->delete();
  33. $this->schema->table('presences', function (Blueprint $table) {
  34. $table->text('status')->nullable(false)->change();
  35. });
  36. Roster::whereNull('name')->delete();
  37. $this->schema->table('rosters', function (Blueprint $table) {
  38. $table->string('name', 256)->nullable(false)->change();
  39. });
  40. Conference::whereNull('nick')->delete();
  41. $this->schema->table('conferences', function (Blueprint $table) {
  42. $table->string('nick', 256)->nullable(false)->change();
  43. });
  44. Contact::whereNull('nickname')->delete();
  45. Contact::whereNull('fn')->delete();
  46. $this->schema->table('contacts', function (Blueprint $table) {
  47. $table->string('nickname', 256)->nullable(false)->change();
  48. $table->string('fn', 256)->nullable(false)->change();
  49. });
  50. }
  51. }