[DATABASE] Re-order tables to be created

Foreign keys need to be created after the respective tables are already in
place. This order makes sure this is the case.
This commit is contained in:
Alexei Sorokin 2019-09-11 11:56:36 +03:00 committed by Diogo Peralta Cordeiro
parent 3f17a0efea
commit bc97f34f5a
1 changed files with 75 additions and 58 deletions

View File

@ -1,4 +1,18 @@
<?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// GNU social is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
/**
*
@ -25,64 +39,67 @@
* double-check what we've been doing on postgres?
*/
$classes = array('Schema_version',
'Profile',
'Avatar',
'Sms_carrier',
'User',
'Subscription',
'Group_join_queue',
'Subscription_queue',
'Oauth_token_association',
'Notice',
'Notice_location',
'Notice_source',
'Notice_prefs',
'Reply',
'Consumer',
'Token',
'Nonce',
'Oauth_application',
'Oauth_application_user',
'Confirm_address',
'Remember_me',
'Queue_item',
'Notice_tag',
'Foreign_service',
'Foreign_user',
'Foreign_link',
'Foreign_subscription',
'Invitation',
'Profile_prefs',
'Profile_tag',
'Profile_list',
'Profile_tag_subscription',
'Profile_block',
'User_group',
'Related_group',
'Group_inbox',
'Group_member',
'File',
'File_redirection',
'File_thumbnail',
'File_to_post',
'Group_block',
'Group_alias',
'Session',
'Config',
'Profile_role',
'Location_namespace',
'Login_token',
'User_location_prefs',
'User_im_prefs',
'Conversation',
'Local_group',
'User_urlshortener_prefs',
'Old_school_prefs',
'User_username',
'Attention',
);
defined('GNUSOCIAL') || die();
$classes = [
'Schema_version',
'Profile',
'Avatar',
'Sms_carrier',
'User',
'User_group',
'Subscription',
'Group_join_queue',
'Subscription_queue',
'Consumer',
'Oauth_application',
'Oauth_token_association',
'Conversation',
'Notice',
'Notice_location',
'Notice_source',
'Notice_prefs',
'Reply',
'Token',
'Nonce',
'Oauth_application_user',
'Confirm_address',
'Remember_me',
'Queue_item',
'Notice_tag',
'Foreign_service',
'Foreign_user',
'Foreign_link',
'Foreign_subscription',
'Invitation',
'Profile_prefs',
'Profile_list',
'Profile_tag',
'Profile_tag_subscription',
'Profile_block',
'Related_group',
'Group_inbox',
'Group_member',
'File',
'File_redirection',
'File_thumbnail',
'File_to_post',
'Group_block',
'Group_alias',
'Session',
'Config',
'Profile_role',
'Location_namespace',
'Login_token',
'User_location_prefs',
'User_im_prefs',
'Local_group',
'User_urlshortener_prefs',
'Old_school_prefs',
'User_username',
'Attention'
];
foreach ($classes as $cls) {
$schema[strtolower($cls)] = call_user_func(array($cls, 'schemaDef'));
$schema[strtolower($cls)] = call_user_func([$cls, 'schemaDef']);
}