opengbu / gbuonline

GBU Online
5 stars 6 forks source link

New database upgrade system #24

Closed Varun-garg closed 9 years ago

Varun-garg commented 9 years ago

Hi everyone, upgrading database is a problem, specially on our main site when data is continuously updated. So I have written a small code that updates database automatically.

The database file (gbuonline.sql) has been retested to the point where it is in touch with our main site. Please re-import it. The changes made afterwards have been carefully recorded in the system.

  1. Now to upgrade database, just go to domain/users , and everything will be done automatically.
  2. To modify the structure, open /users/controllers/upgrade.php
  3. You will see many entries like 1.1, 1.2, 1.3 and so on.
  4. Add your entry there, like

    $u = new update;
    $u->version = 1.5;
    array_push($u->updates, "ALTER TABLE `blog` ...");
    array_push($u->updates, "ALTER TABLE `h_complaint` DROP `user_id` ....");
    array_push($u->updates, " ... .... ");
    //more sql queries can be inserted like this.
    array_push($update_list, $u);
    unset($u);