I'm working on a custom wordpress plugin, but I can't seem to figure out how to create the database when installing the plugin. (Or when updating)
When searching around this is what I came up with, but this doesn't seem to do anything.
function to_install() {
global $wpdb;
$sql = "CREATE TABLE to_issues (
id int(11) NOT NULL AUTO_INCREMENT,
name varchar(125) NOT NULL
);";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
add_option('to_db_version', TO_VERSION);
}
function to_install_data() {
global $wpdb;
$welcome_name = "Hello";
$welcom_text = "Install successfull";
}
register_activation_hook(__FILE__, 'to_install');
register_activation_hook(__FILE__, 'to_install_data');
On a side note, when updating the plugin, will this reinstall all the tables? Or will wordpress handle this correctly?