[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

View File

@ -1,4 +1,18 @@
<?php <?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? * double-check what we've been doing on postgres?
*/ */
$classes = array('Schema_version', defined('GNUSOCIAL') || die();
'Profile',
'Avatar', $classes = [
'Sms_carrier', 'Schema_version',
'User', 'Profile',
'Subscription', 'Avatar',
'Group_join_queue', 'Sms_carrier',
'Subscription_queue', 'User',
'Oauth_token_association', 'User_group',
'Notice', 'Subscription',
'Notice_location', 'Group_join_queue',
'Notice_source', 'Subscription_queue',
'Notice_prefs', 'Consumer',
'Reply', 'Oauth_application',
'Consumer', 'Oauth_token_association',
'Token', 'Conversation',
'Nonce', 'Notice',
'Oauth_application', 'Notice_location',
'Oauth_application_user', 'Notice_source',
'Confirm_address', 'Notice_prefs',
'Remember_me', 'Reply',
'Queue_item', 'Token',
'Notice_tag', 'Nonce',
'Foreign_service', 'Oauth_application_user',
'Foreign_user', 'Confirm_address',
'Foreign_link', 'Remember_me',
'Foreign_subscription', 'Queue_item',
'Invitation', 'Notice_tag',
'Profile_prefs', 'Foreign_service',
'Profile_tag', 'Foreign_user',
'Profile_list', 'Foreign_link',
'Profile_tag_subscription', 'Foreign_subscription',
'Profile_block', 'Invitation',
'User_group', 'Profile_prefs',
'Related_group', 'Profile_list',
'Group_inbox', 'Profile_tag',
'Group_member', 'Profile_tag_subscription',
'File', 'Profile_block',
'File_redirection', 'Related_group',
'File_thumbnail', 'Group_inbox',
'File_to_post', 'Group_member',
'Group_block', 'File',
'Group_alias', 'File_redirection',
'Session', 'File_thumbnail',
'Config', 'File_to_post',
'Profile_role', 'Group_block',
'Location_namespace', 'Group_alias',
'Login_token', 'Session',
'User_location_prefs', 'Config',
'User_im_prefs', 'Profile_role',
'Conversation', 'Location_namespace',
'Local_group', 'Login_token',
'User_urlshortener_prefs', 'User_location_prefs',
'Old_school_prefs', 'User_im_prefs',
'User_username', 'Local_group',
'Attention', 'User_urlshortener_prefs',
); 'Old_school_prefs',
'User_username',
'Attention'
];
foreach ($classes as $cls) { foreach ($classes as $cls) {
$schema[strtolower($cls)] = call_user_func(array($cls, 'schemaDef')); $schema[strtolower($cls)] = call_user_func([$cls, 'schemaDef']);
} }