Skip to content

Instantly share code, notes, and snippets.

@BytesCrafter
Created July 20, 2020 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BytesCrafter/6550dbbfdb811adcfd3ce3b3d9442453 to your computer and use it in GitHub Desktop.
Save BytesCrafter/6550dbbfdb811adcfd3ce3b3d9442453 to your computer and use it in GitHub Desktop.
function dbhook_activate() {
global $wpdb;
// #region CREATING TABLE FOR Clusters
$usn_cluster_tab = USN_CLUSTER_TAB;
if($wpdb->get_var( "SHOW TABLES LIKE '$usn_cluster_tab'" ) != $usn_cluster_tab) {
$sql = "CREATE TABLE `".$usn_cluster_tab."` (";
$sql .= "`ID` bigint(20) NOT NULL AUTO_INCREMENT, ";
$sql .= "`cluster_name` varchar(120) NOT NULL, ";
$sql .= "`cluster_info` varchar(255) NOT NULL, ";
$sql .= "`cluster_owner` bigint(20) NOT NULL, ";
$sql .= "`cluster_hostname` varchar(120) NOT NULL, ";
$sql .= "`cluster_secretkey` varchar(120) NOT NULL, ";
$sql .= "`cluster_capacity` int(12) NOT NULL DEFAULT '1000', ";
$sql .= "`date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, ";
$sql .= "PRIMARY KEY (`ID`), ";
$sql .= "UNIQUE (`cluster_name`) ";
$sql .= ") ENGINE = InnoDB; ";
$result = $wpdb->get_results($sql);
}
// #endregion
}
add_action( 'activated_plugin', 'dbhook_activate' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment