Skip to content

Commit

Permalink
rename uuid column to char 36 for future consistency with mariadb driver
Browse files Browse the repository at this point in the history
  • Loading branch information
Xinecraft committed Dec 9, 2024
1 parent 090b9af commit dee7d24
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public function up(): void
{
$this->schema->create('telescope_entries', function (Blueprint $table) {
$table->bigIncrements('sequence');
$table->uuid('uuid');
$table->uuid('batch_id');
$table->char('uuid', 36); // uuid
$table->char('batch_id', 36); // uuid
$table->string('family_hash')->nullable();
$table->boolean('should_display_on_index')->default(true);
$table->string('type', 20);
Expand All @@ -52,7 +52,7 @@ public function up(): void
});

$this->schema->create('telescope_entries_tags', function (Blueprint $table) {
$table->uuid('entry_uuid');
$table->char('entry_uuid', 36); // uuid
$table->string('tag');

$table->index(['entry_uuid', 'tag']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public function up()
{
Schema::create('players', function (Blueprint $table) {
$table->id();
$table->uuid('uuid')->unique();
$table->char('uuid', 36)->unique();
$table->string('username')->index()->nullable();
$table->float('rating')->nullable(); // Calculated from secret rating function. Used to decide how elite player is.
$table->float('rating', 23)->nullable(); // Calculated from secret rating function. Used to decide how elite player is.
$table->integer('total_score')->default(0); // Used to calculate Rank. Admin can change what score give what rank.
$table->unsignedInteger('position')->nullable(); // Based on Average of rating and score maybe

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function up()
Schema::create('json_minecraft_player_stats', function (Blueprint $table) {
$table->id();
$table->foreignId('server_id')->constrained()->onDelete('cascade');
$table->uuid('uuid')->index();
$table->char('uuid', 36)->index();
$table->string('username')->nullable();
$table->unsignedBigInteger('last_modified')->nullable(); // This can be used as player last seen
$table->string('hash')->nullable(); // Used to check if file has changed in server and need to be synced
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CreateNotificationsTable extends Migration
public function up()
{
Schema::create('notifications', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->char('id', 36)->primary();
$table->string('type');
$table->morphs('notifiable');
$table->text('data');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function up()
Schema::create('json_minecraft_player_advancements', function (Blueprint $table) {
$table->id();
$table->foreignId('server_id')->constrained()->onDelete('cascade');
$table->uuid('uuid');
$table->char('uuid', 36); // uuid

$table->unsignedInteger('data_version')->nullable();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function up()
$table->bigIncrements('id');

$table->morphs('model');
$table->uuid('uuid')->nullable()->unique();
$table->char('uuid', 36)->nullable()->unique();
$table->string('collection_name');
$table->string('name');
$table->string('file_name');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function up()
$table->id();
$table->foreignId('server_id')->nullable()->constrained('servers')->cascadeOnDelete();
$table->text('data')->nullable();
$table->uuid('causer_uuid')->nullable();
$table->char('causer_uuid', 36)->nullable(); // uuid
$table->string('causer_username')->nullable();
$table->string('channel')->nullable(); // Eg: global, admin
$table->string('type')->nullable(); // Eg: chat, death, etc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public function up()
{
Schema::create('minecraft_player_sessions', function (Blueprint $table) {
$table->id();
$table->uuid('uuid')->unique();
$table->uuid('player_uuid')->index();
$table->char('uuid', 36)->unique(); // uuid
$table->char('player_uuid', 36)->index(); // uuid
$table->string('player_username');
$table->string('player_displayname')->nullable();
$table->timestamp('session_started_at')->nullable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public function up()
{
Schema::create('minecraft_player_pvp_kills', function (Blueprint $table) {
$table->id();
$table->uuid('killer_uuid')->index();
$table->uuid('victim_uuid')->index();
$table->char('killer_uuid', 36)->index(); // uuid
$table->char('victim_uuid', 36)->index(); // uuid
$table->string('killer_username');
$table->string('victim_username');
$table->timestamp('killed_at')->nullable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function up()
{
Schema::create('minecraft_player_mob_kills', function (Blueprint $table) {
$table->id();
$table->uuid('player_uuid')->index();
$table->char('player_uuid', 36)->index(); // uuid
$table->string('player_username');
$table->string('mob_id');
$table->string('mob_name');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function up()
{
Schema::create('minecraft_player_events', function (Blueprint $table) {
$table->id();
$table->uuid('player_uuid')->index();
$table->char('player_uuid', 36)->index(); // uuid
$table->string('player_username');
$table->string('ip_address')->nullable();
$table->integer('player_ping')->nullable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ public function up()
{
Schema::create('minecraft_player_deaths', function (Blueprint $table) {
$table->id();
$table->uuid('player_uuid')->index();
$table->char('player_uuid', 36)->index(); // uuid
$table->string('player_username');
$table->string('cause'); // Death cause
$table->uuid('killer_uuid')->nullable(); // if killed by player then player uuid here
$table->char('killer_uuid', 36)->nullable(); // if killed by player then player uuid here
$table->string('killer_username')->nullable(); // if killed by player then player name here

$table->string('killer_entity_id')->nullable(); // If killed by mob: Entity id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function up()
{
Schema::create('minecraft_player_world_stats', function (Blueprint $table) {
$table->id();
$table->uuid('player_uuid')->index();
$table->char('player_uuid', 36)->index();
$table->integer('survival_time')->default(0);
$table->integer('creative_time')->default(0);
$table->integer('adventure_time')->default(0);
Expand Down
6 changes: 3 additions & 3 deletions database/migrations/2023_06_07_000001_create_pulse_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function up(): void
$table->string('type');
$table->text('key');
match ($driver = $connection->getDriverName()) {
'mysql' => $table->char('key_hash', 16)->charset('binary')->virtualAs('unhex(md5(`key`))'),
'mysql', 'mariadb' => $table->char('key_hash', 16)->charset('binary')->virtualAs('unhex(md5(`key`))'),
'pgsql' => $table->uuid('key_hash')->storedAs('md5("key")::uuid'),
default => throw new RuntimeException("Unsupported database driver [{$driver}]."),
};
Expand All @@ -46,7 +46,7 @@ public function up(): void
$table->string('type');
$table->text('key');
match ($driver = $connection->getDriverName()) {
'mysql' => $table->char('key_hash', 16)->charset('binary')->virtualAs('unhex(md5(`key`))'),
'mysql', 'mariadb' => $table->char('key_hash', 16)->charset('binary')->virtualAs('unhex(md5(`key`))'),
'pgsql' => $table->uuid('key_hash')->storedAs('md5("key")::uuid'),
default => throw new RuntimeException("Unsupported database driver [{$driver}]."),
};
Expand All @@ -65,7 +65,7 @@ public function up(): void
$table->string('type');
$table->text('key');
match ($driver = $connection->getDriverName()) {
'mysql' => $table->char('key_hash', 16)->charset('binary')->virtualAs('unhex(md5(`key`))'),
'mysql', 'mariadb' => $table->char('key_hash', 16)->charset('binary')->virtualAs('unhex(md5(`key`))'),
'pgsql' => $table->uuid('key_hash')->storedAs('md5("key")::uuid'),
default => throw new RuntimeException("Unsupported database driver [{$driver}]."),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function down(): void
Schema::create('json_minecraft_player_stats', function (Blueprint $table) {
$table->id();
$table->foreignId('server_id')->constrained()->onDelete('cascade');
$table->uuid('uuid')->index();
$table->char('uuid', 36)->index(); // uuid
$table->string('username')->nullable();
$table->unsignedBigInteger('last_modified')->nullable(); // This can be used as player last seen
$table->string('hash')->nullable(); // Used to check if file has changed in server and need to be synced
Expand Down Expand Up @@ -81,7 +81,7 @@ public function down(): void
Schema::create('json_minecraft_player_advancements', function (Blueprint $table) {
$table->id();
$table->foreignId('server_id')->constrained()->onDelete('cascade');
$table->uuid('uuid');
$table->char('uuid', 36); // uuid

$table->unsignedInteger('data_version')->nullable();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function up(): void
// Create new table with same name.
Schema::create('minecraft_players', function(Blueprint $table) {
$table->id();
$table->uuid('player_uuid')->index();
$table->char('player_uuid', 36)->index(); // uuid
$table->string('player_username')->index()->nullable();
$table->string('player_displayname')->nullable();
$table->string('player_ip_address')->nullable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function up(): void
$table->string('type');
$table->string('plugin_punishment_id')->nullable();
$table->string('plugin_name')->nullable();
$table->uuid('uuid')->nullable()->index();
$table->char('uuid', 36)->nullable()->index(); // uuid
$table->string('ip_address')->nullable();
$table->foreignId('player_id')->nullable()->constrained('players')->nullOnDelete();
$table->boolean('is_ipban')->default(false);
Expand All @@ -33,9 +33,9 @@ public function up(): void
$table->foreignId('scope_server_id')->nullable()->constrained('servers')->nullOnDelete();
$table->foreignId('origin_server_id')->nullable()->constrained('servers')->nullOnDelete();

$table->uuid('creator_uuid')->nullable()->index();
$table->char('creator_uuid', 36)->nullable()->index(); // uuid
$table->string('creator_username')->nullable();
$table->uuid('remover_uuid')->nullable()->index();
$table->char('remover_uuid', 36)->nullable()->index(); // uuid
$table->string('remover_username')->nullable();
$table->string('removed_reason')->nullable();
$table->timestamp('removed_at')->nullable();
Expand Down

0 comments on commit dee7d24

Please sign in to comment.