From d1236d54d3135508841b5a75dc7b1215abd35f0a Mon Sep 17 00:00:00 2001 From: Turner Bass Date: Sun, 29 Oct 2023 17:17:21 -0500 Subject: [PATCH 1/3] Simplifying development database install scripts to support Vagrant and non-Vagrant based environments --- db/README.md | 11 +++++++++++ db/rift.sql | 2 ++ db/rift_core.sql | 2 ++ db/setup-vagrant.sql | 25 ------------------------- db/setup.sql | 15 +-------------- dev-install.sh | 4 +++- 6 files changed, 19 insertions(+), 40 deletions(-) delete mode 100644 db/setup-vagrant.sql diff --git a/db/README.md b/db/README.md index e69de29..6daefcd 100644 --- a/db/README.md +++ b/db/README.md @@ -0,0 +1,11 @@ +## Why Single files and ALSO folders? + +You may find yourself in the unfortunate situation that you need to be poking around in this directory. + +If that is you, first of all, welcome! Secondly, there is a reason to have the SQL files `setup`, `rift`, and `rift_core` here while also having them split up in folders and files of their own. + +The reason for this is that we originally need to have these backup files split up into a more readable form to have better visibility on the structure of the databases. However, once they became the way that the `dev-install.sh` script restore the development databases, very important pieces of the database puzzle were lost and development environments could no longer load Areas. + +In order to keep the visibility of table structure and the wait for it... _usability_ of the dev databases they exist together in quasi-harmony. + +Cheers! \ No newline at end of file diff --git a/db/rift.sql b/db/rift.sql index a3f6dd3..13cadda 100644 --- a/db/rift.sql +++ b/db/rift.sql @@ -15,6 +15,8 @@ /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +CREATE DATABASE IF NOT EXISTS rift; + -- -- Table structure for table `buglist` -- diff --git a/db/rift_core.sql b/db/rift_core.sql index 0fcfcfd..9e91d77 100644 --- a/db/rift_core.sql +++ b/db/rift_core.sql @@ -15,6 +15,8 @@ /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +CREATE DATABASE IF NOT EXISTS rift_core; + -- -- Table structure for table `bans` -- diff --git a/db/setup-vagrant.sql b/db/setup-vagrant.sql deleted file mode 100644 index 2035138..0000000 --- a/db/setup-vagrant.sql +++ /dev/null @@ -1,25 +0,0 @@ --- --- mariadb setup script for riftshadow --- (FOR DEVELOPMENT ONLY) --- - --- create the required databases -CREATE DATABASE IF NOT EXISTS rift_core; -CREATE DATABASE IF NOT EXISTS rift; - --- databases are imported separately - --- create the rift user -use mysql; -DROP USER IF EXISTS 'rift'@'localhost'; -CREATE USER 'rift'@'localhost' IDENTIFIED BY 'rift123'; - --- grant rift user rights to access mariadb and all rights to the two dbs -GRANT USAGE ON *.* TO 'rift'@'localhost'; -GRANT ALL PRIVILEGES ON rift.* TO 'rift'@'localhost'; -GRANT ALL PRIVILEGES ON rift_core.* TO 'rift'@'localhost'; -FLUSH PRIVILEGES; - --- debug purposes. ensure the rift user has correct rights -SHOW GRANTS FOR 'rift'@'localhost'; - diff --git a/db/setup.sql b/db/setup.sql index 106be02..4cfaf6e 100644 --- a/db/setup.sql +++ b/db/setup.sql @@ -2,26 +2,13 @@ -- mariadb setup script for riftshadow -- (FOR DEVELOPMENT ONLY) -- - --- create the required databases -CREATE DATABASE IF NOT EXISTS rift_core; -CREATE DATABASE IF NOT EXISTS rift; - --- import rift_core script into rift_core db -use rift_core; -source rift_core.sql; - --- import rift script into rift db -use rift; -source rift.sql; - -- create the rift user use mysql; DROP USER IF EXISTS 'rift'@'localhost'; CREATE USER 'rift'@'localhost' IDENTIFIED BY 'rift123'; -- grant rift user rights to access mariadb and all rights to the two dbs -GRANT USAGE ON *.* TO 'rift'@'localhost' IDENTIFIED BY 'rift123'; +GRANT USAGE ON *.* TO 'rift'@'localhost'; GRANT ALL PRIVILEGES ON rift.* TO 'rift'@'localhost'; GRANT ALL PRIVILEGES ON rift_core.* TO 'rift'@'localhost'; FLUSH PRIVILEGES; diff --git a/dev-install.sh b/dev-install.sh index 029bddd..cd7d035 100755 --- a/dev-install.sh +++ b/dev-install.sh @@ -101,7 +101,9 @@ echo "${NOCOLOR}Running database scaffolding\n" { if [ -e ./db/setup.sql ]; then sudo mysql -v mysql < ./db/setup.sql - elif [ -e ~/code/db/setup-vagrant.sql ]; then + sudo mysql -v rift_core < ./db/rift_core.sql >/dev/null 2>&1 + sudo mysql -v rift < ./db/rift.sql >/dev/null 2>&1 + elif [ -e ~/code/db/setup.sql ]; then sudo mysql -v mysql < ~/code/db/setup-vagrant.sql sudo mysql -v rift_core < ~/code/db/rift_core.sql >/dev/null 2>&1 sudo mysql -v rift < ~/code/db/rift.sql >/dev/null 2>&1 From 8eaaa3d6729773ae60ec5da7b6910feddd6aff55 Mon Sep 17 00:00:00 2001 From: Turner Bass Date: Sun, 29 Oct 2023 17:20:36 -0500 Subject: [PATCH 2/3] Moved Create Database Lines to main setup.sql --- db/rift.sql | 2 -- db/rift_core.sql | 1 - db/setup.sql | 3 +++ 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/rift.sql b/db/rift.sql index 13cadda..a3f6dd3 100644 --- a/db/rift.sql +++ b/db/rift.sql @@ -15,8 +15,6 @@ /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -CREATE DATABASE IF NOT EXISTS rift; - -- -- Table structure for table `buglist` -- diff --git a/db/rift_core.sql b/db/rift_core.sql index 9e91d77..fcb73b7 100644 --- a/db/rift_core.sql +++ b/db/rift_core.sql @@ -15,7 +15,6 @@ /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -CREATE DATABASE IF NOT EXISTS rift_core; -- -- Table structure for table `bans` diff --git a/db/setup.sql b/db/setup.sql index 4cfaf6e..3db2cb8 100644 --- a/db/setup.sql +++ b/db/setup.sql @@ -1,6 +1,9 @@ -- -- mariadb setup script for riftshadow -- (FOR DEVELOPMENT ONLY) +CREATE DATABASE IF NOT EXISTS rift_core; +CREATE DATABASE IF NOT EXISTS rift; + -- -- create the rift user use mysql; From 1c8799ac7009a572182c89d13d45e409e5c4d2e4 Mon Sep 17 00:00:00 2001 From: Turner Bass Date: Sun, 29 Oct 2023 17:28:11 -0500 Subject: [PATCH 3/3] Fixed vagrant dev-install execution on setup.sql --- dev-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-install.sh b/dev-install.sh index cd7d035..93cc4af 100755 --- a/dev-install.sh +++ b/dev-install.sh @@ -104,7 +104,7 @@ echo "${NOCOLOR}Running database scaffolding\n" sudo mysql -v rift_core < ./db/rift_core.sql >/dev/null 2>&1 sudo mysql -v rift < ./db/rift.sql >/dev/null 2>&1 elif [ -e ~/code/db/setup.sql ]; then - sudo mysql -v mysql < ~/code/db/setup-vagrant.sql + sudo mysql -v mysql < ~/code/db/setup.sql sudo mysql -v rift_core < ~/code/db/rift_core.sql >/dev/null 2>&1 sudo mysql -v rift < ~/code/db/rift.sql >/dev/null 2>&1 ~/code/admin/artisan migrate