Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #227 #250

Merged
merged 7 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions .github/workflows/bc.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
on:
- pull_request
- push
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'phpunit.xml.dist'
- 'psalm.xml'
push:
branches: ['master']
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'phpunit.xml.dist'
- 'psalm.xml'

name: backwards compatibility

jobs:
roave_bc_check:
name: Roave BC Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: fetch tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Roave BC Check
uses: docker://nyholm/roave-bc-check-ga
roave_bc_check:
uses: yiisoft/actions/.github/workflows/bc.yml@master
with:
os: >-
['ubuntu-latest']
php: >-
['8.1']
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Yii DB Migration Change Log

## 1.0.1 under development
## 1.1.0 under development

- no changes in this release.
- New #250: Add shortcuts for UUID columns (@viktorprogger)

## 1.0.0 December 21, 2023

- Initial release.
- Initial release.
36 changes: 36 additions & 0 deletions src/AbstractMigrationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,42 @@ public function bigPrimaryKey(int $length = null): ColumnInterface
return $this->schema->createColumn(SchemaInterface::TYPE_BIGPK, $length);
}

/**
* Creates a UUID primary key column.
*
* This parameter will be ignored if not supported by the DBMS.
*
* @return ColumnInterface The column instance which can be further customized.
*/
public function uuidPrimaryKey(): ColumnInterface
{
return $this->schema->createColumn(SchemaInterface::TYPE_UUID_PK);
}

/**
* Creates a UUID primary key column with a sequence.
*
* This parameter will be ignored if not supported by the DBMS.
*
* @return ColumnInterface The column instance which can be further customized.
*/
public function uuidPrimaryKeySequenced(): ColumnInterface
{
return $this->schema->createColumn(SchemaInterface::TYPE_UUID_PK_SEQ);
}

/**
* Creates a UUID column.
*
* This parameter will be ignored if not supported by the DBMS.
*
* @return ColumnInterface The column instance which can be further customized.
*/
public function uuid(): ColumnInterface
{
return $this->schema->createColumn(SchemaInterface::TYPE_UUID);
}

/**
* Creates a binary column.
*
Expand Down
15 changes: 15 additions & 0 deletions tests/Common/AbstractMigrationBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,21 @@ public function testTinyInteger(): void
$this->assertSame('tinyint', $this->builder->tinyInteger()->asString());
}

public function testUuid(): void
{
$this->assertSame('uuid', $this->builder->uuid()->asString());
}

public function testUuidPrimaryKey(): void
{
$this->assertSame('uuid_pk', $this->builder->uuidPrimaryKey()->asString());
}

public function testUuidPrimaryKeySequenced(): void
{
$this->assertSame('uuid_pk_seq', $this->builder->uuidPrimaryKeySequenced()->asString());
}

public function testGetDb(): void
{
$this->assertSame($this->db, $this->builder->getDb());
Expand Down
Loading