lh-ehr icon indicating copy to clipboard operation
lh-ehr copied to clipboard

[WIP] Setup installation EHR

Open muarachmann opened this issue 5 years ago • 3 comments

This PR attempts to fix the setup installation process for EHR now found in /modules/setup . and eventually will solve #1474

  • [x] create temporal file for for temporal track of setup installation process
  • [ ] removed unsed files
  • [ ] move all styles and js, images to assets/
  • [ ] optimize the code to show real time percentages from mysql query (like measure actual execution of each query to provide appropriate feedback to user)
  • [ ] Revamp multi-site login (re-installs)

.....

NB - This currently installs EHR and works fine. Except for clone source database which i dont know why the function doesn't work. Looking forward to solving this

private function dumpSourceDatabase() {
        global $OE_SITES_BASE;
        require("$OE_SITES_BASE/$this->source_site_id/sqlconf.php");

        if (empty($config)) die("Source site $this->source_site_id has not been set up!");

        $backup_file = $this->get_backup_filename();
        $cmd = "mysqldump -u " . escapeshellarg($this->login) .
            " -p" . escapeshellarg($this->pass) .
            " --opt --quote-names -r $backup_file " .
            //" --opt --skip-extended-insert --quote-names -r $backup_file " .  Comment out above line and enable this to have really slow DB duplication.
            escapeshellarg($this->dbname);

        $tmp0 = exec($cmd, $tmp1=array(), $tmp2);
        if ($tmp2) die("Error $tmp2 running \"$cmd\": $tmp0 " . implode(' ', $tmp1));

        return $backup_file;
    }

PS - Should be merged after #1473

muarachmann avatar May 16 '19 01:05 muarachmann

We also need to rebuild the database.sql file. Two choices.

  1. Create a separate file for each table, maintain each separately, and have the installer run files in sequence, THEN do insert files.
  2. Clean database.sql up, organize it, then re-write or dump all the inserts so they do not do 12 million queries. Installing the db can take about 5 seconds when optimized. The way it is now, it can potentially time out.

aethelwulffe avatar May 16 '19 14:05 aethelwulffe

Okay i see the error here. The issue is the dump was only done considering windows mostly. Adding the patch for mac. cause the dumpfile is never created

In this function

 /**
     * @return filename of the source backup database for cloning
     */
    private function get_backup_filename() {
        if (stristr(PHP_OS, 'WIN')) {
            $backup_file = 'C:/windows/temp/setup_dump.sql';
        }
        else {
            $backup_file = '/tmp/setup_dump.sql';
        }
        return $backup_file;
    }

muarachmann avatar May 19 '19 16:05 muarachmann

Assets move next? You can keep them in the setup module if you like, but since it is (or is to be) a core module, nothing wrong with using the standard assets.

Multi-site (adding sites, updating sql for sites), requiring a localhost or pre-set install access auth to run setup (which can be done without root db pass remotely if db is local to apache), and removing all other setup tools to prevent use by unauthorized access (while not requiring anyone to remove setup.php) are higher on the list than the install countdown. Frankly, if we optimize database.sql, it might be so quick we don't need a timer. I think that issue might already be taken care of in the SCCBranch monster PR. It runs much faster now, and still has room for improvement, after I remove a few thousand semicolons and combined insert queries.

aethelwulffe avatar May 20 '19 16:05 aethelwulffe