-- ============================================================
--  MSSQL — add the settings columns the new Settings page needs.
--  Your existing tables (links, tblDesign, users) are NOT changed
--  except for these three additive, nullable columns on tblDesign.
--  Idempotent: safe to run more than once.
--
--  Run against your StudentInfo database.
-- ============================================================

USE [StudentInfo];
GO

IF COL_LENGTH('dbo.tblDesign', 'name') IS NULL
    ALTER TABLE dbo.tblDesign ADD [name] NVARCHAR(200) NULL;
GO

IF COL_LENGTH('dbo.tblDesign', 'location') IS NULL
    ALTER TABLE dbo.tblDesign ADD [location] NVARCHAR(300) NULL;
GO

IF COL_LENGTH('dbo.tblDesign', 'title') IS NULL
    ALTER TABLE dbo.tblDesign ADD [title] NVARCHAR(300) NULL;
GO

-- Seed the new columns from the existing header text on first run.
UPDATE dbo.tblDesign
   SET [name]  = COALESCE([name],  txtHeader),
       [title] = COALESCE([title], txtHeader)
 WHERE [name] IS NULL OR [title] IS NULL;
GO
