View | Details | Raw Unified | Return to bug 28786
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/two-fa.perl (-34 lines)
Lines 1-34 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
4
    $dbh->do(q{
5
        INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
6
        ('TwoFactorAuthentication', '0', 'NULL', 'Enables two-factor authentication', 'YesNo')
7
    });
8
9
    if( !column_exists( 'borrowers', 'secret' ) ) {
10
      $dbh->do(q{
11
          ALTER TABLE borrowers ADD COLUMN `secret` MEDIUMTEXT COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Secret for 2FA' AFTER `password`
12
      });
13
    }
14
15
    if( !column_exists( 'deletedborrowers', 'secret' ) ) {
16
      $dbh->do(q{
17
          ALTER TABLE deletedborrowers ADD COLUMN `secret` MEDIUMTEXT COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Secret for 2FA' AFTER `password`
18
        });
19
    }
20
21
    if( !column_exists( 'borrowers', 'auth_method' ) ) {
22
      $dbh->do(q{
23
          ALTER TABLE borrowers ADD COLUMN `auth_method` ENUM('password', 'two-factor') NOT NULL DEFAULT 'password' COMMENT 'Authentication method' AFTER `secret`
24
      });
25
    }
26
27
    if( !column_exists( 'deletedborrowers', 'auth_method' ) ) {
28
      $dbh->do(q{
29
          ALTER TABLE deletedborrowers ADD COLUMN `auth_method` ENUM('password', 'two-factor') NOT NULL DEFAULT 'password' COMMENT 'Authentication method' AFTER `secret`
30
      });
31
    }
32
33
    NewVersion( $DBversion, 28786, "Add new syspref TwoFactorAuthentication");
34
}
(-)a/installer/data/mysql/atomicupdate/two-fa.pl (-1 / +39 lines)
Line 0 Link Here
0
- 
1
use Modern::Perl;
2
3
return {
4
    bug_number => 28786,
5
    description => "Add syspref TwoFactorAuthentication, fields secret and auth_method",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
10
        $dbh->do(q{
11
            INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
12
            ('TwoFactorAuthentication', '0', 'NULL', 'Enables two-factor authentication', 'YesNo')
13
        });
14
15
        if( !column_exists( 'borrowers', 'secret' ) ) {
16
          $dbh->do(q{
17
              ALTER TABLE borrowers ADD COLUMN `secret` MEDIUMTEXT COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Secret for 2FA' AFTER `password`
18
          });
19
        }
20
21
        if( !column_exists( 'deletedborrowers', 'secret' ) ) {
22
          $dbh->do(q{
23
              ALTER TABLE deletedborrowers ADD COLUMN `secret` MEDIUMTEXT COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Secret for 2FA' AFTER `password`
24
            });
25
        }
26
27
        if( !column_exists( 'borrowers', 'auth_method' ) ) {
28
          $dbh->do(q{
29
              ALTER TABLE borrowers ADD COLUMN `auth_method` ENUM('password', 'two-factor') NOT NULL DEFAULT 'password' COMMENT 'Authentication method' AFTER `secret`
30
          });
31
        }
32
33
        if( !column_exists( 'deletedborrowers', 'auth_method' ) ) {
34
          $dbh->do(q{
35
              ALTER TABLE deletedborrowers ADD COLUMN `auth_method` ENUM('password', 'two-factor') NOT NULL DEFAULT 'password' COMMENT 'Authentication method' AFTER `secret`
36
          });
37
        }
38
    },
39
};

Return to bug 28786