Forum

Welcome to ProjeQtOr new Forum. We migrated old forum to the new website.
You will find all your posts here, with your usual account.
Just one point : you’ll have to reinitialize your password. Use “Lost password” feature.

Database update
 
Notifications
Clear all

Database update

3 Posts
2 Users
0 Reactions
4,275 Views
Antoine
(@eb0z)
Posts: 14
Active Member
Topic starter
 
[#1034]

Hello Babynus,

I would update my database when I want.
So I would go through the sql files.

For that, I added a variable in parameters.php

parameters.php

$forceToUpdate = false;//or true to force the update

Then I added a condition in projector.php

projector.php

if (Sql::getDbVersion()!=$version or $forceToUpdate) {
    $prf=new Profile($user->idProfile);
    if ($prf->profileCode!='ADM') {
      loginErrorMaintenance();
      exit;
    }
    include "../db/maintenance.php";
    exit;
}

I also changed the version (text) in projector.php to be sure that it will not be the same as the version stored in the parameter's table (db) and added the SQL file in maintenance.php too.

My problem is that it does not go in the last sql files I added.
In fact, it does not execute the script.
To test I have created a sql file with a table creation inside, and after the update (forced), my table has not been created...

How can I do for that ?
Does it go through my sql file without executing the scripts ?

I hope I have been enough clear.

Thank you.

Antoine.


 
Posted : 19 Mar 2013 12H31
babynus
(@babynus)
Posts: 14953
Main Contributor Admin
 

Your parameter $forceToUpdate is not really usefull.

what you need to update is :
- create new /db/Projector_Vx.y.z.sql
- add your new version "Vx.y.z" in $versionHistory (an array) in /db/maintenance.php
(I think it is this step that is missing)
- change $version="Vx.y.z" in /tool/projector.php
This is all.
It will work correctly.

Then, if you want to run again your script, change parameterValue of table parameter, for parameterCode='dbVersion', to the old version.
This is important as the tool will apply scripts from this version to $version.
So $forceToUpdate is no use. If you only set it, the tool does not apply any script (none exists from 'dbVersion' to $version as they are equal)


 
Posted : 19 Mar 2013 16H04
Antoine
(@eb0z)
Posts: 14
Active Member
Topic starter
 

Thank you for your answer.
Yes I knew that I could do by this way, but I wanted something without changing the version.
Anyway, I am going to do like that.
Regards.


 
Posted : 19 Mar 2013 16H16
Share:

Scroll to Top