Skip to content

Commit

Permalink
Refactor column schema (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
samdark committed Mar 21, 2023
1 parent 91a96a7 commit d0cb221
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Expand Up @@ -69,7 +69,7 @@ jobs:
- name: Install db.
uses: yiisoft/actions/db/subpackage-install@master
with:
BRANCH_NAME: ${{ github.head_ref }}
BRANCH_NAME: ${{ env.BRANCH_NAME }}
COMPOSER_ROOT_VERSION: ${{ env.COMPOSER_ROOT_VERSION }}
CURRENT_PACKAGE: db
FULL_BRANCH_NAME: ${{ env.FULL_BRANCH_NAME }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mutation.yml
Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Install db.
uses: yiisoft/actions/db/subpackage-install@master
with:
BRANCH_NAME: ${{ github.head_ref }}
BRANCH_NAME: ${{ env.BRANCH_NAME }}
COMPOSER_ROOT_VERSION: ${{ env.COMPOSER_ROOT_VERSION }}
CURRENT_PACKAGE: db
FULL_BRANCH_NAME: ${{ env.FULL_BRANCH_NAME }}
Expand Down
11 changes: 7 additions & 4 deletions src/Schema.php
Expand Up @@ -457,8 +457,7 @@ public function getSchemaDefaultValues(string $schema = '', bool $refresh = fals
*/
protected function loadColumnSchema(array $info): ColumnSchemaInterface
{
$column = $this->createColumnSchema();
$column->name($info['name']);
$column = $this->createColumnSchema($info['name']);
$column->allowNull(!$info['notnull']);
$column->primaryKey($info['pk'] != '0');
$column->dbType(strtolower($info['type']));
Expand Down Expand Up @@ -603,10 +602,14 @@ private function loadTableConstraints(string $tableName, string $returnType): Co
* Creates a column schema for the database.
*
* This method may be overridden by child classes to create a DBMS-specific column schema.
*
* @param string $name Name of the column.
*
* @return ColumnSchemaInterface
*/
private function createColumnSchema(): ColumnSchemaInterface
private function createColumnSchema(string $name): ColumnSchemaInterface
{
return new ColumnSchema();
return new ColumnSchema($name);
}

/**
Expand Down

0 comments on commit d0cb221

Please sign in to comment.