Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

How to migrate database ? #4461

tung.nh1 ·

Hello@robinshen
I have a problem with migrate database of quickbuild.
I created a field is configBuildTypeScript in Configuration.java (com.pmease.quickbuild/src/com/pmease/quickbuild/model/Configuration.java), and migrate data in file MainMigrator.java.
And I run command upgrade.sh but it is failed. (quickbuild_current/bin$ ./upgrade.sh /quickbuild_new)
This is content of my change in file MainMigrator.java

private void migrate102(File dataDir, Stack<Integer> versions) {
        for (File file : dataDir.listFiles()) {
            String configurationFileNamePrefix = 
                    Configuration.class.getSimpleName() + "s.xml";
                if (file.getName().startsWith(configurationFileNamePrefix)) {
                VersionedDocument dom = FileUtils.readFileAsDom(file);
                for (Element configurationElement : (List<Element>) dom
                        .getRootElement().elements()) {
                    if (configurationElement.elementText("id").trim().equals("1")) {
                        configurationElement.addElement("configBuildTypeScript").setText("");
                    }
                }
                FileUtils.writeFile(file, dom, false, false, false);
            }
        }
    }

This is error log:

2023-01-05 15:20:27,956 INFO  - >>> 2023-01-05 15:20:27,956 WARN  - SQL Error: 1054, SQLState: 42S22
2023-01-05 15:20:27,957 INFO  - >>> 2023-01-05 15:20:27,957 ERROR - Unknown column 'configurat0_.qb_build_type' in 'field list'
2023-01-05 15:20:27,958 INFO  - >>> 2023-01-05 15:20:27,958 WARN  - SQL Warning Code: 1054, SQLState: 42S22
2023-01-05 15:20:27,959 INFO  - >>> 2023-01-05 15:20:27,958 WARN  - Unknown column 'configurat0_.qb_build_type' in 'field list'

Do I need use sql query before running upgrade.sh?
Ex: ALTER TABLE QB_CONFIGURATION ADD COLUMN configBuildTypeScript VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_bin' AFTER QB_BUILD_TYPE_SCRIPT;

  • replies 3
  • views 234
  • stars 0
robinshen ADMIN ·

Seems that your database has a field "build_type" not reflected in your configuration. You might need to add that field as well.

WARNING: Adding custom specific migration methods may screw up the database and we generally do not recommend that.

tung.nh1 ·

WARNING: Adding custom specific migration methods may screw up the database and we generally do not recommend that.
=> So, Should I run the SQL command without running upgrade.sh? And Do I need add change in file MainMigration.java ?
I mean I only run Mysql querry for add field "build_type" -> Is it ok ?

robinshen ADMIN ·

You may add that field via sql directly.