Skip to content

Commit dfaed48

Browse files
author
Colin Viebrock
committed
tweak autoinc/unsigned method names
1 parent d01c392 commit dfaed48

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

.semver

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
:major: 1
33
:minor: 8
4-
:patch: 0
4+
:patch: 1
55
:special: ''

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 1.8.1 - 26-Nov-2020
4+
5+
- Minor tweak to unsigned or auto-incrementing integers to use
6+
the more compact migration methods
7+
8+
39
## 1.8.0 - 26-Nov-2020
410

511
- Reworked handling of signed autoincrement integers and

ExportToLaravelMigration.spBundle/MigrationParser.php

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,15 @@ public function formatStructure()
251251

252252
$method = $data['method'];
253253
$isNumeric = $this->isNumeric($method);
254+
$isInteger = $this->isInteger($method);
255+
256+
if ($isInteger) {
257+
if ($data['autoIncrement']) {
258+
$method = str_replace('nteger', 'ncrements', $method);
259+
} elseif ($data['unsigned']) {
260+
$method = 'unsigned' . ucfirst($method);
261+
}
262+
}
254263

255264
if ($method === 'timestamp' && $data['args'] === self::TS_UPDATE_STRING) {
256265
$data['default'] .= ' ' . $data['args'];
@@ -270,16 +279,13 @@ public function formatStructure()
270279
} else {
271280
$temp .= '()';
272281
}
273-
if ($data['autoIncrement']) {
274-
if (stripos($temp, 'nteger')!==false) {
275-
$temp = str_replace('nteger', 'ncrements', $temp);
276-
$data['unsigned'] = false;
277-
} else {
282+
if (!$isInteger) {
283+
if ($data['autoIncrement']) {
278284
$temp .= '->autoIncrement()';
279285
}
280-
}
281-
if ($data['unsigned']) {
282-
$temp .= '->unsigned()';
286+
if ($data['unsigned']) {
287+
$temp .= '->unsigned()';
288+
}
283289
}
284290
if ($data['nullable']) {
285291
$temp .= '->nullable()';
@@ -707,9 +713,14 @@ private function trimStringQuotes($string)
707713
);
708714
}
709715

716+
private function isInteger($method)
717+
{
718+
return stripos($method, 'integer') !== false;
719+
}
720+
710721
private function isNumeric($method)
711722
{
712-
return (stripos($method, 'integer') !== false)
723+
return $this->isInteger($method)
713724
|| $method === 'decimal'
714725
|| $method === 'double'
715726
|| $method === 'float'

ExportToLaravelMigration.spBundle/command.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
<key>keyEquivalent</key>
1616
<string>^~@m</string>
1717
<key>name</key>
18-
<string>Export To Laravel Migration</string>
18+
<string>Export To Laravel Migration(s)</string>
1919
<key>output</key>
2020
<string>showashtml</string>
2121
<key>scope</key>
2222
<string>general</string>
2323
<key>tooltip</key>
24-
<string>Export the selected table(s) to Laravel migration file on the Desktop</string>
24+
<string>Export the selected table(s) to Laravel migration file(s) in a Desktop folder</string>
2525
<key>uuid</key>
2626
<string>BAAD749B-F050-4F02-879C-333B581D2E23</string>
2727
</dict>

0 commit comments

Comments
 (0)