Heureka database upgrade script 0.5.3.1
Revision as of 13:13, 6 May 2009 by Cawa2 (talk | contribs) (New page: Back to scripts <pre> IF (SELECT COUNT(*) FROM VERSION WHERE ApplicationVersion = '0.5.3' OR ApplicationVersion = '0.5.3.1' ) = 0 BEGIN PRINT 'Wron...)
IF (SELECT COUNT(*) FROM VERSION WHERE ApplicationVersion = '0.5.3' OR ApplicationVersion = '0.5.3.1' ) = 0 BEGIN PRINT 'Wrong Version of database. You must upgrade to version 0.5.3 before running this script.'; SELECT ApplicationVersion FROM VERSION; END ELSE BEGIN -- 1. Add table TreatmentUnitNeighbour IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'TreatmentUnitNeighbour') BEGIN CREATE TABLE [dbo].[TreatmentUnitNeighbour]( [TreatmentUnitGUID] [uniqueidentifier] NOT NULL, [TreatmentUnitNeighbourGUID] [uniqueidentifier] NOT NULL, [CommonBorderLength] [int] NOT NULL, CONSTRAINT [PK_TreatmentUnitNeighbour] PRIMARY KEY CLUSTERED ( [TreatmentUnitGUID] ASC, [TreatmentUnitNeighbourGUID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] ALTER TABLE [dbo].[TreatmentUnitNeighbour] WITH CHECK ADD CONSTRAINT [FK_TreatmentUnitNeighbour_TreatmentUnit] FOREIGN KEY([TreatmentUnitGUID]) REFERENCES [dbo].[TreatmentUnit] ([TreatmentUnitGUID]) ON DELETE CASCADE ALTER TABLE [dbo].[TreatmentUnitNeighbour] CHECK CONSTRAINT [FK_TreatmentUnitNeighbour_TreatmentUnit] END -- Update Version Table UPDATE Version SET ApplicationVersion = '0.5.3.1'; PRINT 'Success! Database upgrade to version 0.5.3.1'; END