First try to fix boolean defaultValue #314
This commit is contained in:
committed by
Alessandro Briosi
parent
b62143b39b
commit
4417f17c7f
@ -71,4 +71,18 @@ class MigrationHelper
|
|||||||
{
|
{
|
||||||
return self::resolveDbType($driverName) === 'sqlsrv';
|
return self::resolveDbType($driverName) === 'sqlsrv';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getBooleanValue($driverName,$value=false)
|
||||||
|
{
|
||||||
|
switch (self::resolveDbType($driverName)) {
|
||||||
|
case 'sqlsrv':
|
||||||
|
return $value?1:0;
|
||||||
|
break;
|
||||||
|
case 'pgsql':
|
||||||
|
return $value?true:false;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,13 +12,14 @@
|
|||||||
namespace Da\User\Migration;
|
namespace Da\User\Migration;
|
||||||
|
|
||||||
use yii\db\Migration;
|
use yii\db\Migration;
|
||||||
|
use Da\User\Helper\MigrationHelper;
|
||||||
|
|
||||||
class m000000_000006_add_two_factor_fields extends Migration
|
class m000000_000006_add_two_factor_fields extends Migration
|
||||||
{
|
{
|
||||||
public function safeUp()
|
public function safeUp()
|
||||||
{
|
{
|
||||||
$this->addColumn('{{%user}}', 'auth_tf_key', $this->string(16));
|
$this->addColumn('{{%user}}', 'auth_tf_key', $this->string(16));
|
||||||
$this->addColumn('{{%user}}', 'auth_tf_enabled', $this->boolean()->defaultValue(0));
|
$this->addColumn('{{%user}}', 'auth_tf_enabled', $this->boolean()->defaultValue(MigrationHelper::getBooleanValue($this->db->driverName,false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function safeDown()
|
public function safeDown()
|
||||||
|
|||||||
@ -12,14 +12,15 @@
|
|||||||
namespace Da\User\Migration;
|
namespace Da\User\Migration;
|
||||||
|
|
||||||
use yii\db\Migration;
|
use yii\db\Migration;
|
||||||
|
use Da\User\Helper\MigrationHelper;
|
||||||
|
|
||||||
class m000000_000009_add_gdpr_consent_fields extends Migration
|
class m000000_000009_add_gdpr_consent_fields extends Migration
|
||||||
{
|
{
|
||||||
public function safeUp()
|
public function safeUp()
|
||||||
{
|
{
|
||||||
$this->addColumn('{{%user}}', 'gdpr_consent', $this->boolean()->defaultValue(false));
|
$this->addColumn('{{%user}}', 'gdpr_consent', $this->boolean()->defaultValue(MigrationHelper::getBooleanValue($this->db->driverName,false)));
|
||||||
$this->addColumn('{{%user}}', 'gdpr_consent_date', $this->integer(11)->null());
|
$this->addColumn('{{%user}}', 'gdpr_consent_date', $this->integer(11)->null());
|
||||||
$this->addColumn('{{%user}}', 'gdpr_deleted', $this->boolean()->defaultValue(false));
|
$this->addColumn('{{%user}}', 'gdpr_deleted', $this->boolean()->defaultValue(MigrationHelper::getBooleanValue($this->db->driverName,false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function safeDown()
|
public function safeDown()
|
||||||
|
|||||||
Reference in New Issue
Block a user