From 5c0d96cc7cd1b4b477f264d7dec73c652d3b4490 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 16 Jan 2021 21:42:34 +0100 Subject: Skip setting up db if db version is ok. Introduces a database schema version which we store in the wordpress options table. We could just use a flag, but if the schema ever will change, it will be good to have it versioned. --- includes/admin/register_db_tables.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'includes/admin/register_db_tables.php') diff --git a/includes/admin/register_db_tables.php b/includes/admin/register_db_tables.php index 2c41771..c6d40f5 100644 --- a/includes/admin/register_db_tables.php +++ b/includes/admin/register_db_tables.php @@ -248,6 +248,11 @@ if (!function_exists('gigologadmin_populate_countries')) { } if ( !function_exists( "gigolog_register_db_tables") ) { + $db_version = get_option('gigologadmin_db_version'); + if ($db_version == 1) { + return; + } + function gigolog_register_db_tables() { $bands_table = "CREATE TABLE IF NOT EXISTS `wpg_bands` ( @@ -383,6 +388,8 @@ if ( !function_exists( "gigolog_register_db_tables") ) { ADD CONSTRAINT `wpgconcert_venue` FOREIGN KEY (`venue`) REFERENCES `wpg_venues` (`id`) ON DELETE NO ACTION;"); + + update_option("gigologadmin_db_version", 1); } gigolog_register_db_tables(); -- cgit v1.2.3