Creation of auto-gen script #11

Merged
MrLyallCSIT merged 2 commits from issue-10 into main 2020-08-05 18:36:04 +00:00
3 changed files with 121 additions and 0 deletions

5
app/includes/install.php Normal file
View File

@@ -0,0 +1,5 @@
<?php
$output1 = shell_exec($command . '/../includes/install.sql');
?>

103
app/includes/install.sql Normal file
View File

@@ -0,0 +1,103 @@
-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 10.0.0.2:3306
-- Generation Time: Aug 04, 2020 at 05:00 PM
-- Server version: 5.7.31
-- PHP Version: 7.4.8
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `ADCMHelp`
--
-- --------------------------------------------------------
--
-- Table structure for table `tickets`
--
CREATE TABLE IF NOT EXISTS `tickets` (
`uuid` varchar(128) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` text NOT NULL,
`description` text NOT NULL,
`status` enum('New','In Progress','Pending','Resolved','Closed') NOT NULL DEFAULT 'New',
`assignee` text,
`created_by` text NOT NULL,
`created_on` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`,`uuid`),
UNIQUE KEY `uuid` (`uuid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `ticket_subscribers`
--
CREATE TABLE IF NOT EXISTS `ticket_subscribers` (
`sub_id` int(11) NOT NULL AUTO_INCREMENT,
`ticket_uuid` varchar(36) NOT NULL,
`user_uuid` varchar(36) NOT NULL,
PRIMARY KEY (`sub_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `ticket_updates`
--
CREATE TABLE IF NOT EXISTS `ticket_updates` (
`ticket` varchar(36) NOT NULL,
`created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`user` varchar(36) NOT NULL,
`msg` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `ticket_uploads`
--
CREATE TABLE IF NOT EXISTS `ticket_uploads` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ticket` varchar(36) NOT NULL,
`created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`user` varchar(36) NOT NULL,
`path` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`uuid` varchar(36) NOT NULL,
`uid` text NOT NULL,
`given_name` text NOT NULL,
`family_name` text NOT NULL,
`email` text NOT NULL,
UNIQUE KEY `uuid` (`uuid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

View File

@@ -7,6 +7,19 @@ require_once __DIR__ . "/../vendor/autoload.php";
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . "/..");
$dotenv->load();
// Database auto-generation
if (file_exists("/../includes/install.php")) {
return;
add_action('run_db_populate')
luketainton commented 2020-08-05 18:12:51 +00:00 (Migrated from github.com)
Review

What does this do?

What does this do?
MrLyallCSIT commented 2020-08-05 18:32:48 +00:00 (Migrated from github.com)
Review

Runs the install script then renames it's so it doesn't run it each time

Runs the install script then renames it's so it doesn't run it each time
}
function run_db_populate() {
// all my glorious one-time-magic.
include( "/../includes/install.php" );
// after all execution rename your file;
rename( "/../includes/install.php", "/../includes/install-backup.php");
}
// Session
session_start();