summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--admin/schema_inc.php1
-rw-r--r--admin/upgrades/5.0.1.php38
2 files changed, 39 insertions, 0 deletions
diff --git a/admin/schema_inc.php b/admin/schema_inc.php
index 5c26b67..3882248 100644
--- a/admin/schema_inc.php
+++ b/admin/schema_inc.php
@@ -43,6 +43,7 @@ $tables = [
user_id I4 PRIMARY,
provider C(64) PRIMARY,
provider_identifier C(64) NOTNULL,
+
last_login I8,
profile_json X
",
diff --git a/admin/upgrades/5.0.1.php b/admin/upgrades/5.0.1.php
new file mode 100644
index 0000000..d4bcbde
--- /dev/null
+++ b/admin/upgrades/5.0.1.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * @package users
+ */
+
+global $gBitInstaller;
+
+$gBitInstaller->registerPackageUpgrade(
+ [
+ 'package' => USERS_PKG_NAME,
+ 'version' => '5.0.1',
+ 'description' => 'Add users_auth_map table for OAuth/external authentication provider support.',
+ ],
+ [
+ [ 'DATADICT' => [
+ [ 'CREATE' => [
+ 'users_auth_map' => "
+ user_id I4 PRIMARY,
+ provider C(64) PRIMARY,
+ provider_identifier C(64) NOTNULL,
+ last_login I8,
+ profile_json X
+ ",
+ ]],
+ [ 'CREATEINDEX' => [
+ 'users_auth_user_idx' => [ 'users_auth_map', 'user_id', null ],
+ 'users_auth_provider_ident_idx' => [ 'users_auth_map', 'provider,provider_identifier', [ 'UNIQUE' ] ],
+ ]],
+ ]],
+ ]
+);
+
+$constraints = [
+ 'users_auth_map' => [ 'users_auth_user_ref' => 'FOREIGN KEY (`user_id`) REFERENCES `' . BIT_DB_PREFIX . 'users_users` (`user_id`)' ],
+];
+foreach( array_keys( $constraints ) as $tableName ) {
+ $gBitInstaller->registerSchemaConstraints( USERS_PKG_NAME, $tableName, $constraints[$tableName] );
+}