Skip to content

Commit e69165c

Browse files
committed
SchemaGenerator: added some default custom types for MySQL
DateInterval is converted to TIME.
1 parent 14669f2 commit e69165c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

docs/custom-types.md

+10
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,13 @@ Prepared custom types for MySQL:
1414
- `bcrypt` - `CHAR(60)`
1515
- `md5` - `CHAR(32)`
1616
- `money` - `DECIMAL(15, 4)`
17+
- `DateInterval` - `TIME`
18+
- [`inteve/types`](https://github.com/inteve/types)
19+
- `Inteve\Types\HexColor` - `CHAR(6)`
20+
- `Inteve\Types\Html` - `MEDIUMTEXT`
21+
- `Inteve\Types\Md5Hash` - `CHAR(32)`
22+
- `Inteve\Types\Password` - `VARCHAR(255)`
23+
- `Inteve\Types\UniqueId` - `CHAR(10)`
24+
- `Inteve\Types\Url` - `VARCHAR(255)`
25+
- `Inteve\Types\UrlSlug` - `VARCHAR(255)`
26+
- `Inteve\Types\UrlPath` - `VARCHAR(255)`

src/SchemaGenerator.php

+9
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,15 @@ private function prepareDefaults($databaseType)
226226
$this->setCustomType('bcrypt', 'CHAR', [60]);
227227
$this->setCustomType('md5', 'CHAR', [32]);
228228
$this->setCustomType('money', 'DECIMAL', [15, 4]);
229+
$this->setCustomType(\DateInterval::class, 'TIME');
230+
$this->setCustomType(\Inteve\Types\HexColor::class, 'CHAR', [6]);
231+
$this->setCustomType(\Inteve\Types\Html::class, 'MEDIUMTEXT');
232+
$this->setCustomType(\Inteve\Types\Md5Hash::class, 'CHAR', [32]);
233+
$this->setCustomType(\Inteve\Types\Password::class, 'VARCHAR', [255]); // https://www.php.net/manual/en/function.password-hash.php#refsect1-function.password-hash-description
234+
$this->setCustomType(\Inteve\Types\UniqueId::class, 'CHAR', [10]);
235+
$this->setCustomType(\Inteve\Types\Url::class, 'VARCHAR', [255]);
236+
$this->setCustomType(\Inteve\Types\UrlSlug::class, 'VARCHAR', [255]);
237+
$this->setCustomType(\Inteve\Types\UrlPath::class, 'VARCHAR', [255]);
229238
}
230239
}
231240

0 commit comments

Comments
 (0)