<?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_1.0.2.1</id>
	<title>Heureka database upgrade script 1.0.2.1 - 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_1.0.2.1"/>
	<link rel="alternate" type="text/html" href="https://www.heurekaslu.se/w/index.php?title=Heureka_database_upgrade_script_1.0.2.1&amp;action=history"/>
	<updated>2026-05-05T20:48:57Z</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_1.0.2.1&amp;diff=3802&amp;oldid=prev</id>
		<title>Cawa2: New page:  Back to scripts  &lt;pre&gt; IF (SELECT COUNT(*) FROM VERSION WHERE ApplicationVersion = '1.0.2.0') = 0 BEGIN 	PRINT 'Wrong Version of database. You must upgrade...</title>
		<link rel="alternate" type="text/html" href="https://www.heurekaslu.se/w/index.php?title=Heureka_database_upgrade_script_1.0.2.1&amp;diff=3802&amp;oldid=prev"/>
		<updated>2010-02-12T15:19:18Z</updated>

		<summary type="html">&lt;p&gt;New page: &lt;a href=&quot;/wiki/Category:Database_scripts&quot; title=&quot;Category:Database scripts&quot;&gt; Back to scripts&lt;/a&gt;  &amp;lt;pre&amp;gt; IF (SELECT COUNT(*) FROM VERSION WHERE ApplicationVersion = &amp;#039;1.0.2.0&amp;#039;) = 0 BEGIN 	PRINT &amp;#039;Wrong Version of database. You must upgrade...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[:Category:Database scripts | Back to scripts]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
IF (SELECT COUNT(*) FROM VERSION WHERE ApplicationVersion = '1.0.2.0') = 0&lt;br /&gt;
BEGIN&lt;br /&gt;
	PRINT 'Wrong Version of database. You must upgrade to version 1.0.2.0 before running this script.';&lt;br /&gt;
END&lt;br /&gt;
ELSE &lt;br /&gt;
BEGIN		&lt;br /&gt;
&lt;br /&gt;
	-- 1. Drop column RejuvenationProposal&lt;br /&gt;
&lt;br /&gt;
	-- 1.1 Drop column RejuvenationProposal from table InvReferenceUnitPlant&lt;br /&gt;
	IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'InvReferenceUnitPlant' AND COLUMN_NAME = 'RejuvenationProposal')&lt;br /&gt;
	BEGIN&lt;br /&gt;
		ALTER TABLE InvReferenceUnitPlant DROP COLUMN RejuvenationProposal&lt;br /&gt;
	END&lt;br /&gt;
&lt;br /&gt;
	-- 1.2 Remove rows containing RejuvenationProposal for ReferenceUnitPlant from InventoryTemplate&lt;br /&gt;
	IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'InventoryTemplate')&lt;br /&gt;
	BEGIN&lt;br /&gt;
		DELETE FROM InventoryTemplate WHERE TableName = 'ReferenceUnitPlant' AND ColumnName = 'RejuvenationProposal'&lt;br /&gt;
	END&lt;br /&gt;
&lt;br /&gt;
	--  2. Add check constraint for column VegitationTypeCode in table ReferenceUnit&lt;br /&gt;
	IF (NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS WHERE CONSTRAINT_NAME = 'ck_ReferenceUnit_VegetationTypeCode')) AND&lt;br /&gt;
		(EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'ReferenceUnit' AND COLUMN_NAME = 'VegetationTypeCode'))&lt;br /&gt;
	BEGIN&lt;br /&gt;
		ALTER TABLE [dbo].[ReferenceUnit]  WITH CHECK ADD  CONSTRAINT [ck_ReferenceUnit_VegetationTypeCode] CHECK  (([VegetationTypeCode]&amp;gt;=(0) AND [VegetationTypeCode]&amp;lt;=(18)))&lt;br /&gt;
		ALTER TABLE [dbo].[ReferenceUnit] CHECK CONSTRAINT [ck_ReferenceUnit_VegetationTypeCode]&lt;br /&gt;
&lt;br /&gt;
	END&lt;br /&gt;
&lt;br /&gt;
	-- Update Version Table&lt;br /&gt;
&lt;br /&gt;
	UPDATE Version SET ApplicationVersion = '1.0.2.1';&lt;br /&gt;
	PRINT 'Success! Database upgrade to version 1.0.2.1';&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
[[Category:Database scripts]]&lt;/div&gt;</summary>
		<author><name>Cawa2</name></author>
	</entry>
</feed>