Skip to content

Commit 9d7ad74

Browse files
committed
#197: Add default values for double/float
1 parent 886630a commit 9d7ad74

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,8 @@ Note, that U have an ability to make any ranges for varchar, integer types throu
12211221
For instance, integer can be set to unsigned smallint with
12221222
`minimum: 1` (any number > 0) and `maximum: 2` (any number <= 3 to fit smallint db type range).
12231223

1224+
If double/float types used, then maximum goes for display length (or M) and minimum for precision (or D) in SQL e.g.: DOUBLE(M, D)
1225+
12241226
All migrations for specific module will be placed in ``` Modules/{ModuleName}/Database/Migrations/ ```
12251227

12261228
To execute them all - run: ``` php artisan module:migrate ```

src/Blocks/MigrationsTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ private function setNumberRow(array $attrVal, string $attrKey): void
121121
&& ($attrVal[ApiInterface::RAML_TYPE_FORMAT] === ModelsInterface::MIGRATION_METHOD_DOUBLE
122122
|| $attrVal[ApiInterface::RAML_TYPE_FORMAT] === ModelsInterface::MIGRATION_METHOD_FLOAT)
123123
) {
124-
$max = empty($attrVal[ApiInterface::RAML_INTEGER_MAX]) ? PhpInterface::PHP_TYPES_ARRAY : $attrVal[ApiInterface::RAML_INTEGER_MAX];
125-
$min = empty($attrVal[ApiInterface::RAML_INTEGER_MIN]) ? PhpInterface::PHP_TYPES_ARRAY : $attrVal[ApiInterface::RAML_INTEGER_MIN];
124+
$max = empty($attrVal[ApiInterface::RAML_INTEGER_MAX]) ? ModelsInterface::DEFAULT_DOUBLE_M : $attrVal[ApiInterface::RAML_INTEGER_MAX];
125+
$min = empty($attrVal[ApiInterface::RAML_INTEGER_MIN]) ? ModelsInterface::DEFAULT_DOUBLE_D : $attrVal[ApiInterface::RAML_INTEGER_MIN];
126126

127127
$this->setRow($attrVal[ApiInterface::RAML_TYPE_FORMAT], $attrKey, $max . PhpInterface::COMMA
128128
. PhpInterface::SPACE . $min);

src/Types/ModelsInterface.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ interface ModelsInterface
66
{
77
public const ID = 'id';
88
// Laravel
9-
public const LARAVEL_ACTIVE_RECORD = 'Model';
10-
public const LARAVEL_MIGRATION_CLASS = 'Migration';
11-
public const LARAVEL_PROPERTY_TABLE = 'table';
129
public const DEFAULT_LIMIT = 20;
1310
public const MAX_LIMIT = 1000;
1411
public const DEFAULT_PAGE = 1;
@@ -26,9 +23,6 @@ interface ModelsInterface
2623
public const LARAVEL_FILTER_MAX = 'max';
2724
public const COLUMN = 'column';
2825
public const DIRECTION = 'direction';
29-
public const PARENT_ID = 'parent_id';
30-
31-
public const COUNT = 'count';
3226

3327
// Methods
3428
public const MODEL_METHOD_ALL = 'all';
@@ -104,16 +98,18 @@ interface ModelsInterface
10498

10599

106100
public const ID_MAX_INCREMENTS = 10;
107-
public const STRING_MAX_CHARS = 32;
108101

109102
// db indices
110103
public const INDEX_TYPE_INDEX = 'index';
111104
public const INDEX_TYPE_UNIQUE = 'unique';
112105
public const INDEX_TYPE_PRIMARY = 'primary';
113106
public const INDEX_TYPE_FOREIGN = 'foreign';
114-
public const INDEX_COLUMN = '_column';
115107
public const INDEX_REFERENCES = 'references';
116108
public const INDEX_ON = 'on';
117109
public const INDEX_ON_DELETE = 'onDelete';
118110
public const INDEX_ON_UPDATE = 'onUpdate';
111+
112+
// default double/float values
113+
public const DEFAULT_DOUBLE_M = 16; // display length
114+
public const DEFAULT_DOUBLE_D = 4; // precision
119115
}

0 commit comments

Comments
 (0)