diff --git a/Backend/Program.cs b/Backend/Program.cs
index a633f479..194c746a 100644
--- a/Backend/Program.cs
+++ b/Backend/Program.cs
@@ -167,6 +167,10 @@ namespace Swarmops.Backend
OutboundComm.CreateNotification(null, NotificationResource.System_Startup);
+ // Checking for schemata upgrade
+
+ DatabaseMaintenance.UpgradeSchemata();
+
// Check for existence of installation ID. If not, create one. Warning: has privacy implications when communicated.
if (Persistence.Key["SwarmopsInstallationId"] == string.Empty)
diff --git a/BuildFiles/Packaging/repackage-build b/BuildFiles/Packaging/repackage-build
index 3b5fbee1..8bb39af6 100755
--- a/BuildFiles/Packaging/repackage-build
+++ b/BuildFiles/Packaging/repackage-build
@@ -1,5 +1,12 @@
#!/bin/bash
+#Update schemata
+cd /home/prod/Smallwebs/Activizr-repo/schemas
+echo "Checking for updates to schema..."
+svn update
+
+cd /home/packager/swarmops
+
#Update all files, including this one. Runpos will remain same in possible new version
echo "Checking for updates to packaging process..."
svn update
@@ -38,9 +45,9 @@ echo ""
echo "Notifying developers that new build has packaged for test/deployment..."
if [ "$DROPFOLDER" == "internal" ]; then
- echo "The packages (swarmops-frontend-internal, swarmops-backend-internal) are available from repositories now, and can be tested at http://dev.swarmops.com/ as usual. Last 3 commits on 'master':" > deploymsg.txt
+ echo "$(cat ../lastbuild/swarmops/internal/CommitMessage.txt)" > deploymsg.txt
echo "" >> deploymsg.txt
- echo "$(cat ../lastbuild/swarmops/internal/CommitMessage.txt)" >> deploymsg.txt
+ echo "The packages (swarmops-frontend-internal, swarmops-backend-internal) are available from repositories now, and can be tested at http://dev.swarmops.com/ as usual. Last 3 commits on 'master':" >> deploymsg.txt
else
echo "NOTE: this is a $DROPFOLDER package bundle. It will deploy automatically to live systems via apt-get upgrade. Yay, we made another sprint!" > deploymsg.txt
fi
diff --git a/BuildFiles/Packaging/repackage-one b/BuildFiles/Packaging/repackage-one
index 51dd4d7e..0c67f218 100755
--- a/BuildFiles/Packaging/repackage-one
+++ b/BuildFiles/Packaging/repackage-one
@@ -158,7 +158,7 @@ scripts/update-repos swarmops-$PACKAGENAME-latest.deb
if [ "$2" == "" ]; then
echo "Installing INTERNAL BUILD on swarmops-dev for testing..."
- dpkg -i swarmops-$PACKAGENAME-latest.deb
+ sudo dpkg -i swarmops-$PACKAGENAME-latest.deb
fi
echo "Cleaning up..."
diff --git a/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.Designer.cs b/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.Designer.cs
index bac65cad..bc17a068 100644
--- a/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.Designer.cs
+++ b/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.Designer.cs
@@ -275,6 +275,26 @@ namespace Swarmops.Logic.App_GlobalResources {
}
}
+ ///
+ /// Looks up a localized string similar to Swarmops Backend [SwarmopsVersion] on host [HostName] has successfully upgraded the Swarmops database schema to revision [DbVersion].
+ ///
+ ///This is for information only. You do not need to take action..
+ ///
+ internal static string System_DatabaseSchemaUpgraded_Body {
+ get {
+ return ResourceManager.GetString("System_DatabaseSchemaUpgraded_Body", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Swarmops database upgraded.
+ ///
+ internal static string System_DatabaseSchemaUpgraded_Subject {
+ get {
+ return ResourceManager.GetString("System_DatabaseSchemaUpgraded_Subject", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to An unhandled exception was thrown in Swarmops:
///
diff --git a/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.resx b/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.resx
index 2f4d1123..49261047 100644
--- a/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.resx
+++ b/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.resx
@@ -112,10 +112,10 @@
2.0
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Your requested cash advance with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat], concerning [RequestPurpose], has been attested by the budget owner. It will now proceed to payout to you.
@@ -206,6 +206,14 @@ Please log on to Swarmops at [SystemUrl] to confirm or reject them.
(ACTION ITEM) [OrganizationName] Receipts Filed - Validation Needed
+
+ Swarmops Backend [SwarmopsVersion] on host [HostName] has successfully upgraded the Swarmops database schema to revision [DbVersion].
+
+This is for information only. You do not need to take action.
+
+
+ Swarmops database upgraded
+
An unhandled exception was thrown in Swarmops:
diff --git a/Logic/Communications/Transmission/NotificationPayload.cs b/Logic/Communications/Transmission/NotificationPayload.cs
index 9d482602..94967d8f 100644
--- a/Logic/Communications/Transmission/NotificationPayload.cs
+++ b/Logic/Communications/Transmission/NotificationPayload.cs
@@ -89,6 +89,7 @@ namespace Swarmops.Logic.Communications.Transmission
Unknown = 0,
System_Startup,
System_Exception,
+ System_DatabaseSchemaUpgraded,
CashAdvance_Requested,
CashAdvance_Attested,
CashAdvance_Deattested,
diff --git a/Logic/Support/DatabaseMaintenance.cs b/Logic/Support/DatabaseMaintenance.cs
index 995fe7c1..5d7608a6 100644
--- a/Logic/Support/DatabaseMaintenance.cs
+++ b/Logic/Support/DatabaseMaintenance.cs
@@ -5,6 +5,9 @@ using System.Net;
using System.Text;
using Swarmops.Logic.Swarm;
using Swarmops.Database;
+using System.Globalization;
+using Swarmops.Logic.Communications;
+using Swarmops.Logic.Communications.Transmission;
namespace Swarmops.Logic.Support
{
@@ -38,7 +41,7 @@ namespace Swarmops.Logic.Support
using (WebClient client = new WebClient())
{
- sql = client.DownloadString("http://packages.swarmops.com/schemas/initialize.sql"); // Hardcoded as security measure - don't want to pass arbitrary sql in from web layer
+ sql = client.DownloadString("http://packages.swarmops.com/schemata/initialize.sql"); // Hardcoded as security measure - don't want to pass arbitrary sql in from web layer
}
string[] sqlCommands = sql.Split('#'); // in the file, the commands are split by a single # sign. (Semicolons are an integral part of storedprocs, so they can't be used.)
@@ -50,5 +53,40 @@ namespace Swarmops.Logic.Support
SwarmDb.GetDatabaseForWriting().SetKeyValue("DbVersion", "1"); // We're at baseline
}
+
+ static public void UpgradeSchemata()
+ {
+ int currentDbVersion = Int32.Parse(SwarmDb.GetDatabaseForReading().GetKeyValue("DbVersion"));
+ int expectedDbVersion = SwarmDb.DbVersion;
+ string sql;
+ bool upgraded = false;
+
+ while (currentDbVersion < expectedDbVersion)
+ {
+ currentDbVersion++;
+
+ string fileName = String.Format("http://packages.swarmops.com/schemata/upgrade-{0:D4}.sql", currentDbVersion);
+
+ using (WebClient client = new WebClient())
+ {
+ sql = client.DownloadString(fileName);
+ }
+
+ string[] sqlCommands = sql.Split('#'); // in the file, the commands are split by a single # sign. (Semicolons are an integral part of storedprocs, so they can't be used.)
+
+ foreach (string sqlCommand in sqlCommands)
+ {
+ SwarmDb.GetDatabaseForAdmin().ExecuteAdminCommand(sqlCommand.Trim());
+ }
+
+ upgraded = true;
+ SwarmDb.GetDatabaseForWriting().SetKeyValue("DbVersion", currentDbVersion.ToString(CultureInfo.InvariantCulture)); // Increment after each successful run
+ }
+
+ if (upgraded)
+ {
+ OutboundComm.CreateNotification(null, NotificationResource.System_DatabaseSchemaUpgraded);
+ }
+ }
}
}