-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Installing Flux gives certain SQL errors #168
Comments
Drop colum for reinstallation doesn't seem like a good idea, it would be better something like:
|
Unfortunately, this issue still persists and it haunted me while trying to set up a containerized deployment. Since the existence of the respective indices and columns is not checked within the PHP code, some indices are duplicated whenever a new FluxCP instance is created, and the column alterations fail. The following scripts are problematic:
For a quick workaround (which does solve the crashes without any data loss like having to drop columns), I have expanded on the approach of @Daegaladh, using stored procedures to check for the existence of these indices and columns. This will still bring up the installation screen whenever FluxCP is redeployed, but it will not fail when performing the installation. So, here are the two types of snippets needed (Using the One for the DROP PROCEDURE IF EXISTS alter_cp_itemshop_20090104190020;
DELIMITER //
CREATE PROCEDURE alter_cp_itemshop_20090104190020()
BEGIN
IF (
SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'cp_itemshop'
AND COLUMN_NAME = 'category'
) = 0
THEN
ALTER TABLE `cp_itemshop` ADD `category` INT(11) NULL AFTER `nameid`;
END IF;
END
//
DELIMITER ;
CALL alter_cp_itemshop_20090104190020; And one for the DROP PROCEDURE IF EXISTS alter_cp_itemshop_20081128093449;
DELIMITER //
CREATE PROCEDURE alter_cp_itemshop_20081128093449()
BEGIN
IF (
SELECT COUNT(*)
FROM information_schema.statistics
WHERE TABLE_NAME = 'cp_itemshop'
AND INDEX_NAME = 'nameid'
) = 0
THEN
ALTER TABLE `cp_itemshop` ADD INDEX `nameid` (`nameid`);
END IF;
END
//
DELIMITER ;
CALL alter_cp_itemshop_20081128093449; Just replace the contents of the existing scripts with these, altering the respective names where appropriate. That specifically includes the table names, index names, column names and procedure names. Keep in mind that some scripts change multiple indices or columns so you might need multiple IF statements. The procedure names should be unique (though it will work either way since the procedure is dropped on script execution). I used a slightly altered version of the respective script file name. The index names can just be set to the first column that is part of the index. That is MySQL's default behavior when no index name is specified but it does throw an error if that index already exists, instead of just adding an incrementing number to the end. This makes troubleshooting a little easier since duplicating an index should not be possible with this setup. @Akkarinage if you'd like, I could create a pull request with these changes. Depends on whether you want to have a permanent solution for this inside the PHP code rather than use this workaround. It does preserve the independence of the code towards the SQL scripts though so I personally think it's quite an elegant solution. Quick Edit: The DROP PROCEDURE calls were initially only meant for my testing so that I didn't have to drop them manually every time but I left them in since they don't break anything and allow for easier debugging if something does go wrong. |
Hello!
While installing Flux various errors show up along the way.
These updates to the tables are cause of the issue, for:
cp_itemshop.20081109093448.sql
Add the missing semi-colon to fix.
cp_itemshop.20090104190020.sql
Add the missing semi-colon to fix.
Should probably be the missing semi-colon to fix as below, however I ended up with dropping/readding the columns for my fresh install.
My solution for my installation:
With these modifications in place I was able to install everything. Perhaps newly updated tables can be added to the schemas for the creation of the
cp_tables
along with a newer date for these files so that the old sql files won't be re-iterated through.Hopefully this might be of some use.
Kind regards,
Tranquility
The text was updated successfully, but these errors were encountered: