File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
src/Illuminate/Database/Schema/Grammars Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,10 @@ protected static function getDoctrineColumnChangeOptions(Fluent $fluent)
125
125
$ options ['length ' ] = static ::calculateDoctrineTextLength ($ fluent ['type ' ]);
126
126
}
127
127
128
+ if ($ fluent ['type ' ] === 'char ' ) {
129
+ $ options ['fixed ' ] = true ;
130
+ }
131
+
128
132
if (static ::doesntNeedCharacterOptions ($ fluent ['type ' ])) {
129
133
$ options ['customSchemaOptions ' ] = [
130
134
'collation ' => '' ,
@@ -151,6 +155,7 @@ protected static function getDoctrineColumnType($type)
151
155
'mediumtext ' , 'longtext ' => 'text ' ,
152
156
'binary ' => 'blob ' ,
153
157
'uuid ' => 'guid ' ,
158
+ 'char ' => 'string ' ,
154
159
default => $ type ,
155
160
});
156
161
}
Original file line number Diff line number Diff line change @@ -126,6 +126,29 @@ public function testChangingColumnWithCollationWorks()
126
126
$ this ->assertEquals ($ expected2 , $ queries2 );
127
127
}
128
128
129
+ public function testChangingCharColumnsWork ()
130
+ {
131
+ $ this ->db ->connection ()->getSchemaBuilder ()->create ('users ' , function ($ table ) {
132
+ $ table ->string ('name ' );
133
+ });
134
+
135
+ $ blueprint = new Blueprint ('users ' , function ($ table ) {
136
+ $ table ->char ('name ' , 50 )->change ();
137
+ });
138
+
139
+ $ queries = $ blueprint ->toSql ($ this ->db ->connection (), new SQLiteGrammar );
140
+
141
+ $ expected = [
142
+ 'CREATE TEMPORARY TABLE __temp__users AS SELECT name FROM users ' ,
143
+ 'DROP TABLE users ' ,
144
+ 'CREATE TABLE users (name CHAR(50) NOT NULL COLLATE BINARY) ' ,
145
+ 'INSERT INTO users (name) SELECT name FROM __temp__users ' ,
146
+ 'DROP TABLE __temp__users ' ,
147
+ ];
148
+
149
+ $ this ->assertEquals ($ expected , $ queries );
150
+ }
151
+
129
152
public function testRenameIndexWorks ()
130
153
{
131
154
$ this ->db ->connection ()->getSchemaBuilder ()->create ('users ' , function ($ table ) {
You can’t perform that action at this time.
0 commit comments