mirror of
https://github.com/e107inc/e107.git
synced 2025-01-18 05:09:05 +01:00
Merge pull request #3191 from SimSync/_blank_setup
Blank SQL + Setup Documentation
This commit is contained in:
commit
42f63a3be0
@ -78,6 +78,96 @@ if(!class_exists("_blank_setup"))
|
||||
// print_a($var);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Call During Upgrade Check. May be used to check for existance of tables etc and if not found return TRUE to call for an upgrade.
|
||||
*
|
||||
* @return bool true = upgrade required; false = upgrade not required
|
||||
*/
|
||||
function upgrade_required()
|
||||
{
|
||||
// Check if a specific table exists and if not, return true to force a db update
|
||||
// In this example, it checks if the table "blank_table" exists
|
||||
// if(!e107::getDb()->isTable('blank_table'))
|
||||
// {
|
||||
// return true; // true to trigger an upgrade alert, and false to not.
|
||||
// }
|
||||
|
||||
|
||||
// Check if a specific field exists in the specified table
|
||||
// and if not return false to force a db update to add this field
|
||||
// from the "_blank_sql.php" file
|
||||
// In this case: Exists field "blank_id" in table "blank_table"
|
||||
// if(!e107::getDb()->field('blank_table','blank_id'))
|
||||
// {
|
||||
// return true; // true to trigger an upgrade alert, and false to not.
|
||||
// }
|
||||
|
||||
|
||||
// In case you need to delete a field that is not used anymore,
|
||||
// first check if the field exists, than run a sql command to drop (delete) the field
|
||||
// !!! ATTENTION !!!
|
||||
// !!! Deleting a field, deletes also the data stored in that field !!!
|
||||
// !!! Make sure you know what you are doing !!!
|
||||
//
|
||||
// In this example, the field "blank_unused_field" from table "blank_table"
|
||||
// isn't used anymore and will be deleted (dropped) if it still exists
|
||||
// if(e107::getDb()->field('blank_table', 'blank_unused_field'))
|
||||
// {
|
||||
// this statement directly deletes the field, an additional
|
||||
// db update isn't needed anymore, if this is the only change on the db/table.
|
||||
// e107::getDb()->gen("ALTER TABLE `#blank_table` DROP `blank_unused_field` ");
|
||||
// }
|
||||
|
||||
|
||||
// In case you need to delete a index that is not used anymore,
|
||||
// first check if the index exists, than run a sql command to drop (delete) the field
|
||||
// Be aware, that deleting an index is not very harmfull, as the data of the
|
||||
// index will be recreated when the index is added again.
|
||||
// if(e107::getDb()->index('blank_table','blank_unused_index'))
|
||||
// {
|
||||
// this statement directly deletes the index, an additional
|
||||
// db update isn't needed anymore, if this is the only change on the db/table.
|
||||
// e107::getDb()->gen("ALTER TABLE `#blank_table` DROP INDEX `blank_unused_index` ");
|
||||
// }
|
||||
|
||||
// In case you need to check an index and which fields it is build of,
|
||||
// use the fourth parameter to return the index definition.
|
||||
// In this case, the index should be deleted if consists only of 1 field ("blank_fieldname"),
|
||||
// if(e107::getDb()->index('blank_table','blank_unused_index', array('blank_fieldname')))
|
||||
// {
|
||||
// this statement directly deletes the index, an additional
|
||||
// db update isn't needed anymore, if this is the only change on the db/table.
|
||||
// e107::getDb()->gen("ALTER TABLE `#blank_table` DROP INDEX `blank_unused_index` ");
|
||||
// }
|
||||
|
||||
|
||||
// In case you need to check an index and which fields it is build of,
|
||||
// use the third parameter to return the index definition.
|
||||
// In this case, the index should be deleted if consists only of 1 field ("blank_fieldname"),
|
||||
// if ($index_def = e107::getDb()->index('blank_table','blank_unused_index', array('blank_fieldname')))
|
||||
// {
|
||||
// Check if the key should be UNIQUE
|
||||
// $unique = array_count_values(array_column($index_def, 'Non_unique'));
|
||||
// if($unique[1] > 0) // Keys are not unique
|
||||
// {
|
||||
// this statement directly deletes the index, an additional
|
||||
// db update isn't needed anymore, if this is the only change on the db/table.
|
||||
// e107::getDb()->gen("ALTER TABLE `#blank_table` DROP INDEX `blank_unused_index` ");
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
$legacyMenuPref = e107::getConfig('menu')->getPref();
|
||||
if(isset($legacyMenuPref['newforumposts_caption']))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function upgrade_post($var)
|
||||
{
|
||||
// $sql = e107::getDb();
|
||||
|
@ -1,3 +1,48 @@
|
||||
/**
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2013 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* INFORMATION
|
||||
*
|
||||
* BEFORE DOING ANY DATABASE CHANGES OR UPDATES, CREATE A FRESH BACKUP!!!
|
||||
*
|
||||
* Add the SQL statements for your table here.
|
||||
* Make sure that you do not add the e107 table prefix (by default e107) to the table name!!
|
||||
* This file will be analyzed on plugin install and missing tables will be installed automatically.
|
||||
* To check if the table structure is still valid, run the "Tools -> Database -> Check for Updates" command.
|
||||
* Any differences between the defined structure here and the table structure on the server will than be detected.
|
||||
* In another step, you are able to update the table structure to the latest version from this file!
|
||||
*
|
||||
*
|
||||
* For the moment, the following operations are supported:
|
||||
* -------------------------------------------------------
|
||||
* - Create table
|
||||
* - Change field type, field size, field null or not, field default value
|
||||
* - Add index
|
||||
*
|
||||
*
|
||||
* What is currently NOT supported:
|
||||
* --------------------------------
|
||||
* - Rename table (by renaming the tablename, e.g. "blank" > "blank2"). The renamed table will be considered as new!
|
||||
* - Drop a table (e.g. if you remove the "blank" table definition from this file, the table will NOT be deleted from the database!)
|
||||
* - Rename or drop a field (a renamed field will be considered new, a missing field definition will NOT be recognized at all!)
|
||||
* - Change an index/key (e.g. the change is recognized, but leads to an error message and the change is not applied)
|
||||
* - Rename or drop an index/key (Rename is recognized as a new index and the missing index is not recognized at all!)
|
||||
* - A field definition containing "NULL DEFAULT NULL". The "Check for updates" method will always detect a change,
|
||||
* but fails silently when trying to update. In that case remove the first "NULL" and run the the "Check for updates" again.
|
||||
*
|
||||
*
|
||||
* How to rename or drop tables, fields and indexes or modify indexes:
|
||||
* -------------------------------------------------------------------
|
||||
* There are methods that can be used to detect tables, fields and indexes. Some examples of how to use them
|
||||
* can be found in the "_blank_setup.php". There are also examples on how to drop a field or index or to check for specific properties.
|
||||
* Other examples can be found also in the "forum_setup.php"
|
||||
*/
|
||||
|
||||
|
||||
CREATE TABLE blank (
|
||||
`blank_id` int(10) NOT NULL AUTO_INCREMENT,
|
||||
`blank_icon` varchar(255) NOT NULL,
|
||||
|
Loading…
x
Reference in New Issue
Block a user