Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow migration to unsigned of existing users_* tables
- Loading branch information
Showing
1 changed file
with
91 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?php | ||
|
||
/** | ||
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 | ||
* @copyright Aimeos (aimeos.org), 2019 | ||
*/ | ||
|
||
|
||
namespace Aimeos\MW\Setup\Task; | ||
|
||
|
||
/** | ||
* Removes signed constraints from users_* tables before migrating to unsigned | ||
*/ | ||
class UsersRemoveSignedConstraints extends \Aimeos\MW\Setup\Task\Base | ||
{ | ||
/** | ||
* Returns the list of task names which this task depends on. | ||
* | ||
* @return string[] List of task names | ||
*/ | ||
public function getPreDependencies() | ||
{ | ||
return []; | ||
} | ||
|
||
|
||
/** | ||
* Returns the list of task names which depends on this task. | ||
* | ||
* @return array List of task names | ||
*/ | ||
public function getPostDependencies() | ||
{ | ||
return ['TablesCreateMShop']; | ||
} | ||
|
||
|
||
/** | ||
* Executes the task | ||
*/ | ||
public function migrate() | ||
{ | ||
$sql = 'SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = \'users\' AND COLUMN_NAME = \'id\''; | ||
|
||
if( $this->getValue( $sql, 'COLUMN_TYPE', 'db-customer' ) === 'int(10)' ) | ||
{ | ||
$this->msg( sprintf( 'Remove signed constraints in users related tables' ), 0 ); | ||
$this->status( '' ); | ||
|
||
|
||
$this->msg( 'Checking constraint in "users_address"', 1 ); | ||
|
||
if( $schema->constraintExists( 'users_address', 'fk_lvuad_pid' ) ) | ||
{ | ||
$this->execute( 'ALTER TABLE "users_address" DROP FOREIGN KEY "fk_lvuad_pid"', 'db-customer' ); | ||
$this->status( 'done' ); | ||
} | ||
else | ||
{ | ||
$this->status( 'OK' ); | ||
} | ||
|
||
|
||
$this->msg( 'Checking constraint in "users_list"', 1 ); | ||
|
||
if( $schema->constraintExists( 'users_list', 'fk_lvuli_pid' ) ) | ||
{ | ||
$this->execute( 'ALTER TABLE "users_list" DROP FOREIGN KEY "fk_lvuli_pid"', 'db-customer' ); | ||
$this->status( 'done' ); | ||
} | ||
else | ||
{ | ||
$this->status( 'OK' ); | ||
} | ||
|
||
|
||
$this->msg( 'Checking constraint in "users_property"', 1 ); | ||
|
||
if( $schema->constraintExists( 'users_property', 'fk_lvupr_pid' ) ) | ||
{ | ||
$this->execute( 'ALTER TABLE "users_property" DROP FOREIGN KEY "fk_lvupr_pid"', 'db-customer' ); | ||
$this->status( 'done' ); | ||
} | ||
else | ||
{ | ||
$this->status( 'OK' ); | ||
} | ||
} | ||
} | ||
} |