diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2021-09-04 14:47:03 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2021-09-04 14:47:03 +0200 |
commit | 64f4141378ea6fb524df015abdef5393d8d589bb (patch) | |
tree | 50c73458c20615e7e4c319d0fd22777d3f01516d | |
parent | 82fff1107a46f9cdaab589e619b03a3c76431c4f (diff) | |
download | gigologadmin-64f4141378ea6fb524df015abdef5393d8d589bb.tar.gz gigologadmin-64f4141378ea6fb524df015abdef5393d8d589bb.tar.bz2 gigologadmin-64f4141378ea6fb524df015abdef5393d8d589bb.zip |
Add timestamp columns to concerts and venues.
To keep track of creation and modification times for each record.
-rw-r--r-- | includes/admin/register_db_tables.php | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/includes/admin/register_db_tables.php b/includes/admin/register_db_tables.php index 64123d9..8c6dc98 100644 --- a/includes/admin/register_db_tables.php +++ b/includes/admin/register_db_tables.php @@ -260,7 +260,7 @@ if ( !function_exists( "giglog_register_db_tables") ) function giglog_register_db_tables() { $db_version = get_option('giglogadmin_db_version'); - if ($db_version == 6) { + if ($db_version == 8) { return; } @@ -459,7 +459,22 @@ if ( !function_exists( "giglog_register_db_tables") ) wpgconcert_roles JSON CHECK (JSON_VALID(wpgconcert_roles)))"); } - update_option("giglogadmin_db_version", 6); + if ($db_version == NULL || $db_version < 8) + { + // Add automatically updated `created` and `updated` colomns to keep + // track of creation time and modification times for a record. + $wpdb->query( + "ALTER TABLE `wpg_concerts` ADD COLUMN IF NOT ExISTS ( + created TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP)"); + + $wpdb->query( + "ALTER TABLE `wpg_venues` ADD COLUMN IF NOT ExISTS ( + created TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP)"); + } + + update_option("giglogadmin_db_version", 8); } giglog_register_db_tables(); |