Skip to content

Commit

Permalink
use uuid by default on uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Feb 25, 2024
1 parent 06a5717 commit 8648a4a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
11 changes: 11 additions & 0 deletions src/Illuminate/Database/Schema/Grammars/MariaDbGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ public function compileRenameColumn(Blueprint $blueprint, Fluent $command, Conne
return parent::compileRenameColumn($blueprint, $command, $connection);
}

/**
* Create the column definition for a uuid type.
*
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function typeUuid(Fluent $column)
{
return 'uuid';
}

/**
* Create the column definition for a spatial Geometry type.
*
Expand Down
8 changes: 4 additions & 4 deletions tests/Database/DatabaseMariaDbSchemaGrammarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function testBasicCreateTable()
$statements = $blueprint->toSql($conn, $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertSame('create table `users` (`id` char(36) not null, primary key (`id`))', $statements[0]);
$this->assertSame('create table `users` (`id` uuid not null, primary key (`id`))', $statements[0]);
}

public function testAutoIncrementStartingValue()
Expand Down Expand Up @@ -1090,7 +1090,7 @@ public function testAddingUuid()
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertSame('alter table `users` add `foo` char(36) not null', $statements[0]);
$this->assertSame('alter table `users` add `foo` uuid not null', $statements[0]);
}

public function testAddingUuidDefaultsColumnName()
Expand All @@ -1100,7 +1100,7 @@ public function testAddingUuidDefaultsColumnName()
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertSame('alter table `users` add `uuid` char(36) not null', $statements[0]);
$this->assertSame('alter table `users` add `uuid` uuid not null', $statements[0]);
}

public function testAddingForeignUuid()
Expand All @@ -1116,7 +1116,7 @@ public function testAddingForeignUuid()

$this->assertInstanceOf(ForeignIdColumnDefinition::class, $foreignUuid);
$this->assertSame([
'alter table `users` add `foo` char(36) not null, add `company_id` char(36) not null, add `laravel_idea_id` char(36) not null, add `team_id` char(36) not null, add `team_column_id` char(36) not null',
'alter table `users` add `foo` uuid not null, add `company_id` uuid not null, add `laravel_idea_id` uuid not null, add `team_id` uuid not null, add `team_column_id` uuid not null',
'alter table `users` add constraint `users_company_id_foreign` foreign key (`company_id`) references `companies` (`id`)',
'alter table `users` add constraint `users_laravel_idea_id_foreign` foreign key (`laravel_idea_id`) references `laravel_ideas` (`id`)',
'alter table `users` add constraint `users_team_id_foreign` foreign key (`team_id`) references `teams` (`id`)',
Expand Down

0 comments on commit 8648a4a

Please sign in to comment.