Skip to content

Commit 8648a4a

Browse files
committed
use uuid by default on uuid
1 parent 06a5717 commit 8648a4a

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/Illuminate/Database/Schema/Grammars/MariaDbGrammar.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ public function compileRenameColumn(Blueprint $blueprint, Fluent $command, Conne
5454
return parent::compileRenameColumn($blueprint, $command, $connection);
5555
}
5656

57+
/**
58+
* Create the column definition for a uuid type.
59+
*
60+
* @param \Illuminate\Support\Fluent $column
61+
* @return string
62+
*/
63+
protected function typeUuid(Fluent $column)
64+
{
65+
return 'uuid';
66+
}
67+
5768
/**
5869
* Create the column definition for a spatial Geometry type.
5970
*

tests/Database/DatabaseMariaDbSchemaGrammarTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function testBasicCreateTable()
5757
$statements = $blueprint->toSql($conn, $this->getGrammar());
5858

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

6363
public function testAutoIncrementStartingValue()
@@ -1090,7 +1090,7 @@ public function testAddingUuid()
10901090
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
10911091

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

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

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

11061106
public function testAddingForeignUuid()
@@ -1116,7 +1116,7 @@ public function testAddingForeignUuid()
11161116

11171117
$this->assertInstanceOf(ForeignIdColumnDefinition::class, $foreignUuid);
11181118
$this->assertSame([
1119-
'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',
1119+
'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',
11201120
'alter table `users` add constraint `users_company_id_foreign` foreign key (`company_id`) references `companies` (`id`)',
11211121
'alter table `users` add constraint `users_laravel_idea_id_foreign` foreign key (`laravel_idea_id`) references `laravel_ideas` (`id`)',
11221122
'alter table `users` add constraint `users_team_id_foreign` foreign key (`team_id`) references `teams` (`id`)',

0 commit comments

Comments
 (0)