From ba8cae362f3f869ba9425a2a52974f7b7d3cfdcd Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 25 Apr 2019 19:55:28 -0600 Subject: [PATCH 1/2] Add new migration --- ...add_snowflake_ids_to_collections_table.php | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 database/migrations/2019_04_25_200411_add_snowflake_ids_to_collections_table.php diff --git a/database/migrations/2019_04_25_200411_add_snowflake_ids_to_collections_table.php b/database/migrations/2019_04_25_200411_add_snowflake_ids_to_collections_table.php new file mode 100644 index 000000000..10392de1f --- /dev/null +++ b/database/migrations/2019_04_25_200411_add_snowflake_ids_to_collections_table.php @@ -0,0 +1,43 @@ +getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); + } + + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('collections', function (Blueprint $table) { + $table->dropPrimary('id'); + $table->bigInteger('id')->unsigned()->primary()->change(); + }); + + Schema::table('collection_items', function (Blueprint $table) { + $table->dropPrimary('id'); + $table->bigInteger('id')->unsigned()->primary()->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('collections', function (Blueprint $table) { + // + }); + } +} From 4f14a7dd749753bd1295561037572608c80aa56f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 25 Apr 2019 19:56:04 -0600 Subject: [PATCH 2/2] Add snowflake ids to Collection models --- app/Collection.php | 10 ++++++++++ app/CollectionItem.php | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/app/Collection.php b/app/Collection.php index e0e110f2e..2e46078c2 100644 --- a/app/Collection.php +++ b/app/Collection.php @@ -3,9 +3,19 @@ namespace App; use Illuminate\Database\Eloquent\Model; +use Pixelfed\Snowflake\HasSnowflakePrimary; class Collection extends Model { + use HasSnowflakePrimary; + + /** + * Indicates if the IDs are auto-incrementing. + * + * @var bool + */ + public $incrementing = false; + public function profile() { return $this->belongsTo(Profile::class); diff --git a/app/CollectionItem.php b/app/CollectionItem.php index 7e306a33e..0a3f72cb8 100644 --- a/app/CollectionItem.php +++ b/app/CollectionItem.php @@ -3,9 +3,19 @@ namespace App; use Illuminate\Database\Eloquent\Model; +use Pixelfed\Snowflake\HasSnowflakePrimary; class CollectionItem extends Model { + use HasSnowflakePrimary; + + /** + * Indicates if the IDs are auto-incrementing. + * + * @var bool + */ + public $incrementing = false; + public function collection() { return $this->belongsTo(Collection::class);