Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 195343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:40:22+00:00 2026-05-11T16:40:22+00:00

I have an application in PHP/MySQL. I am searching for an automated way upgrading

  • 0

I have an application in PHP/MySQL. I am searching for an automated way upgrading database behind the application.
I don’t need to have the compatibility with older versions once it is upgraded.

I have read jeff’s and K. Scott Allen’s articles on this.

I am still not sure how to implement this for a PHP/MySQL application.

Is there any simple and good process for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T16:40:23+00:00Added an answer on May 11, 2026 at 4:40 pm

    I have a “Schema” object that I use – but you could do the same without classes..

    What you want to do is create a ‘db_schema_versions‘ table:

    CREATE TABLE db_schema_versions (
      `table` varchar(255) NOT NULL PRIMARY KEY, 
      `version` INT NOT NULL
    )
    

    After your database can track what version # it is on – it can do SQL upgrades automatically.

    You should lock your schema table while upgrading schema. This way you wont have two requests at the same moment trying to upgrade your schema.

    So – keep track of the version you are upgrading from – build a big switch – something like this:

    class SNTrack_Db_Schema extends MW_Db_Schema_Abstract {
      protected $table = "sntrack_db_schema";
      protected $version = 5;
    
      protected function upgrade($fromVersion) {
        // don't break
        switch($fromVersion) {
          case 0:
            $this->db->query('CREATE TABLE sntrack_inbound_shipment (
                `id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
                `from` VARCHAR(255) NOT NULL,
                `date` DATE NOT NULL,
                `invoice` VARCHAR(255) NOT NULL,
                `notes` TEXT
              )');
            $this->setVersion(1);
          case 1:
            $this->db->query('ALTER TABLE sntrack_details ADD `shipment_id` INT');
            $this->db->query('ALTER TABLE sntrack_product ADD `inventory` INT NOT NULL DEFAULT 0');
            $this->db->query('CREATE TABLE sntrack_inventory_shipment (
                `shipment_id` INT NOT NULL,
                `product_id` INT NOT NULL,
                `qty` INT NOT NULL,
                PRIMARY KEY (`shipment_id`, `product_id`)
              )');
            $this->setVersion(2);
    ...etc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small application written in PHP and a mysql database hosted on
I have a PHP web application which uses a MySQL database for object tagging,
I have a ticketing web application written with PHP and MySQL. I need something
I have an application that works with database (PHP + MySQL). One of the
I have php mysql application and i want the phone numbers be saved in
We have a PHP/MYSQL application that collects user input, including special characters like ø,ü,ñ,
I have a LAMP (Linux/Apache/MySQL/Php) application that I should release soon. Even if I've
I have made a simple chat application in PHP/Ajax/MySQL. I am regularly calling these
We have a custom PHP/MySQL web application that gets updated and copied (using SFTP)
I have been working on on an AJAX chat application using php, mysql. It's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.