Add multi-factor foreign keys to update_com.woltlab.wcf_5.4_db.php
authorTim Düsterhus <duesterhus@woltlab.com>
Mon, 23 Nov 2020 15:57:40 +0000 (16:57 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Mon, 23 Nov 2020 15:57:40 +0000 (16:57 +0100)
wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_db.php

index 48e76b5ce6bf720e89de9cf5bfdf8396e8d739c7..506c389907995ea7bc526f00e0046adef3c8aaaa 100644 (file)
@@ -10,6 +10,7 @@ use wcf\system\database\table\column\TextDatabaseTableColumn;
 use wcf\system\database\table\column\VarbinaryDatabaseTableColumn;
 use wcf\system\database\table\DatabaseTable;
 use wcf\system\database\table\DatabaseTableChangeProcessor;
+use wcf\system\database\table\index\DatabaseTableForeignKey;
 use wcf\system\database\table\index\DatabaseTableIndex;
 use wcf\system\database\table\index\DatabaseTablePrimaryIndex;
 use wcf\system\database\table\PartialDatabaseTable;
@@ -61,6 +62,18 @@ $tables = [
                        DatabaseTableIndex::create()
                                ->type(DatabaseTableIndex::UNIQUE_TYPE)
                                ->columns(['userID', 'objectTypeID']),
+               ])
+               ->foreignKeys([
+                       DatabaseTableForeignKey::create()
+                               ->columns(['userID'])
+                               ->referencedTable('wcf1_user')
+                               ->referencedColumns(['userID'])
+                               ->onDelete('CASCADE'),
+                       DatabaseTableForeignKey::create()
+                               ->columns(['objectTypeID'])
+                               ->referencedTable('wcf1_object_type')
+                               ->referencedColumns(['objectTypeID'])
+                               ->onDelete('CASCADE'),
                ]),
        
        DatabaseTable::create('wcf1_user_multifactor_backup')
@@ -77,6 +90,13 @@ $tables = [
                        DatabaseTableIndex::create()
                                ->type(DatabaseTableIndex::UNIQUE_TYPE)
                                ->columns(['setupID', 'identifier']),
+               ])
+               ->foreignKeys([
+                       DatabaseTableForeignKey::create()
+                               ->columns(['setupID'])
+                               ->referencedTable('wcf1_user_multifactor')
+                               ->referencedColumns(['setupID'])
+                               ->onDelete('CASCADE'),
                ]),
                
        DatabaseTable::create('wcf1_user_multifactor_email')
@@ -89,6 +109,13 @@ $tables = [
                        DatabaseTableIndex::create()
                                ->type(DatabaseTableIndex::UNIQUE_TYPE)
                                ->columns(['setupID', 'code']),
+               ])
+               ->foreignKeys([
+                       DatabaseTableForeignKey::create()
+                               ->columns(['setupID'])
+                               ->referencedTable('wcf1_user_multifactor')
+                               ->referencedColumns(['setupID'])
+                               ->onDelete('CASCADE'),
                ]),
        
        DatabaseTable::create('wcf1_user_multifactor_totp')
@@ -109,6 +136,13 @@ $tables = [
                        DatabaseTableIndex::create()
                                ->type(DatabaseTableIndex::UNIQUE_TYPE)
                                ->columns(['setupID', 'deviceID']),
+               ])
+               ->foreignKeys([
+                       DatabaseTableForeignKey::create()
+                               ->columns(['setupID'])
+                               ->referencedTable('wcf1_user_multifactor')
+                               ->referencedColumns(['setupID'])
+                               ->onDelete('CASCADE'),
                ]),
 ];