예제 #1
0
 /**
  * Gets the generic table column.
  * The $column parameter must contain:
  *  - name
  *  - type
  *  - length
  *  - precision
  *  - scale
  *  - unisgned
  *  - fixed
  *  - not_null
  *  - default
  *  - auto_increment
  *  - comment
  * @param array $column The column.
  * @return Column The generic column.
  */
 protected function getGenericColumn(array $column) : Column
 {
     $typeToken = '(),';
     $databaseType = strtok($column['type'], $typeToken);
     $length = $precision = strtok($typeToken);
     $length = $precision = $length !== false ? (int) $length : null;
     $scale = strtok($typeToken);
     $scale = $scale !== false ? (int) $scale : null;
     $default = !empty($column['default']) ? $column['default'] : null;
     switch ($databaseType) {
         case 'decimal':
         case 'double':
         case 'float':
         case 'numeric':
         case 'real':
             $length = null;
             break;
         case 'bigint':
         case 'int':
         case 'integer':
         case 'smallint':
         case 'char':
         case 'longtext':
         case 'mediumint':
         case 'mediumtext':
         case 'string':
         case 'text':
         case 'tinytext':
         case 'varchar':
             $precision = null;
             $scale = null;
             break;
         default:
             $length = null;
             $precision = null;
             $scale = null;
             break;
     }
     return parent::getGenericColumn(['name' => $column['name'], 'type' => $databaseType, 'length' => $length, 'precision' => $precision, 'scale' => $scale, 'unsigned' => $column['unsigned'] ? true : null, 'fixed' => $databaseType === 'char' ? true : null, 'not_null' => $column['not_null'], 'default' => $default, 'auto_increment' => $column['auto_increment'] ? true : null, 'comment' => !empty($column['comment']) ? $column['comment'] : null]);
 }
예제 #2
0
 /**
  * Gets the generic table checks.
  * The $checks parameter contains:
  *  - name
  *  - definition
  * @param array $checks The checks.
  * @return array The generic checks.
  */
 protected function getGenericChecks(array $checks) : array
 {
     foreach ($checks as &$check) {
         $check['definition'] = substr($check['definition'], 1, -1);
     }
     return parent::getGenericChecks($checks);
 }