Skip to main content
Topic: Databases support install (and upgrade) (Read 5688 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Databases support install (and upgrade)

I didn't post that one at github because I was not sure in which repository file the issue... :P

At the moment each database layer has it's own .sql file with queries for installing and upgrade.
The problem is obviously that we have to keep more than one file in-synch.
This was difficult (to remember and for a syntax reason) when all the layers were in the main repository, now that SQLite is gone to tools it is even more difficult for anyone.

So, how difficult would be use our own db-layer to "merge" all the install_*_{dbms}.sql into a single file and parse it independently from the dbms in use during he installation?
Not easy, a bit tedious, but it should be possible...I think.

Upgrade is a bit more tricky, we can maintain a common file and then each dbms can have its own peculiar changes (i.e. in case of issues specific to a single dbms). Again not easy, tedious, etc, but for sure more easily maintainable is the goal is move all the layers to tools.

Better options? (Apart from get rid of them entirely that may be a bit drastic at the moment :P)
Bugs creator.
Features destroyer.
Template killer.

Re: Databases support install (and upgrade)

Reply #1

The only reason you'd need to keep the separate layer is if you have to index the tables differently depending on backend.

Re: Databases support install (and upgrade)

Reply #2

Indexes may be part of the db-specific part (or at least specific indexes if needed, TBH I have no idea what are the current differences between the three), but that could make sense, tough repeat tables and inserts in all the three seems a bit inefficient...
Bugs creator.
Features destroyer.
Template killer.

Re: Databases support install (and upgrade)

Reply #3

Ohhh.... so long ago!
Well, I'm now messing a lot with both install and upgrade.
Install is already fine, I moved first to a single ".sql" file, then I recently rewrote it to use a class instead, so a single php file. Much cleaner.
Upgrade is a little behind because it a bit more messy, though it's catching up: it's not a single file for any dbms, and I'm in the process of converting it to a class as well.
I've also started a general splitting of the install.php and upgrade.php files, in order to better understand what's going on in there and start a kind of refactoring. It's still an early WIP, but it should give some results at some point in the future. lol

Back working on upgrade now!

For the reference, this is the code I'm working on:
https://github.com/elkarte/Elkarte/pull/2051
Bugs creator.
Features destroyer.
Template killer.

Re: Databases support install (and upgrade)

Reply #4

wOOt  :D ... thats awesome!  Its fun to look way back and see what those files looked like a couple of years ago, they have come a long way.

Re: Databases support install (and upgrade)

Reply #5

Indeed, indeed! :D

Now support other database systems will be a slightly smaller pain! :P

The only tiny thing I'm not entirely happy about is that I'm not sure it's possible to pause the sub-steps, but honestly I'm not entirely sure it was possible with the old code as well, so I didn't pay much attention either. lol
There is also a kind of pending piece, but again I'm not sure how worth it is: in the old code, ALTER TABLEs had several checks to wait until the alteration was finished. I feel this was working reliably only when running with javascript available and on MySQL, for that reason I didn't spend much time trying to re-implement it, I just added few mock methods and some comments, but I left everything unfinished.

And just for tracking: actually, the main reason I found in the code for having additional dbms-specific files in the install/upgrade process was for postgre to add the custom functions at the beginning, so I gave the possibility to have one additional file at the beginning of the process. If more are needed in the future tweak that part would be easy. :D
Bugs creator.
Features destroyer.
Template killer.