Merge branch 'master' of https://github.com/Swarmops/Swarmops
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 listed above." >> 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
|
||||
|
||||
@@ -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 --force-confdef swarmops-$PACKAGENAME-latest.deb
|
||||
fi
|
||||
|
||||
echo "Cleaning up..."
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,119 @@
|
||||
|
||||
ALTER TABLE `FinancialAccounts`
|
||||
ADD COLUMN `Active` TINYINT NOT NULL DEFAULT '1' AFTER `Administrative`,
|
||||
ADD COLUMN `LinkBackward` INT NOT NULL DEFAULT 0 AFTER `Active`,
|
||||
ADD COLUMN `LinkForward` INT NOT NULL DEFAULT 0 AFTER `LinkBackward`
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
CREATE PROCEDURE `SetFinancialAccountActive`(
|
||||
IN financialAccountId INTEGER,
|
||||
IN active TINYINT
|
||||
)
|
||||
BEGIN
|
||||
|
||||
UPDATE FinancialAccounts SET FinancialAccounts.Active = active
|
||||
WHERE FinancialAccounts.FinancialAccountId=financialAccountId;
|
||||
|
||||
END
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
|
||||
CREATE PROCEDURE `SetFinancialAccountExpensable`(
|
||||
IN financialAccountId INTEGER,
|
||||
IN expensable TINYINT
|
||||
)
|
||||
BEGIN
|
||||
|
||||
UPDATE FinancialAccounts SET FinancialAccounts.Expensable = expensable
|
||||
WHERE FinancialAccounts.FinancialAccountId=financialAccountId;
|
||||
|
||||
END
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
|
||||
CREATE PROCEDURE `SetFinancialAccountAdministrative`(
|
||||
IN financialAccountId INTEGER,
|
||||
IN administrative TINYINT
|
||||
)
|
||||
BEGIN
|
||||
|
||||
UPDATE FinancialAccounts SET FinancialAccounts.Administrative = administrative
|
||||
WHERE FinancialAccounts.FinancialAccountId=financialAccountId;
|
||||
|
||||
END
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
|
||||
CREATE PROCEDURE `SetFinancialAccountLinkBackward`(
|
||||
IN financialAccountId INTEGER,
|
||||
IN linkBackward INTEGER
|
||||
)
|
||||
BEGIN
|
||||
|
||||
UPDATE FinancialAccounts SET FinancialAccounts.LinkBackward = linkBackward
|
||||
WHERE FinancialAccounts.FinancialAccountId=financialAccountId;
|
||||
|
||||
END
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
CREATE PROCEDURE `SetFinancialAccountLinkForward`(
|
||||
IN financialAccountId INTEGER,
|
||||
IN linkForward INTEGER
|
||||
)
|
||||
BEGIN
|
||||
|
||||
UPDATE FinancialAccounts SET FinancialAccounts.LinkForward = linkForward
|
||||
WHERE FinancialAccounts.FinancialAccountId=financialAccountId;
|
||||
|
||||
END
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
|
||||
CREATE PROCEDURE `SetFinancialAccountParent`(
|
||||
IN financialAccountId INTEGER,
|
||||
IN parentFinancialAccountId INTEGER
|
||||
)
|
||||
BEGIN
|
||||
|
||||
UPDATE FinancialAccounts SET FinancialAccounts.ParentFinancialAccountId = parentFinancialAccountId
|
||||
WHERE FinancialAccounts.FinancialAccountId=financialAccountId;
|
||||
|
||||
END
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
CREATE PROCEDURE `MoveFinancialTransactionRowRangeToNewAccount`(
|
||||
IN oldFinancialAccountId INTEGER,
|
||||
IN newFinancialAccountId INTEGER,
|
||||
IN startDate DATETIME,
|
||||
IN endDate DATETIME
|
||||
)
|
||||
BEGIN
|
||||
|
||||
UPDATE FinancialTransactionRows
|
||||
JOIN FinancialTransactions ON FinancialTransactions.FinancialTransactionId=FinancialTransactionRows.FinancialTransactionId
|
||||
SET FinancialTransactionRows.FinancialAccountId=newFinancialAccountId
|
||||
WHERE FinancialTransactions.DateTime >= startDate AND FinancialTransactions.DateTime < endDate
|
||||
AND FinancialTransactionRows.FinancialAccountId=oldFinancialAccountId;
|
||||
|
||||
END
|
||||
Generated
+20
@@ -315,6 +315,26 @@ namespace Swarmops.Logic.App_GlobalResources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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..
|
||||
/// </summary>
|
||||
internal static string System_DatabaseSchemaUpgraded_Body {
|
||||
get {
|
||||
return ResourceManager.GetString("System_DatabaseSchemaUpgraded_Body", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Swarmops database upgraded.
|
||||
/// </summary>
|
||||
internal static string System_DatabaseSchemaUpgraded_Subject {
|
||||
get {
|
||||
return ResourceManager.GetString("System_DatabaseSchemaUpgraded_Subject", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to An unhandled exception was thrown in Swarmops:
|
||||
///
|
||||
|
||||
@@ -222,6 +222,14 @@ Please log on to Swarmops at [SystemUrl] to confirm or reject them.</value>
|
||||
<data name="Receipts_Filed_Subject" xml:space="preserve">
|
||||
<value>(ACTION ITEM) [OrganizationName] Receipts Filed - Validation Needed</value>
|
||||
</data>
|
||||
<data name="System_DatabaseSchemaUpgraded_Body" xml:space="preserve">
|
||||
<value>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.</value>
|
||||
</data>
|
||||
<data name="System_DatabaseSchemaUpgraded_Subject" xml:space="preserve">
|
||||
<value>Swarmops database upgraded</value>
|
||||
</data>
|
||||
<data name="System_Exception_Body" xml:space="preserve">
|
||||
<value>An unhandled exception was thrown in Swarmops:
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ namespace Swarmops.Logic.Communications.Transmission
|
||||
Unknown = 0,
|
||||
System_Startup,
|
||||
System_Exception,
|
||||
System_DatabaseSchemaUpgraded,
|
||||
CashAdvance_Requested,
|
||||
CashAdvance_Attested,
|
||||
CashAdvance_Deattested,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user