<?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.1.2</id>
	<title>Heureka database upgrade script 0.5.1.2 - 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.1.2"/>
	<link rel="alternate" type="text/html" href="https://www.heurekaslu.se/w/index.php?title=Heureka_database_upgrade_script_0.5.1.2&amp;action=history"/>
	<updated>2026-11-08T09:01:44Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://www.heurekaslu.se/w/index.php?title=Heureka_database_upgrade_script_0.5.1.2&amp;diff=2779&amp;oldid=prev</id>
		<title>Peder at 13:50, 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.1.2&amp;diff=2779&amp;oldid=prev"/>
		<updated>2009-07-14T13:50:43Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&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 14:50, 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=&quot;diff-marker&quot; data-marker=&quot;−&quot;&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 style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Heureka database upgrade &lt;/del&gt;scripts | Back to scripts]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&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 style=&quot;font-weight: bold; text-decoration: none;&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 class=&quot;diff-marker&quot;&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=&quot;diff-marker&quot;&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=&quot;diff-marker&quot;&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 = &amp;#039;0.5.1.1&amp;#039; OR ApplicationVersion = &amp;#039;0.5.1.2&amp;#039; ) = 0&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&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 = &amp;#039;0.5.1.1&amp;#039; OR ApplicationVersion = &amp;#039;0.5.1.2&amp;#039; ) = 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-l135&quot;&gt;Line 135:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 135:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&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=&quot;diff-marker&quot;&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=&quot;diff-marker&quot;&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;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&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;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&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=&quot;diff-marker&quot; data-marker=&quot;+&quot;&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 style=&quot;font-weight: bold; text-decoration: none;&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.1.2&amp;diff=1214&amp;oldid=prev</id>
		<title>Cawa2: New page:  Back to scripts &lt;pre&gt; IF (SELECT COUNT(*) FROM VERSION WHERE ApplicationVersion = &#039;0.5.1.1&#039; OR ApplicationVersion = &#039;0.5.1.2&#039; ) = 0 BEGIN 	PRINT &#039;Wro...</title>
		<link rel="alternate" type="text/html" href="https://www.heurekaslu.se/w/index.php?title=Heureka_database_upgrade_script_0.5.1.2&amp;diff=1214&amp;oldid=prev"/>
		<updated>2009-02-27T10:54:01Z</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.1.1&amp;#039; OR ApplicationVersion = &amp;#039;0.5.1.2&amp;#039; ) = 0 BEGIN 	PRINT &amp;#039;Wro...&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 = &amp;#039;0.5.1.1&amp;#039; OR ApplicationVersion = &amp;#039;0.5.1.2&amp;#039; ) = 0&lt;br /&gt;
BEGIN&lt;br /&gt;
	PRINT &amp;#039;Wrong Version of database. You must upgrade to version 0.5.1.1 before running this script.&amp;#039;;&lt;br /&gt;
	SELECT ApplicationVersion FROM VERSION;&lt;br /&gt;
END&lt;br /&gt;
ELSE &lt;br /&gt;
BEGIN&lt;br /&gt;
&lt;br /&gt;
	/*===================== 1. Constraints on importsource in area ==========================*/&lt;br /&gt;
&lt;br /&gt;
	--1. Change constraint on column ImportSource in table Area&lt;br /&gt;
&lt;br /&gt;
	ALTER TABLE [dbo].[Area] DROP CONSTRAINT [CK_Area_ImportSource]&lt;br /&gt;
	ALTER TABLE [dbo].[Area]  WITH CHECK ADD  CONSTRAINT [CK_Area_ImportSource] CHECK  (([ImportSource]&amp;gt;=(1) AND [ImportSource]&amp;lt;=(6)))&lt;br /&gt;
&lt;br /&gt;
	--2. Change description on column ImportSource in table Area&lt;br /&gt;
	IF NOT EXISTS(SELECT 1 FROM ::fn_listextendedproperty (&amp;#039;MS_Description&amp;#039;, &amp;#039;Schema&amp;#039;, &amp;#039;dbo&amp;#039;, &amp;#039;table&amp;#039;, &amp;#039;Area&amp;#039;, &amp;#039;column&amp;#039;, &amp;#039;ImportSource&amp;#039; ))&lt;br /&gt;
	BEGIN&lt;br /&gt;
		EXEC sp_addextendedproperty &lt;br /&gt;
		@name = N&amp;#039;MS_Description&amp;#039;, @value = &amp;#039;NULL = not defined, 1=TAX, 2=IPAK, 3=KNN, 4=Manual, 5=HeurekaInvApplication, 6=StandRegister&amp;#039;,&lt;br /&gt;
		@level0type = N&amp;#039;Schema&amp;#039;, @level0name = dbo, &lt;br /&gt;
		@level1type = N&amp;#039;Table&amp;#039;,  @level1name = Area, &lt;br /&gt;
		@level2type = N&amp;#039;Column&amp;#039;, @level2name = ImportSource;&lt;br /&gt;
	END&lt;br /&gt;
	ELSE&lt;br /&gt;
	BEGIN&lt;br /&gt;
		--Update the extended property.&lt;br /&gt;
		EXEC sp_updateextendedproperty &lt;br /&gt;
		@name = N&amp;#039;MS_Description&amp;#039;, @value = &amp;#039;NULL = not defined, 1=TAX, 2=IPAK, 3=KNN, 4=Manual, 5=HeurekaInvApplication, 6=StandRegister&amp;#039;,&lt;br /&gt;
		@level0type = N&amp;#039;Schema&amp;#039;, @level0name = dbo, &lt;br /&gt;
		@level1type = N&amp;#039;Table&amp;#039;,  @level1name = Area, &lt;br /&gt;
		@level2type = N&amp;#039;Column&amp;#039;, @level2name = ImportSource;&lt;br /&gt;
	END&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	/*===================== 2. Changes to StandObject ==========================*/&lt;br /&gt;
&lt;br /&gt;
	--1. Add columns for QMD&lt;br /&gt;
	IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = &amp;#039;StandObject&amp;#039; AND COLUMN_NAME = &amp;#039;QuadraticMeanDiameter&amp;#039;)&lt;br /&gt;
	BEGIN&lt;br /&gt;
		ALTER TABLE StandObject ADD&lt;br /&gt;
			[QuadraticMeanDiameter] [float] NULL,&lt;br /&gt;
			[QuadraticMeanDiameterPine] [float] NULL,&lt;br /&gt;
			[QuadraticMeanDiameterSpruce] [float] NULL,&lt;br /&gt;
			[QuadraticMeanDiameterBirch] [float] NULL,&lt;br /&gt;
			[QuadraticMeanDiameterAspen] [float] NULL,&lt;br /&gt;
			[QuadraticMeanDiameterOak] [float] NULL,&lt;br /&gt;
			[QuadraticMeanDiameterBeech] [float] NULL,&lt;br /&gt;
			[QuadraticMeanDiameterDeciduous] [float] NULL,&lt;br /&gt;
			[QuadraticMeanDiameterContorta] [float] NULL,&lt;br /&gt;
			[QuadraticMeanDiameterBroadleaf] [float] NULL&lt;br /&gt;
	END&lt;br /&gt;
&lt;br /&gt;
	--2. Remove columns for StemProportion&lt;br /&gt;
	IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = &amp;#039;StandObject&amp;#039; AND COLUMN_NAME = &amp;#039;StemProportionPine&amp;#039;)&lt;br /&gt;
	BEGIN&lt;br /&gt;
		ALTER TABLE StandObject DROP COLUMN&lt;br /&gt;
			[StemProportionPine],&lt;br /&gt;
			[StemProportionSpruce],&lt;br /&gt;
			[StemProportionBirch],&lt;br /&gt;
			[StemProportionAspen],&lt;br /&gt;
			[StemProportionOak],&lt;br /&gt;
			[StemProportionBeech],&lt;br /&gt;
			[StemProportionDeciduous],&lt;br /&gt;
			[StemProportionContorta],&lt;br /&gt;
			[StemProportionBroadleaf]&lt;br /&gt;
	END&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	--3. Add columns for Regeneration informaiton&lt;br /&gt;
	IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = &amp;#039;StandObject&amp;#039; AND COLUMN_NAME = &amp;#039;RegenerationMethod&amp;#039;)&lt;br /&gt;
	BEGIN&lt;br /&gt;
		ALTER TABLE StandObject ADD&lt;br /&gt;
			[RegenerationMethod] [int] NULL,&lt;br /&gt;
			[RegenerationSpecies] [int] NULL&lt;br /&gt;
	END&lt;br /&gt;
&lt;br /&gt;
	--4. Add columns for SoilMoistCode and VegetationTypeCode&lt;br /&gt;
	IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = &amp;#039;StandObject&amp;#039; AND COLUMN_NAME = &amp;#039;SoilMoistCode&amp;#039;)&lt;br /&gt;
	BEGIN&lt;br /&gt;
		ALTER TABLE StandObject ADD&lt;br /&gt;
			[SoilMoistCode] [int] NULL,&lt;br /&gt;
			[VegetationTypeCode] [int] NULL&lt;br /&gt;
	END&lt;br /&gt;
&lt;br /&gt;
	--5. Add columns for MeanDiameter and MeanHeight per species&lt;br /&gt;
	IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = &amp;#039;StandObject&amp;#039; AND COLUMN_NAME = &amp;#039;MeanDiameterPine&amp;#039;)&lt;br /&gt;
	BEGIN&lt;br /&gt;
		ALTER TABLE StandObject ADD&lt;br /&gt;
			[MeanDiameterPine] [float] NULL,&lt;br /&gt;
			[MeanDiameterSpruce] [float] NULL,&lt;br /&gt;
			[MeanDiameterBirch] [float] NULL,&lt;br /&gt;
			[MeanDiameterAspen] [float] NULL,&lt;br /&gt;
			[MeanDiameterOak] [float] NULL,&lt;br /&gt;
			[MeanDiameterBeech] [float] NULL,&lt;br /&gt;
			[MeanDiameterDeciduous] [float] NULL,&lt;br /&gt;
			[MeanDiameterContorta] [float] NULL,&lt;br /&gt;
			[MeanDiameterBroadleaf] [float] NULL,&lt;br /&gt;
			[MeanHeightPine] [float] NULL,&lt;br /&gt;
			[MeanHeightSpruce] [float] NULL,&lt;br /&gt;
			[MeanHeightBirch] [float] NULL,&lt;br /&gt;
			[MeanHeightAspen] [float] NULL,&lt;br /&gt;
			[MeanHeightOak] [float] NULL,&lt;br /&gt;
			[MeanHeightBeech] [float] NULL,&lt;br /&gt;
			[MeanHeightDeciduous] [float] NULL,&lt;br /&gt;
			[MeanHeightContorta] [float] NULL,&lt;br /&gt;
			[MeanHeightBroadleaf] [float] NULL&lt;br /&gt;
	END&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	--6. Add columns for additional userdefined columns&lt;br /&gt;
	IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = &amp;#039;StandObject&amp;#039; AND COLUMN_NAME = &amp;#039;UserDefined4&amp;#039;)&lt;br /&gt;
	BEGIN&lt;br /&gt;
		ALTER TABLE StandObject ADD&lt;br /&gt;
			[UserDefined4] [int] NULL,&lt;br /&gt;
			[UserDefined5] [int] NULL,&lt;br /&gt;
			[UserDefined6] [real] NULL,&lt;br /&gt;
			[UserDefined7] [real] NULL,&lt;br /&gt;
			[UserDefined8] [real] NULL,&lt;br /&gt;
			[UserDefined9] [real] NULL,&lt;br /&gt;
			[UserDefined10] [real] NULL&lt;br /&gt;
	END&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	-- Update Version Table&lt;br /&gt;
&lt;br /&gt;
	UPDATE Version SET ApplicationVersion = &amp;#039;0.5.1.2&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
	PRINT &amp;#039;Success! Database upgrade to version 0.5.1.2&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
END&lt;br /&gt;
&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>