summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2021-04-01 19:33:02 +0200
committerHarald Eilertsen <haraldei@anduin.net>2021-04-01 19:33:02 +0200
commit0c703ce2cfdbc97c74b57c0d0b5f9f60d0487a2b (patch)
tree5fd4a65dbc1bdb07b472c820153d60f83aae84ba
parentfe57b461edbdcb5173c1b3096a7936a89ebc250f (diff)
downloadgigologadmin-0c703ce2cfdbc97c74b57c0d0b5f9f60d0487a2b.tar.gz
gigologadmin-0c703ce2cfdbc97c74b57c0d0b5f9f60d0487a2b.tar.bz2
gigologadmin-0c703ce2cfdbc97c74b57c0d0b5f9f60d0487a2b.zip
Populate the pressstatus table on activation.
Was missing in the first import. This looks like pure static data, though, and will probably be moved to constants in the code instead. While this doesn't really change the db schema, the db version was incremented to version 2, to make sure the new data is added, even if the db is already initialized.
-rw-r--r--includes/admin/register_db_tables.php83
1 files changed, 50 insertions, 33 deletions
diff --git a/includes/admin/register_db_tables.php b/includes/admin/register_db_tables.php
index a54e2c8..9cff614 100644
--- a/includes/admin/register_db_tables.php
+++ b/includes/admin/register_db_tables.php
@@ -247,13 +247,15 @@ if (!function_exists('giglogadmin_populate_countries')) {
}
}
-if ( !function_exists( "giglog_register_db_tables") ) {
- $db_version = get_option('giglogadmin_db_version');
- if ($db_version == 1) {
- return;
- }
+if ( !function_exists( "giglog_register_db_tables") )
+{
+ function giglog_register_db_tables()
+ {
+ $db_version = get_option('giglogadmin_db_version');
+ if ($db_version == 2) {
+ return;
+ }
- function giglog_register_db_tables() {
$bands_table =
"CREATE TABLE IF NOT EXISTS `wpg_bands` (
`id` int(11) NOT NULL AUTO_INCREMENT,
@@ -358,38 +360,53 @@ if ( !function_exists( "giglog_register_db_tables") ) {
}
}
- giglogadmin_populate_countries();
+ if ($db_version == NULL || $db_version < 1)
+ {
+ giglogadmin_populate_countries();
- $wpdb->query(
- "ALTER TABLE `wpg_countries`
- ADD FULLTEXT KEY `id`
- (`id`,`wpgc_fullname`,`wpgcountry_name`,`wpgc_iso3`,`wpgc_numcode`);");
+ $wpdb->query(
+ "ALTER TABLE `wpg_countries`
+ ADD FULLTEXT KEY `id`
+ (`id`,`wpgc_fullname`,`wpgcountry_name`,`wpgc_iso3`,`wpgc_numcode`);");
- $wpdb->query(
- "ALTER TABLE `wpg_bands`
- ADD CONSTRAINT `wpgband_country`
- FOREIGN KEY (`wpgband_country`)
- REFERENCES `wpg_countries` (`id`) ON DELETE NO ACTION;");
+ $wpdb->query(
+ "ALTER TABLE `wpg_bands`
+ ADD CONSTRAINT `wpgband_country`
+ FOREIGN KEY (`wpgband_country`)
+ REFERENCES `wpg_countries` (`id`) ON DELETE NO ACTION;");
- $wpdb->query(
- "ALTER TABLE `wpg_concertlogs`
- ADD CONSTRAINT `wpglog_concerts`
- FOREIGN KEY (`wpgcl_concertid`)
- REFERENCES `wpg_concerts` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
- ADD CONSTRAINT `wpglog_status`
- FOREIGN KEY (`wpgcl_status`)
- REFERENCES `wpg_pressstatus` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;");
+ $wpdb->query(
+ "ALTER TABLE `wpg_concertlogs`
+ ADD CONSTRAINT `wpglog_concerts`
+ FOREIGN KEY (`wpgcl_concertid`)
+ REFERENCES `wpg_concerts` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
+ ADD CONSTRAINT `wpglog_status`
+ FOREIGN KEY (`wpgcl_status`)
+ REFERENCES `wpg_pressstatus` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;");
- $wpdb->query(
- "ALTER TABLE `wpg_concerts`
- ADD CONSTRAINT `wpgconcert_band`
- FOREIGN KEY (`band`)
- REFERENCES `wpg_bands` (`id`) ON DELETE NO ACTION,
- ADD CONSTRAINT `wpgconcert_venue`
- FOREIGN KEY (`venue`)
- REFERENCES `wpg_venues` (`id`) ON DELETE NO ACTION;");
+ $wpdb->query(
+ "ALTER TABLE `wpg_concerts`
+ ADD CONSTRAINT `wpgconcert_band`
+ FOREIGN KEY (`band`)
+ REFERENCES `wpg_bands` (`id`) ON DELETE NO ACTION,
+ ADD CONSTRAINT `wpgconcert_venue`
+ FOREIGN KEY (`venue`)
+ REFERENCES `wpg_venues` (`id`) ON DELETE NO ACTION;");
+ }
+
+ if ($db_version == NULL || $db_version < 2)
+ {
+ $wpdb->query(
+ "INSERT INTO `wpg_pressstatus` (`id`, `wpgs_name`) VALUES
+ (1, ' '),
+ (2, 'Accred Requested'),
+ (3, 'Photo Approved'),
+ (4, 'Text Approved'),
+ (5, 'Photo and Text approved'),
+ (6, 'Rejected');");
+ }
- update_option("giglogadmin_db_version", 1);
+ update_option("giglogadmin_db_version", 2);
}
giglog_register_db_tables();