-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
122 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# .github/workflows/lint.yaml | ||
name: Lint | ||
name: DOCtor-RST | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the MultiFlexi package | ||
* | ||
* https://multiflexi.eu/ | ||
* | ||
* (c) Vítězslav Dvořák <http://vitexsoftware.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
final class CredentialTypeUuid extends AbstractMigration | ||
{ | ||
/** | ||
* Change Method. | ||
* | ||
* Write your reversible migrations using this method. | ||
* | ||
* More information on writing migrations is available here: | ||
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method | ||
* | ||
* Remember to call "create()" or "update()" and NOT "save()" when working | ||
* with the Table class. | ||
*/ | ||
public function change(): void | ||
{ | ||
$table = $this->table('credential_type'); | ||
$table->addColumn('uuid', 'string', ['length' => 40])->update(); | ||
|
||
if ($this->adapter->getAdapterType() === 'mysql') { | ||
$this->execute('ALTER TABLE `credential_type` CHANGE `uuid` `uuid` VARCHAR(40) NULL DEFAULT uuid(); '); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the MultiFlexi package | ||
* | ||
* https://multiflexi.eu/ | ||
* | ||
* (c) Vítězslav Dvořák <http://vitexsoftware.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
final class CredentialTypeID extends AbstractMigration | ||
{ | ||
/** | ||
* Change Method. | ||
* | ||
* Write your reversible migrations using this method. | ||
* | ||
* More information on writing migrations is available here: | ||
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method | ||
* | ||
* Remember to call "create()" or "update()" and NOT "save()" when working | ||
* with the Table class. | ||
*/ | ||
public function change(): void | ||
{ | ||
$databaseType = $this->getAdapter()->getOption('adapter'); | ||
$unsigned = ($databaseType === 'mysql') ? ['signed' => false] : []; | ||
|
||
// Adding 'credential_type_id' column to 'credentials' table | ||
$table = $this->table('credentials'); | ||
$table->addColumn('credential_type_id', 'integer', array_merge(['null' => false], $unsigned)) | ||
->update(); | ||
|
||
// Check if the 'credentials' table is empty | ||
$rowCount = $this->fetchRow('SELECT COUNT(*) as count FROM credentials')['count']; | ||
|
||
if ($rowCount === 0) { | ||
// Add foreign key constraint only if the table is empty | ||
$table->addForeignKey('credential_type_id', 'credential_type', ['id'], ['constraint' => 'ct2c_credential_type_must_exist']) | ||
->update(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters