Created
November 15, 2012 17:53
-
-
Save tarolandia/4080087 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$con = mysql_connect("web02.sjc.netdna.com", "devel", "n3tdn@"); | |
if (!$con) die('Could not connect: ' . mysql_error()); | |
mysql_select_db("clients_test", $con); | |
// MUST Consider 100TB packages | |
// Default settings for all packages are placed into package_features | |
// - max_zones, bandwidth, storage, initial credits (SSL, Flex, Secure, Full Site, etc) | |
// Available additions for all packages are placed into package_addons | |
// - additional credits (SSL, Flex, Secure, Full Site, etc), | |
// should add a description column to package_features - at least for internal knowledge (different types of ssl could be confusing) | |
// would love to go through packages table and remove any unused packages - also convert customers with rarer packages to something more standard | |
// update bandwidth amounts to be in base 1024 not 1000 | |
mysql_query("UPDATE clients_test.packages SET bandwidth=549755813888 WHERE id=262;"); | |
mysql_query("UPDATE clients_test.packages SET bandwidth=1099511627776 WHERE id=263;"); | |
mysql_query("UPDATE clients_test.packages SET bandwidth=5497558138880 WHERE id=264;"); | |
mysql_query("UPDATE clients_test.packages SET bandwidth=10995116277760 WHERE id=265;"); | |
mysql_query("UPDATE clients_test.packages SET bandwidth=27487790694400 WHERE id=266;"); | |
// udpate billing_cycles table | |
mysql_query("UPDATE clients_test.billing_cycles SET name='Annually' WHERE id=5;"); | |
mysql_query("INSERT INTO clients_test.billing_cycles VALUES ('', 'Biannually');"); | |
//retrieve current package information | |
$packages = mysql_query("SELECT * FROM clients_test.packages"); | |
//loop through packages | |
while($row = mysql_fetch_array($packages)) | |
{ | |
// handle NetDNA separately | |
if($row['brand_id'] == 1) { | |
mysql_query("INSERT INTO clients_test.package_features VALUES ('', {$row['id']}, 'max_zones', -1), | |
('', {$row['id']}, 'bandwidth', 0), | |
('', {$row['id']}, 'seo_enabled', 1), | |
('', {$row['id']}, 'ssl_enabled', 1), | |
('', {$row['id']}, 'geo_enabled', 1), | |
('', {$row['id']}, 'ssl_credits', -1), | |
('', {$row['id']}, 'rules_enabled', 1); | |
"); | |
} else { | |
// insert bandwidth and max_zones features | |
if(in_array($row['id'], array(262, 263, 264, 265, 266))) { | |
// set MaxCDN recurring values to settings in packages table | |
mysql_query("INSERT INTO clients_test.package_features VALUES ('', {$row['id']}, 'max_zones', {$row['max_pull_zones']}), | |
('', {$row['id']}, 'bandwidth', {$row['bandwidth']}), | |
('', {$row['id']}, 'storage', -1);" | |
); | |
} else if($row['brand_id'] == HDDN || $row['brand_id'] == CloudCache) { | |
mysql_query("INSERT INTO clients_test.package_features VALUES ('', {$row['id']}, 'max_zones', -1), | |
('', {$row['id']}, 'bandwidth', 0), | |
('', {$row['id']}, 'storage', {$row['storage']});" | |
); | |
} else { | |
// set remaining packages to unlimited | |
mysql_query("INSERT INTO clients_test.package_features VALUES ('', {$row['id']}, 'max_zones', -1), | |
('', {$row['id']}, 'bandwidth', 0), | |
('', {$row['id']}, 'storage', -1);" | |
); | |
} | |
// insert seo_enabled & ssl_enabled features | |
if(in_array($row['id'], array(263, 264, 265, 266))) { | |
// enable ssl addon & seo for MaxCDN recurring (except 500GB) | |
mysql_query("INSERT INTO clients_test.package_features VALUES ('', {$row['id']}, 'seo_enabled', 1), | |
('', {$row['id']}, 'ssl_enabled', 1);" | |
); | |
} else if(in_array($row['id']), array()) { // add package ids for HDDN enterprise & permium packages | |
// insert ssl_enabled (& seo_enabled?) where applicable | |
} else { | |
// disable ssl addon & seo for remaining packages | |
mysql_query("INSERT INTO clients_test.package_features VALUES ('', {$row['id']}, 'seo_enabled', 0), | |
('', {$row['id']}, 'ssl_enabled', 0);" | |
); | |
} | |
// insert geo_enabled & ssl_credits features | |
if(in_array($row['id'], array(264, 265, 266))) { | |
// enable flex | |
mysql_query("INSERT INTO clients_test.package_features VALUES ('', {$row['id']}, 'geo_enabled', 1), | |
('', {$row['id']}, 'ssl_credits', 1);" | |
); | |
} else if(in_array($row['id']), array()) { // add package ids for HDDN enterprise & permium packages | |
// insert ssl_credits where applicable | |
} else { | |
mysql_query("INSERT INTO clients_test.package_features VALUES ('', {$row['id']}, 'geo_enabled', 0), | |
('', {$row['id']}, 'ssl_credits', 0);" | |
); | |
} | |
if(in_array($row['id'], array(265, 266))) { | |
mysql_query("INSERT INTO clients_test.package_features VALUES ('', {$row['id']}, 'rules_enabled', 1);"); | |
} else { | |
mysql_query("INSERT INTO clients_test.package_features VALUES ('', {$row['id']}, 'rules_enabled', 0);"); | |
} | |
// insert feature records for API Access Level | |
// mysql_query("INSERT INTO clients_test.package_addons VALUES ('', {$row['id']}, 'ssl', 'EdgeSSL', '39.00', 0, 3, 1), ('', {$row['id']}, 'flex', 'Asia Network', '39.00', 0, 3, 1), ('', {$row['id']}, 'ssl', 'EdgeSSL', '39.00', 0, 3, 1);"); | |
} | |
} | |
mysql_close($con); | |
///// NOTES: ///// | |
// need to move pricing / billing information from packages table to package_pricing table | |
// need to consider secure tokens accross brands and zone types | |
// need to consider that PAYG MAXCDN will remain indefinitely (only for existing customers) | |
// storage will be handled outside of packages for the time being | |
// mysql_query("INSERT INTO clients_test.package_features VALUES ('', {$row['id']}, 'storage', {$row['storage']});"); | |
///// Queries to run once CP2 is dropped ///// | |
// ALTER TABLE clients_test.companies DROP COLUMN max_pull_zones, DROP COLUMN max_push_zones, DROP COLUMN max_vod_zones, DROP COLUMN max_live_zones, DROP COLUMN max_secure_zones, DROP COLUMN bandwidth, DROP COLUMN storage, DROP COLUMN price, DROP COLUMN setup, DROP COLUMN price_monthly, DROP COLUMN price_quarterly, DROP COLUMN price_annually, DROP COLUMN price_biannually; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment