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.

57 lines
1.7 KiB

  1. <?php
  2. use Movim\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. class CreateStickersTable extends Migration
  5. {
  6. public function up()
  7. {
  8. $this->schema->create('stickers_packs', function (Blueprint $table) {
  9. $table->string('name');
  10. $table->string('homepage')->nullable();
  11. $table->string('author')->nullable();
  12. $table->string('license')->nullable();
  13. $table->timestamps();
  14. $table->unique('name');
  15. });
  16. $this->schema->create('stickers', function (Blueprint $table) {
  17. $table->increments('id');
  18. $table->string('pack');
  19. $table->string('name');
  20. $table->string('filename');
  21. $table->string('cache_hash');
  22. $table->string('cache_hash_algorythm');
  23. $table->timestamps();
  24. $table->foreign('pack')->references('name')
  25. ->on('stickers_packs')->onDelete('cascade');
  26. $table->index(['cache_hash', 'cache_hash_algorythm']);
  27. $table->unique(['pack', 'name'], 'stickers_pack_name_file_unique');
  28. });
  29. $this->schema->table('messages', function (Blueprint $table) {
  30. $table->dropColumn('sticker');
  31. $table->string('sticker_cid_hash', 256)->nullable();
  32. $table->string('sticker_cid_algorythm', 16)->nullable();
  33. });
  34. }
  35. public function down()
  36. {
  37. $this->schema->table('messages', function (Blueprint $table) {
  38. $table->dropColumn('sticker_cid_hash');
  39. $table->dropColumn('sticker_cid_algorythm');
  40. $table->string('sticker', 128)->nullable();
  41. });
  42. $this->schema->drop('stickers');
  43. $this->schema->drop('stickers_packs');
  44. }
  45. }