commit 04ae563d9e4d6acdd1838a3907ca380858685e2c
parent 24459dae0c73994d9a6db44fb7672c5cc973168d
Author: Jan Dankert <develop@jandankert.de>
Date: Sat, 31 Oct 2020 02:35:54 +0100
Save bytes and use the ascii charset for username and issuer.
Diffstat:
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/modules/cms/update/version/DBVersion000022.class.php b/modules/cms/update/version/DBVersion000022.class.php
@@ -21,17 +21,16 @@ class DBVersion000022 extends DbVersion
{
$table = $this->table('user');
- $table->column('ldap_dn' )->drop();
-
+ $table->column('issuer' )->type(Column::TYPE_VARCHAR )->charset('ascii')->size(50)->nullable()->add();
$table->column('auth_type' )->type(Column::TYPE_INT )->size(2)->defaultValue(1 )->add();
- $table->column('issuer' )->type(Column::TYPE_VARCHAR )->size(50)->nullable()->add();
- $table->dropUniqueIndex( ['name'] );
- $table->addUniqueIndex ( ['name','auth_type','issuer'] );
+ $table->column('ldap_dn' )->drop();
// OpenId subject identifiers may have up to 255 chars, so we have to increase the length
- $table->column('name' )->type(Column::TYPE_VARCHAR )->size(255)->modify();
- $table->column('fullname' )->type(Column::TYPE_VARCHAR )->size(255)->modify();
+ $table->column('name' )->type(Column::TYPE_VARCHAR )->charset('ascii')->size(255)->modify();
+ $table->column('fullname' )->type(Column::TYPE_VARCHAR )->size(255)->modify();
- }
+ $table->dropUniqueIndex( ['name'] );
+ $table->addUniqueIndex ( ['name','auth_type','issuer'] );
+ }
}
diff --git a/modules/database/Column.class.php b/modules/database/Column.class.php
@@ -17,6 +17,7 @@ class Column
private $table;
private $type = self::TYPE_INT;
+ private $charset = null;
private $size = null;
private $default = null;
private $nullable = false;
@@ -27,6 +28,12 @@ class Column
}
+ public function charset( $charset ) {
+ $this->charset = $charset;
+ return $this;
+ }
+
+
public function size( $size ) {
$this->size = $size;
return $this;
@@ -145,7 +152,9 @@ class Column
}
- return $dbmsInternalType . ($this->size != null ? '(' . $this->size . ')' : '') .
+ return $dbmsInternalType .
+ ($this->size !== null ? '(' . $this->size . ')' : '') .
+ ($this->charset !== null ? ' CHARACTER SET ' . $this->charset : '') .
($this->default !== null ? ' DEFAULT ' . (is_string($this->default) ? "'" : '') . $this->default . (is_string($this->default) ? "'" : '') : '') .
' ' . ($this->nullable ? 'NULL' : 'NOT NULL');
}