Skip to content

Commit

Permalink
Merge pull request filsh#98 from ruslanbes/patch-1
Browse files Browse the repository at this point in the history
Fix for migration error [Issue 45]
  • Loading branch information
filsh authored Dec 21, 2016
2 parents ae91739 + 54a1d41 commit 830ffa2
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions migrations/m140501_075311_add_oauth2_server.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ public function mysql($yes,$no='') {
return $this->db->driverName === 'mysql' ? $yes : $no;
}

public function primaryKey($columns) {
public function primaryKeyDefinition($columns) {
return 'PRIMARY KEY (' . $this->db->getQueryBuilder()->buildColumns($columns) . ')';
}

public function foreignKey($columns,$refTable,$refColumns,$onDelete = null,$onUpdate = null) {
public function foreignKeyDefinition($columns,$refTable,$refColumns,$onDelete = null,$onUpdate = null) {
$builder = $this->db->getQueryBuilder();
$sql = ' FOREIGN KEY (' . $builder->buildColumns($columns) . ')'
. ' REFERENCES ' . $this->db->quoteTableName($refTable)
Expand Down Expand Up @@ -46,7 +46,7 @@ public function up()
'grant_types' => Schema::TYPE_STRING . '(100) NOT NULL',
'scope' => Schema::TYPE_STRING . '(2000) DEFAULT NULL',
'user_id' => Schema::TYPE_INTEGER . ' DEFAULT NULL',
$this->primaryKey('client_id'),
$this->primaryKeyDefinition('client_id'),
], $tableOptions);

$this->createTable('{{%oauth_access_tokens}}', [
Expand All @@ -55,8 +55,8 @@ public function up()
'user_id' => Schema::TYPE_INTEGER . ' DEFAULT NULL',
'expires' => Schema::TYPE_TIMESTAMP . " NOT NULL DEFAULT $now $on_update_now",
'scope' => Schema::TYPE_STRING . '(2000) DEFAULT NULL',
$this->primaryKey('access_token'),
$this->foreignKey('client_id','{{%oauth_clients}}','client_id','CASCADE','CASCADE'),
$this->primaryKeyDefinition('access_token'),
$this->foreignKeyDefinition('client_id','{{%oauth_clients}}','client_id','CASCADE','CASCADE'),
], $tableOptions);

$this->createTable('{{%oauth_refresh_tokens}}', [
Expand All @@ -65,8 +65,8 @@ public function up()
'user_id' => Schema::TYPE_INTEGER . ' DEFAULT NULL',
'expires' => Schema::TYPE_TIMESTAMP . " NOT NULL DEFAULT $now $on_update_now",
'scope' => Schema::TYPE_STRING . '(2000) DEFAULT NULL',
$this->primaryKey('refresh_token'),
$this->foreignKey('client_id','{{%oauth_clients}}','client_id','CASCADE','CASCADE'),
$this->primaryKeyDefinition('refresh_token'),
$this->foreignKeyDefinition('client_id','{{%oauth_clients}}','client_id','CASCADE','CASCADE'),
], $tableOptions);

$this->createTable('{{%oauth_authorization_codes}}', [
Expand All @@ -76,8 +76,8 @@ public function up()
'redirect_uri' => Schema::TYPE_STRING . '(1000) NOT NULL',
'expires' => Schema::TYPE_TIMESTAMP . " NOT NULL DEFAULT $now $on_update_now",
'scope' => Schema::TYPE_STRING . '(2000) DEFAULT NULL',
$this->primaryKey('authorization_code'),
$this->foreignKey('client_id','{{%oauth_clients}}','client_id','CASCADE','CASCADE'),
$this->primaryKeyDefinition('authorization_code'),
$this->foreignKeyDefinition('client_id','{{%oauth_clients}}','client_id','CASCADE','CASCADE'),
], $tableOptions);

$this->createTable('{{%oauth_scopes}}', [
Expand All @@ -89,15 +89,15 @@ public function up()
'client_id' => Schema::TYPE_STRING . '(32) NOT NULL',
'subject' => Schema::TYPE_STRING . '(80) DEFAULT NULL',
'public_key' => Schema::TYPE_STRING . '(2000) DEFAULT NULL',
$this->primaryKey('client_id'),
$this->primaryKeyDefinition('client_id'),
], $tableOptions);

$this->createTable('{{%oauth_users}}', [
'username' => Schema::TYPE_STRING . '(255) NOT NULL',
'password' => Schema::TYPE_STRING . '(2000) DEFAULT NULL',
'first_name' => Schema::TYPE_STRING . '(255) DEFAULT NULL',
'last_name' => Schema::TYPE_STRING . '(255) DEFAULT NULL',
$this->primaryKey('username'),
$this->primaryKeyDefinition('username'),
], $tableOptions);

$this->createTable('{{%oauth_public_keys}}', [
Expand Down

0 comments on commit 830ffa2

Please sign in to comment.