03-16-2023, 11:33 AM (This post was last modified: 03-16-2023, 11:45 AM by TheYear2525.)
Quote:(02-23-2023, 02:58 AM)Rob F Wrote: [url=https://www.robo-tank.ca/forum/Thread-Robo-Tank-v6-6-is-Ready?pid=8338#pid8338][/url]If you have Chrome, right click on the page and click "inspect", a window will open in the browser. In that window there are tabs at the top, click the "console" tab. Then reload the page again, this time click and hold the refresh button and a drop down will appear. Then click "empty cache and hard reload". If it's still blank send me the info in the "console" you opened. That should tell me where it's getting stuck.
Right on, thank-you, that's definitely the problem but I'm not sure how. I've been doing some testing and it all seems good and would make sense nothing is wrong in the code or I would think I should experience it as well. When I change a field name in the database table I get the same error so maybe something is wrong with the table and the query is failing.
Can you log into the database and see if the "schedules" table looks like this when you click the "structure" tab?
Here's how you access the database.
Add /phpmyadmin/ to your Pi IP address like below.
I didn't expect to see =1678987612522 at the end, that's the unix timestamp and it lines up close to when you posted. I don't send that to the php file so not sure why it's there, only the sort column (in this case schName) and ascending (1) or descending(0) sort is sent. But when I run that link in my browser the query runs so it doesn't seem to be affecting it. However that space before the = sign gets replaced with %20 as spaces aren't allowed. I'm wondering if that's what's breaking the php query as it likely won't auto replace the space.
So I need to figure out why that's being included and why it's not for me, arggg. Can you run that link in your browser, I suspect you'll see [] as there are no records to return but that'll verify the database and query are ok.
Turns out that timestamp is being sent because I have cache turned to off on the ajax call so it's not the problem. Here's something to try, this will update the schedulesSort.php file, I removed the variables from the query, maybe somehow it's stumbling over that. Run these 5 commands and try reloading the page.
(03-17-2023, 12:22 AM)gandalf Wrote: if i Remember properly, schedulesort was one of the file i had to fix to make it working. i could check when i'm back from work
If you could check that would be awesome, I do have something different going on with the Order By clause for this query but can't remember why, I think some columns weren't sorting properly and this fixed it but not sure what the * 1 means now.
PHP Code:
ORDER BY `{$sort}` ASC, `{$sort}` * 1 ASC
In my last post with the updated schedulesSort.php file I changed it to this just to test.
PHP Code:
ORDER BY schName ASC
If this is the problem or there's a different problem in this file can you explain why it works for me and others yet some it doesn't?
This is the whole file to compare with yours.
PHP Code:
<?php
header('Content-Type: application/json'); header("Access-Control-Allow-Origin: *"); $sort = $_GET["s"];// get sort type $asc = $_GET["a"];// get sort type
require '../php/database.php';
if ($asc == 1) { $query = sprintf("SELECT schedules.scheduleID, schedules.scheduleTypeID, schedules.pinID, schedules.offOn, schedules.schName, schedules.start, schedules.sun, schedules.mon, schedules.tue, schedules.wed, schedules.thu, schedules.fri, schedules.sat, schedules.repeatDays, schedules.enabled, schedules.schEmail, schedules.schAlert, scheduleType.type, pinsAvailable.name, pinsAvailable.iconID, dosingSchedules.mL FROM schedules LEFT JOIN scheduleType ON scheduleType.scheduleTypeID = schedules.scheduleTypeID LEFT JOIN pinsAvailable ON pinsAvailable.pinID = schedules.pinID LEFT JOIN dosingSchedules ON dosingSchedules.scheduleID = schedules.scheduleID ORDER BY `{$sort}` ASC, `{$sort}` * 1 ASC"); // ORDER BY LENGTH(`{$sort}`), `{$sort}` ASC"); // ORDER BY binray_not_needed_column ASC , `{$sort}` ASC"); } else { $query = sprintf("SELECT schedules.scheduleID, schedules.scheduleTypeID, schedules.pinID, schedules.offOn, schedules.schName, schedules.start, schedules.sun, schedules.mon, schedules.tue, schedules.wed, schedules.thu, schedules.fri, schedules.sat, schedules.repeatDays, schedules.enabled, schedules.schEmail, schedules.schAlert, scheduleType.type, pinsAvailable.name, pinsAvailable.iconID, dosingSchedules.mL FROM schedules LEFT JOIN scheduleType ON scheduleType.scheduleTypeID = schedules.scheduleTypeID LEFT JOIN pinsAvailable ON pinsAvailable.pinID = schedules.pinID LEFT JOIN dosingSchedules ON dosingSchedules.scheduleID = schedules.scheduleID ORDER BY `{$sort}` DESC, `{$sort}` * 1 DESC"); // ORDER BY LENGTH(`{$sort}`), `{$sort}` DESC"); // ORDER BY binray_not_needed_column DESC , `{$sort}` DESC"); } //execute query $result = $mysqli->query($query);
//loop through the returned data $dataWindow = array(); foreach ($result as $row) { $dataWindow[] = $row; }
print json_encode($dataWindow); //free memory associated with result $result->close();
Problem is I don't have any error related to this, scheduleSorts.php runs fine for me and others. Not long ago, after v6.6, someone pointed out a bunch of errors in this log, I think I've got those fixed now at least my log is showing clean. Those changes will be in v6.7.
Yeah but I don't get any 500 errors, I did see a bunch of errors for variables defined but not used as you mentioned but that's unrelated.
I don't know for sure but it seems for 75% it works fine 25% can't load the page and probably for the same reason, that's why it doesn't make sense as we all use the same code, php version etc. I get it if there's a problem with the code but I don't get why this code works for some and not others.
03-17-2023, 04:48 AM (This post was last modified: 03-17-2023, 05:03 AM by gandalf.)
I was referring to the screenshot posted by TheYear2525
What i know for sure is that my install didn't started and I had to customize some php file fixing the variable issues (mostly variables used as constants)
Also the mysql instance had an issue but i don't remember what i've changed.
Just an example:
checkStartupWizard.php
You have this:
Code:
$query = sprintf("SELECT `userID`, `username`, `firstRun`, `adminEmail`, `email1`, `email2`, `email2Enabled`, `email3`, `email3Enabled` FROM `users` ORDER BY ".userID." ASC");
this breaks for sure, as the "userID" is considered a constant, not a database field thus the resulting query would be :
Code:
SELECT `userID`, `username`, `firstRun`, `adminEmail`, `email1`, `email2`, `email2Enabled`, `email3`, `email3Enabled` FROM `users` ORDER BY ASC
that is not valid (missing field after the ORDER BY)
This breaks for sure.
Same error in many other files, i had to fix all of these to make it working
something similiar in getLightModesData.php , lightPorts.php
The following 1 user Likes gandalf's post:1 user Likes gandalf's post • Rob F
Thanks, funny you mention these files as I actually just fixed them last week, when someone told me to check the php log I saw errors from these files and more so was able to fix them. As I'm going I'm learning, php I don't know much about so that's why I had those mistakes. I'm going to go though all the php files to make sure I didn't miss any.
Now can you answer this?
Why did those coding issues break your system and some others, yet me and a majority they had no effect other than lots of log errors? I promise you I can install v6.6 on a fresh SD card all day long and it works and I know one other person for sure was able to upgrade without issue.
Can you recommend any other error logs I should be paying attention to?
100% those queries were working for a lot of people including myself as some of them have been there basically from day 1. It's obvious just from forum posts, guaranteed people using it didn't make all the changes you did. I'm really hoping I can find out why this is the case, I'm hoping you have a different PHP version but if you used my install script then I can't see how yours would be different.
What do you think of this updated php code vs what I'm currently doing?
Switched from mysqli to PDO to access the database, using prepared statement so it's safer, try catch block and error handling.
(03-17-2023, 01:16 AM)Rob F Wrote: Is this the log you refer to?
/var/log/apache2/error.log
Problem is I don't have any error related to this, scheduleSorts.php runs fine for me and others. Not long ago, after v6.6, someone pointed out a bunch of errors in this log, I think I've got those fixed now at least my log is showing clean. Those changes will be in v6.7.
My graphs were also randomly disappearing before you patched the files for me. Usually if I'd left the page open for a while.
The following 1 user Likes matt's post:1 user Likes matt's post • Rob F
100% those queries were working for a lot of people including myself as some of them have been there basically from day 1. It's obvious just from forum posts, guaranteed people using it didn't make all the changes you did. I'm really hoping I can find out why this is the case, I'm hoping you have a different PHP version but if you used my install script then I can't see how yours would be different.
What do you think of this updated php code vs what I'm currently doing?
Switched from mysqli to PDO to access the database, using prepared statement so it's safer, try catch block and error handling.
$ php -v
PHP 7.4.33 (cli) (built: Nov 8 2022 11:40:37) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies
Which Debian do you have in your Pi ? Probaby not the 11:
Code:
$ cat /etc/debian_version
11.6
the code above looks good to me
It should work anyway, but triggering a huge warning:
Code:
$ php -r "echo 'HELLO '.World.'';"
PHP Warning: Use of undefined constant World - assumed 'World' (this will throw an Error in a future version of PHP) in Command line code on line 1
HELLO World
in php8 this this is fixed and the undefined constant is not considered a string anymore.
Probably on some environment this didn't worked because the error is outputting some unxepceted data (the error message) that break the AJAX call if you expect a json or something similar.
The following 1 user Likes gandalf's post:1 user Likes gandalf's post • Rob F
(03-19-2023, 09:24 AM)matt Wrote: My graphs were also randomly disappearing before you patched the files for me. Usually if I'd left the page open for a while.
Thanks for letting me know, if it happens again let me know. Now I have the graphs loading from the database instead of CSV files so that might help, this will be coming in v6.7.
Gandalf thanks for checking, my debian version is 10.12. This and my php version is from my main system which has been running a long time so might explain why the versions are so old, I'll have to see what versions I get on a fresh install. A different php version could be the reason it works for some and not others but yeah either way those queries weren't well written so my fault. I updated all the php files to PDO etc so hopefully that helps as well. When I ran php -r "echo 'HELLO '.World.'';" I got the same as you.
Hey Rob, I tried to go through a fresh install since my old SD card died. Followed the instructions, got message that the installation completed successfully. When I tried to access the site I kept getting error, see screen shot. Tried the steps twice with the same results.
Hi Enigma79, sorry about that, someone had this problem the other day and found the fix, try running the following two commands in the SSH terminal.
sudo usermod -a -G www-data username
sudo chown -R -f www-data:www-data /var/www/html
After this you should get the login screen but you likely won't be able to log in. If so you'll have to add the database manually, here's how you do that.
Add /phpmyadmin/ to your Pi IP address like below and log in. http://192.168.1.145/phpmyadmin/ Username = root Password = robotank
At the top there should be a bunch of tabs, click on the 2nd tab "SQL" and you should see a large text box. Copy and paste the following in the text box and click the "Go" button on the right side. After this you should be able to log in.
Code:
-- phpMyAdmin SQL Dump
-- version 4.6.6deb5
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Generation Time: Feb 13, 2023 at 11:13 PM
-- Server version: 10.3.34-MariaDB-0+deb10u1
-- PHP Version: 7.3.31-1~deb10u1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
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 */;
CREATE TABLE `versionInfo` (
`versionInfoID` int(11) NOT NULL,
`versionID` int(11) NOT NULL,
`versionTypeID` int(11) NOT NULL,
`change` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `versionInfo`
--
INSERT INTO `versionInfo` (`versionInfoID`, `versionID`, `versionTypeID`, `change`) VALUES
(1, 1, 2, 'Configure Ports - Added Robo-Tank extensions to DB9 accessory types'),
(2, 1, 2, 'Configure Ports - Added all pin functions to advanced tab'),
(3, 1, 3, 'Program - Sensors were being checked when disabled'),
(4, 1, 1, 'Added a toggle switch as a sensor type'),
(5, 1, 2, 'Dashboard - Added sensor status to info boxes'),
(6, 1, 3, 'Custom Rules - Off rules were not saved correctly'),
(8, 2, 3, 'Custom Rules - Added ability to disable/enable dosing pumps'),
(9, 2, 3, 'pH Calibration - Couldn\'t adjust 2nd point value'),
(10, 2, 2, 'Light Modes - Change how modes are created and work'),
(11, 2, 1, 'Added Auto Logout'),
(12, 3, 3, 'Could not access Advanced view on Configure Ports Page'),
(13, 3, 3, 'Could not disable schedules'),
(14, 4, 3, 'DC Ports - When put in manual mode the red dot on icon would disappear after a page refresh although it still remained in manual mode'),
(15, 4, 2, 'System - removed wiringPi library to control GPIOs, now reading/writing GPIOs using sysfs'),
(16, 4, 2, 'Dashboard - changed bottom dock to snap to bottom of browser'),
(17, 4, 1, 'System - Added v2 and v3 controller compatibility'),
(18, 4, 1, 'AC Outlets - Added ability to Invert output logic'),
(19, 4, 1, 'DC Ports - Added ability to Invert output logic'),
(20, 4, 3, 'Setup Wizard - Fixed form to configure new pca9685'),
(21, 4, 3, 'PCA9685 - Fixed bug that wouldn\'t allowing more than 2 PCA9685 modules'),
(22, 4, 1, 'RTC - Added support for DS1307 and DS3231 real time clocks'),
(23, 4, 2, 'Interface - Date and time on webpage now gets updated from backend instead of using computer date and time'),
(24, 4, 2, 'Startup Wizard - Fixed DS18B20 scan and added controller version option'),
(25, 5, 1, 'PCA9685 - Added verification, when pca9685 is updated it is immediately read to verify it updated correctly, if not it tries again'),
(26, 5, 1, 'GPIO - Added verification, when GPIO is updated it is immediately read to verify it updated correctly, if not it tries again'),
(27, 5, 3, 'Browser DateTime - Clock would not show 24 hour format after adding RTC'),
(28, 5, 1, 'System Logs - Added logging system to record all actions'),
(29, 5, 3, 'Schedules - Date added was saved wrong in database after RTC was added'),
(30, 5, 3, 'I2C Scanner - Removed auto scanner as it is not required'),
(31, 5, 3, 'Charts - pH chart table in database wasn\'t being updated'),
(32, 5, 2, 'Charts - charts were still getting timestamp from internet time, changed to controller system time'),
(33, 6, 2, 'Schedules - Updated schedules table for user interface'),
(34, 6, 3, 'Schedules - If schedule was disabled when schedule list was filtered it would not appear disabled in list, only visual error'),
(35, 6, 2, 'Schedules - List of schedules is now updated after confirmation is received from backend, previously it waited 250ms before reloading table'),
(36, 6, 2, 'Schedules - Removed Off option for dosing pumps when creating a schedule'),
(37, 6, 3, 'Schedules - If schedule was created using Repeat Every 1 Day setting the first days schedule would not run'),
(38, 6, 3, 'Schedules - It was possible to add a new schedule without any days selected'),
(39, 6, 1, 'Schedules - Added validation when editing a schedule, was possible to crash program without this'),
(40, 6, 3, 'Custom Rules - If custom rule was for a pH probe it failed to run or disply correctly in UI'),
(42, 6, 2, 'System Logs - Added port custom name to source field'),
(43, 6, 1, 'Version Logs - Added version log to system settings page'),
(46, 6, 1, 'Dosing Pumps - Added ability to create a group of schedules'),
(48, 6, 1, 'Dosing Pumps - Added system for dosing pump stirrers'),
(49, 6, 1, 'Dosing Pumps - Speed of dosing pump can now be adjusted during calibration'),
(50, 6, 1, 'Dosing Pumps - User can opt out using the reservior feature, pump can still run if reservior is empty'),
(51, 6, 1, 'Dosing Pumps - Added alert for low reservior, user can set the low limit in milliliters'),
(52, 6, 2, 'Real Time Clock - Raspberry Pi is now managing the real time clock'),
(53, 6, 3, 'Configure Ports - When saving settings from a DB9 it was likely the program would crash as it was repeating save 8 times'),
(54, 6, 2, 'Custom Rules - Updated custom rules to allow user to specify how many milliliters to dose');
--
-- Indexes for table `versionType`
--
ALTER TABLE `versionType`
ADD PRIMARY KEY (`versionTypeID`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `button_labels`
--
ALTER TABLE `button_labels`
MODIFY `buttonID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=20;
--
-- AUTO_INCREMENT for table `dosingPumps`
--
ALTER TABLE `dosingPumps`
MODIFY `doseID` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `dosingSchedules`
--
ALTER TABLE `dosingSchedules`
MODIFY `doseSchID` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `drivers`
--
ALTER TABLE `drivers`
MODIFY `driverID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `ds18b20`
--
ALTER TABLE `ds18b20`
MODIFY `ds18b20ID` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `errors`
--
ALTER TABLE `errors`
MODIFY `errorID` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `errorsSource`
--
ALTER TABLE `errorsSource`
MODIFY `errorSourceID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `i2cDevices`
--
ALTER TABLE `i2cDevices`
MODIFY `i2cID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `i2cDeviceTypes`
--
ALTER TABLE `i2cDeviceTypes`
MODIFY `i2cDeviceTypeID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `lightModes`
--
ALTER TABLE `lightModes`
MODIFY `modeID` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `log`
--
ALTER TABLE `log`
MODIFY `logID` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `logAction`
--
ALTER TABLE `logAction`
MODIFY `logActionID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `logSource`
--
ALTER TABLE `logSource`
MODIFY `logSourceID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
--
-- AUTO_INCREMENT for table `logType`
--
ALTER TABLE `logType`
MODIFY `logTypeID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `pinsAvailable`
--
ALTER TABLE `pinsAvailable`
MODIFY `pinID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=40;
--
-- AUTO_INCREMENT for table `pinsType`
--
ALTER TABLE `pinsType`
MODIFY `pinTypeID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;
--
-- AUTO_INCREMENT for table `probes`
--
ALTER TABLE `probes`
MODIFY `probeID` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `rules`
--
ALTER TABLE `rules`
MODIFY `ruleID` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `rulesEquipment`
--
ALTER TABLE `rulesEquipment`
MODIFY `rulesEquipmentID` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `rulesSensors`
--
ALTER TABLE `rulesSensors`
MODIFY `rulesSensorID` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `rulesType`
--
ALTER TABLE `rulesType`
MODIFY `ruleTypeID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `schedules`
--
ALTER TABLE `schedules`
MODIFY `scheduleID` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `scheduleType`
--
ALTER TABLE `scheduleType`
MODIFY `scheduleTypeID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `stirrers`
--
ALTER TABLE `stirrers`
MODIFY `stirrerID` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `systemSettings`
--
ALTER TABLE `systemSettings`
MODIFY `systemSettingID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `userID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `version`
--
ALTER TABLE `version`
MODIFY `versionID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `versionInfo`
--
ALTER TABLE `versionInfo`
MODIFY `versionInfoID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=55;
--
-- AUTO_INCREMENT for table `versionType`
--
ALTER TABLE `versionType`
MODIFY `versionTypeID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `dosingPumps`
--
ALTER TABLE `dosingPumps`
ADD CONSTRAINT `dosingPumps_ibfk_1` FOREIGN KEY (`dosePinID`) REFERENCES `pinsAvailable` (`pinID`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `dosingSchedules`
--
ALTER TABLE `dosingSchedules`
ADD CONSTRAINT `dosingSchedules_ibfk_1` FOREIGN KEY (`scheduleID`) REFERENCES `schedules` (`scheduleID`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `errors`
--
ALTER TABLE `errors`
ADD CONSTRAINT `errors_ibfk_1` FOREIGN KEY (`errorSourceID`) REFERENCES `errorsSource` (`errorSourceID`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `i2cDevices`
--
ALTER TABLE `i2cDevices`
ADD CONSTRAINT `i2cDevices_ibfk_1` FOREIGN KEY (`i2cDeviceTypeID`) REFERENCES `i2cDeviceTypes` (`i2cDeviceTypeID`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `i2cDevices_ibfk_2` FOREIGN KEY (`i2cDriverID`) REFERENCES `drivers` (`driverID`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `lightModes`
--
ALTER TABLE `lightModes`
ADD CONSTRAINT `lightModes_ibfk_1` FOREIGN KEY (`pinID`) REFERENCES `pinsAvailable` (`pinID`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `log`
--
ALTER TABLE `log`
ADD CONSTRAINT `log_ibfk_1` FOREIGN KEY (`logSourceID`) REFERENCES `logSource` (`logSourceID`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `log_ibfk_2` FOREIGN KEY (`logTypeID`) REFERENCES `logType` (`logTypeID`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `log_ibfk_3` FOREIGN KEY (`logPinID`) REFERENCES `pinsAvailable` (`pinID`) ON DELETE NO ACTION ON UPDATE CASCADE,
ADD CONSTRAINT `log_ibfk_4` FOREIGN KEY (`logActionID`) REFERENCES `logAction` (`logActionID`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `pinsAvailable`
--
ALTER TABLE `pinsAvailable`
ADD CONSTRAINT `pinsAvailable_ibfk_1` FOREIGN KEY (`driverID`) REFERENCES `drivers` (`driverID`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `pinsAvailable_ibfk_2` FOREIGN KEY (`pinTypeID`) REFERENCES `pinsType` (`pinTypeID`);
--
-- Constraints for table `probes`
--
ALTER TABLE `probes`
ADD CONSTRAINT `probes_ibfk_1` FOREIGN KEY (`address`) REFERENCES `i2cDevices` (`decAddress`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `rules`
--
ALTER TABLE `rules`
ADD CONSTRAINT `rules_ibfk_1` FOREIGN KEY (`ruleTypeID`) REFERENCES `rulesType` (`ruleTypeID`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `rulesEquipment`
--
ALTER TABLE `rulesEquipment`
ADD CONSTRAINT `rulesEquipment_ibfk_1` FOREIGN KEY (`equipmentPinID`) REFERENCES `pinsAvailable` (`pinID`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `rulesEquipment_ibfk_2` FOREIGN KEY (`ruleID`) REFERENCES `rules` (`ruleID`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `rulesSensors`
--
ALTER TABLE `rulesSensors`
ADD CONSTRAINT `rulesSensors_ibfk_1` FOREIGN KEY (`ruleID`) REFERENCES `rules` (`ruleID`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `rulesSensors_ibfk_2` FOREIGN KEY (`sensorPinID`) REFERENCES `pinsAvailable` (`pinID`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `schedules`
--
ALTER TABLE `schedules`
ADD CONSTRAINT `schedules_ibfk_1` FOREIGN KEY (`scheduleTypeID`) REFERENCES `scheduleType` (`scheduleTypeID`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `schedules_ibfk_2` FOREIGN KEY (`pinID`) REFERENCES `pinsAvailable` (`pinID`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `schedules_ibfk_3` FOREIGN KEY (`ruleID`) REFERENCES `rules` (`ruleID`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `stirrers`
--
ALTER TABLE `stirrers`
ADD CONSTRAINT `stirrers_ibfk_1` FOREIGN KEY (`stirrerPinID`) REFERENCES `pinsAvailable` (`pinID`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `systemSettings`
--
ALTER TABLE `systemSettings`
ADD CONSTRAINT `systemSettings_ibfk_2` FOREIGN KEY (`userID`) REFERENCES `users` (`userID`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `versionInfo`
--
ALTER TABLE `versionInfo`
ADD CONSTRAINT `versionInfo_ibfk_1` FOREIGN KEY (`versionID`) REFERENCES `version` (`versionID`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `versionInfo_ibfk_2` FOREIGN KEY (`versionTypeID`) REFERENCES `versionType` (`versionTypeID`) ON DELETE CASCADE ON UPDATE CASCADE;
/*!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 */;