Bug 20402: Atomic update and kohastructure.sql fixes
authorTomas Cohen Arazi <tomascohen@theke.io>
Tue, 17 Apr 2018 19:23:36 +0000 (16:23 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 8 May 2018 18:55:43 +0000 (15:55 -0300)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

installer/data/mysql/atomicupdate/oauth_tokens.perl
installer/data/mysql/kohastructure.sql

index e22df6f..070aed2 100644 (file)
@@ -1,15 +1,17 @@
 $DBversion = 'XXX';
 if (CheckVersion($DBversion)) {
-    $dbh->do(q{DROP TABLE IF EXISTS oauth_access_tokens});
-    $dbh->do(q{
-        CREATE TABLE oauth_access_tokens (
-            access_token VARCHAR(255) NOT NULL,
-            client_id VARCHAR(255) NOT NULL,
-            expires INT NOT NULL,
-            PRIMARY KEY (access_token)
-        ) ENGINE=InnoDB DEFAULT CHARSET=utf8
-    });
+
+    if (!TableExists('oauth_access_tokens')) {
+        $dbh->do(q{
+            CREATE TABLE oauth_access_tokens (
+                `access_token` VARCHAR(191) NOT NULL,
+                `client_id`    VARCHAR(191) NOT NULL,
+                `expires`      INT NOT NULL,
+                PRIMARY KEY (`access_token`)
+            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
+        });
+    }
 
     SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug XXXXX - description)\n";
+    print "Upgrade to $DBversion done (Bug 20402 - Implement OAuth2 authentication for REST API)\n";
 }
index 4b770d0..ea59d03 100644 (file)
@@ -4161,6 +4161,18 @@ CREATE TABLE library_groups (
     UNIQUE KEY title ( title )
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
+--
+-- Table structure for table 'oauth_access_tokens'
+--
+
+DROP TABLE IF EXISTS `oauth_access_tokens`;
+CREATE TABLE `oauth_access_tokens` (
+    `access_token` VARCHAR(191) NOT NULL, -- generarated access token
+    `client_id`    VARCHAR(191) NOT NULL, -- the client id the access token belongs to
+    `expires`      INT NOT NULL,          -- expiration time in seconds
+    PRIMARY KEY (`access_token`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
 /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
 /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
 /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;