<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.heurekaslu.se/w/index.php?action=history&amp;feed=atom&amp;title=Heureka_database_upgrade_script_0.5.3</id>
	<title>Heureka database upgrade script 0.5.3 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.heurekaslu.se/w/index.php?action=history&amp;feed=atom&amp;title=Heureka_database_upgrade_script_0.5.3"/>
	<link rel="alternate" type="text/html" href="https://www.heurekaslu.se/w/index.php?title=Heureka_database_upgrade_script_0.5.3&amp;action=history"/>
	<updated>2026-05-05T20:48:32Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.13</generator>
	<entry>
		<id>https://www.heurekaslu.se/w/index.php?title=Heureka_database_upgrade_script_0.5.3&amp;diff=2776&amp;oldid=prev</id>
		<title>Peder at 13:49, 14 July 2009</title>
		<link rel="alternate" type="text/html" href="https://www.heurekaslu.se/w/index.php?title=Heureka_database_upgrade_script_0.5.3&amp;diff=2776&amp;oldid=prev"/>
		<updated>2009-07-14T13:49:24Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 13:49, 14 July 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Heureka database upgrade &lt;/del&gt;scripts | Back to scripts]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:Category:Database &lt;/ins&gt;scripts | Back to scripts]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;IF (SELECT COUNT(*) FROM VERSION WHERE ApplicationVersion = '0.5.2.1' OR ApplicationVersion = '0.5.3' ) = 0&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;IF (SELECT COUNT(*) FROM VERSION WHERE ApplicationVersion = '0.5.2.1' OR ApplicationVersion = '0.5.3' ) = 0&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l118&quot; &gt;Line 118:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 119:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Database]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Database &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;scripts&lt;/ins&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Peder</name></author>
	</entry>
	<entry>
		<id>https://www.heurekaslu.se/w/index.php?title=Heureka_database_upgrade_script_0.5.3&amp;diff=1681&amp;oldid=prev</id>
		<title>Cawa2: New page:  Back to scripts &lt;pre&gt; IF (SELECT COUNT(*) FROM VERSION WHERE ApplicationVersion = '0.5.2.1' OR ApplicationVersion = '0.5.3' ) = 0 BEGIN 	PRINT 'Wrong...</title>
		<link rel="alternate" type="text/html" href="https://www.heurekaslu.se/w/index.php?title=Heureka_database_upgrade_script_0.5.3&amp;diff=1681&amp;oldid=prev"/>
		<updated>2009-04-28T12:35:52Z</updated>

		<summary type="html">&lt;p&gt;New page: &lt;a href=&quot;/w/index.php?title=Heureka_database_upgrade_scripts&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Heureka database upgrade scripts (page does not exist)&quot;&gt; Back to scripts&lt;/a&gt; &amp;lt;pre&amp;gt; IF (SELECT COUNT(*) FROM VERSION WHERE ApplicationVersion = &amp;#039;0.5.2.1&amp;#039; OR ApplicationVersion = &amp;#039;0.5.3&amp;#039; ) = 0 BEGIN 	PRINT &amp;#039;Wrong...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Heureka database upgrade scripts | Back to scripts]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
IF (SELECT COUNT(*) FROM VERSION WHERE ApplicationVersion = '0.5.2.1' OR ApplicationVersion = '0.5.3' ) = 0&lt;br /&gt;
BEGIN&lt;br /&gt;
	PRINT 'Wrong Version of database. You must upgrade to version 0.5.2.1 before running this script.';&lt;br /&gt;
	SELECT ApplicationVersion FROM VERSION;&lt;br /&gt;
END&lt;br /&gt;
ELSE &lt;br /&gt;
BEGIN		&lt;br /&gt;
		-- 1. Rename columns in StandObject&lt;br /&gt;
&lt;br /&gt;
		IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'StandObject' AND COLUMN_NAME = 'ProportionPine')&lt;br /&gt;
		BEGIN&lt;br /&gt;
			exec sp_rename 'StandObject.ProportionPine', 'Proportion_Pine', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.ProportionSpruce', 'Proportion_Spruce', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.ProportionBirch', 'Proportion_Birch', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.ProportionAspen', 'Proportion_Aspen', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.ProportionOak', 'Proportion_Oak', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.ProportionBeech', 'Proportion_Beech', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.ProportionDeciduous', 'Proportion_Deciduous', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.ProportionContorta', 'Proportion_Contorta', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.ProportionBroadleaf', 'Proportion_Broadleaf', 'COLUMN';&lt;br /&gt;
			&lt;br /&gt;
			exec sp_rename 'StandObject.QuadraticMeanDiameterPine', 'QuadraticMeanDiameter_Pine', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.QuadraticMeanDiameterSpruce', 'QuadraticMeanDiameter_Spruce', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.QuadraticMeanDiameterBirch', 'QuadraticMeanDiameter_Birch', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.QuadraticMeanDiameterAspen', 'QuadraticMeanDiameter_Aspen', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.QuadraticMeanDiameterOak', 'QuadraticMeanDiameter_Oak', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.QuadraticMeanDiameterBeech', 'QuadraticMeanDiameter_Beech', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.QuadraticMeanDiameterDeciduous', 'QuadraticMeanDiameter_Deciduous', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.QuadraticMeanDiameterContorta', 'QuadraticMeanDiameter_Contorta', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.QuadraticMeanDiameterBroadleaf', 'QuadraticMeanDiameter_Broadleaf', 'COLUMN';&lt;br /&gt;
&lt;br /&gt;
			exec sp_rename 'StandObject.MeanDiameterPine', 'MeanDiameter_Pine', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.MeanDiameterSpruce', 'MeanDiameter_Spruce', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.MeanDiameterBirch', 'MeanDiameter_Birch', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.MeanDiameterAspen', 'MeanDiameter_Aspen', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.MeanDiameterOak', 'MeanDiameter_Oak', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.MeanDiameterBeech', 'MeanDiameter_Beech', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.MeanDiameterDeciduous', 'MeanDiameter_Deciduous', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.MeanDiameterContorta', 'MeanDiameter_Contorta', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.MeanDiameterBroadleaf', 'MeanDiameter_Broadleaf', 'COLUMN';&lt;br /&gt;
&lt;br /&gt;
			exec sp_rename 'StandObject.MeanHeightPine', 'MeanHeight_Pine', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.MeanHeightSpruce', 'MeanHeight_Spruce', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.MeanHeightBirch', 'MeanHeight_Birch', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.MeanHeightAspen', 'MeanHeight_Aspen', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.MeanHeightOak', 'MeanHeight_Oak', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.MeanHeightBeech', 'MeanHeight_Beech', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.MeanHeightDeciduous', 'MeanHeight_Deciduous', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.MeanHeightContorta', 'MeanHeight_Contorta', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.MeanHeightBroadleaf', 'MeanHeight_Broadleaf', 'COLUMN';&lt;br /&gt;
&lt;br /&gt;
			exec sp_rename 'StandObject.MeanDiameter', 'MeanDiameterTotal', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.MeanHeight', 'MeanHeightTotal', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.QuadraticMeanDiameter', 'QuadraticMeanDiameterTotal', 'COLUMN';&lt;br /&gt;
			exec sp_rename 'StandObject.LastClearCutYear', 'LastFinalFellingYear', 'COLUMN';&lt;br /&gt;
		END&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
		-- 2. Add columns for arithmetic mean height to table InitialState_SpeciesData&lt;br /&gt;
&lt;br /&gt;
		IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'InitialState_SpeciesData' AND COLUMN_NAME = 'ArithmeticMeanHeightPlantPlots_Unknown')&lt;br /&gt;
		BEGIN&lt;br /&gt;
			ALTER TABLE [InitialState_SpeciesData] ADD&lt;br /&gt;
				[ArithmeticMeanHeightPlantPlots_Unknown] [float] NULL,&lt;br /&gt;
				[ArithmeticMeanHeightPlantPlots_Pine] [float] NULL,&lt;br /&gt;
				[ArithmeticMeanHeightPlantPlots_Spruce] [float] NULL,&lt;br /&gt;
				[ArithmeticMeanHeightPlantPlots_Birch] [float] NULL,&lt;br /&gt;
				[ArithmeticMeanHeightPlantPlots_Aspen] [float] NULL,&lt;br /&gt;
				[ArithmeticMeanHeightPlantPlots_Oak] [float] NULL,&lt;br /&gt;
				[ArithmeticMeanHeightPlantPlots_Beech] [float] NULL,&lt;br /&gt;
				[ArithmeticMeanHeightPlantPlots_Deciduous] [float] NULL,&lt;br /&gt;
				[ArithmeticMeanHeightPlantPlots_Contorta] [float] NULL,&lt;br /&gt;
				[ArithmeticMeanHeightPlantPlots_Broadleaf] [float] NULL&lt;br /&gt;
		END&lt;br /&gt;
&lt;br /&gt;
		-- 3. Add table Cliques&lt;br /&gt;
		IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Cliques')&lt;br /&gt;
		BEGIN&lt;br /&gt;
			CREATE TABLE [dbo].[Cliques](&lt;br /&gt;
				[AreaGUID] [uniqueidentifier] NOT NULL,&lt;br /&gt;
				[CliqueID] [int] NOT NULL,&lt;br /&gt;
				[TreatmentUnitGUID] [uniqueidentifier] NOT NULL&lt;br /&gt;
			 ) ON [PRIMARY]&lt;br /&gt;
			ALTER TABLE [dbo].[Cliques]  WITH CHECK ADD  CONSTRAINT [FK_Cliques_TreatmentUnit] FOREIGN KEY([TreatmentUnitGUID])&lt;br /&gt;
			REFERENCES [dbo].[TreatmentUnit] ([TreatmentUnitGUID])&lt;br /&gt;
			ALTER TABLE [dbo].[Cliques] CHECK CONSTRAINT [FK_Cliques_TreatmentUnit]&lt;br /&gt;
			ALTER TABLE [dbo].[Cliques]  WITH CHECK ADD  CONSTRAINT [FK_Cliques_Area] FOREIGN KEY([AreaGUID])&lt;br /&gt;
			REFERENCES [dbo].[Area] ([AreaGUID])&lt;br /&gt;
			ALTER TABLE [dbo].[Cliques] CHECK CONSTRAINT [FK_Cliques_Area]&lt;br /&gt;
		END&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
		-- 4. Add table HarvestClusters&lt;br /&gt;
		IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'HarvestClusters')&lt;br /&gt;
		BEGIN&lt;br /&gt;
			CREATE TABLE [dbo].[HarvestClusters](&lt;br /&gt;
				[AreaGUID] [uniqueidentifier] NOT NULL,&lt;br /&gt;
				[HarvestClusterID] [int] NOT NULL,&lt;br /&gt;
				[TreatmentUnitGUID] [uniqueidentifier] NOT NULL&lt;br /&gt;
			 ) ON [PRIMARY]&lt;br /&gt;
			ALTER TABLE [dbo].[HarvestClusters]  WITH CHECK ADD  CONSTRAINT [FK_HarvestClusters_TreatmentUnit] FOREIGN KEY([TreatmentUnitGUID])&lt;br /&gt;
			REFERENCES [dbo].[TreatmentUnit] ([TreatmentUnitGUID])&lt;br /&gt;
			ALTER TABLE [dbo].[HarvestClusters] CHECK CONSTRAINT [FK_HarvestClusters_TreatmentUnit]&lt;br /&gt;
			ALTER TABLE [dbo].[HarvestClusters]  WITH CHECK ADD  CONSTRAINT [FK_HarvestClusters_Area] FOREIGN KEY([AreaGUID])&lt;br /&gt;
			REFERENCES [dbo].[Area] ([AreaGUID])&lt;br /&gt;
			ALTER TABLE [dbo].[HarvestClusters] CHECK CONSTRAINT [FK_HarvestClusters_Area]&lt;br /&gt;
		END&lt;br /&gt;
&lt;br /&gt;
	-- Update Version Table&lt;br /&gt;
&lt;br /&gt;
	UPDATE Version SET ApplicationVersion = '0.5.3';&lt;br /&gt;
&lt;br /&gt;
	PRINT 'Success! Database upgrade to version 0.5.3';&lt;br /&gt;
&lt;br /&gt;
END&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Database]]&lt;/div&gt;</summary>
		<author><name>Cawa2</name></author>
	</entry>
</feed>