May-11-2018, 09:11 AM
Hi,
In my holiday time I'm working on a huge project for years.
I started to make it open source at the beginning of this year.
Now I'm facing some problems I already expected: How to provide updates.
(Luckily nobody uses this software right now, so I can experiment with possible solutions :) )
While I was the only user of this software, it was easy to do changes by hand.
When I made the software open source, I wrote an installation script (bash) that does all necessary steps to make the software work.
But at the point when it comes to updates it is not that easy to do changes without breaking anything.
I need to do the following things:
An example of the database-adding-column-problem I already solved:
To add a new column to a table in the database the software manages I run during the installation the following script lines.
sqlite3 "$DATAPATH/database.db" "PRAGMA table_info(\"tablename\");" | grep "columnname" > /dev/null
if [ $? -ne 0 ]; then
sqlite3 "$DATAPATH/database.db" 'ALTER TABLE tablename ADD COLUMN columname TEXT DEFAULT "";'
fi
This is ugly as hell.
So my questions is:
How do I manage such updates?
I'm working for over six years on this software and one of its strength is that I always remove features I do not use a lot (Including removing configuration sections and database columns).
And I add a new feature when I need it as I want to have it. When I need to refactor things, I do it. Which leads to adding sections to the configuration and the database.
Clean code has highes priority. When I have to restructure the database or configuration, I want to do it.
I do not want to loose this flexibility.
In my holiday time I'm working on a huge project for years.
I started to make it open source at the beginning of this year.
Now I'm facing some problems I already expected: How to provide updates.
(Luckily nobody uses this software right now, so I can experiment with possible solutions :) )
While I was the only user of this software, it was easy to do changes by hand.
When I made the software open source, I wrote an installation script (bash) that does all necessary steps to make the software work.
But at the point when it comes to updates it is not that easy to do changes without breaking anything.
I need to do the following things:
- Updating a database: Adding/Removing columns
- Updating a ini-configuration: Adding/Removing Keys and Sections
- Updating a javascript file: Adding/Removing lines
- Updating user data directory structures: Adding/Removing/Moving files and directories (I do not mean the software directory, that can be simply updated from the sources via rsync)
An example of the database-adding-column-problem I already solved:
To add a new column to a table in the database the software manages I run during the installation the following script lines.
sqlite3 "$DATAPATH/database.db" "PRAGMA table_info(\"tablename\");" | grep "columnname" > /dev/null
if [ $? -ne 0 ]; then
sqlite3 "$DATAPATH/database.db" 'ALTER TABLE tablename ADD COLUMN columname TEXT DEFAULT "";'
fi
This is ugly as hell.
So my questions is:
How do I manage such updates?
I'm working for over six years on this software and one of its strength is that I always remove features I do not use a lot (Including removing configuration sections and database columns).
And I add a new feature when I need it as I want to have it. When I need to refactor things, I do it. Which leads to adding sections to the configuration and the database.
Clean code has highes priority. When I have to restructure the database or configuration, I want to do it.
I do not want to loose this flexibility.