HRM-10/UsersEmailColumn_DB_Changes.sql

27 lines
952 B
MySQL
Raw Normal View History

2026-11-11 12:09:05 +06:00
/*
UsersEmailColumn_DB_Changes.sql
Why:
UserDA.Insert (HRM.DA/DA/Users/UserDA.cs) writes both dbo.Users.EmailAddress and
dbo.Users.Email. Some databases only have EmailAddress (UserEmailAddress_DB_Changes.sql),
and on those every new user fails with "Invalid column name 'Email'".
What:
Adds dbo.Users.Email as nvarchar(1000) NULL (same type as EmailAddress) when it is missing.
Existing rows are left NULL; reads that need an address use COALESCE(EmailAddress, Email)
(see CalendarItemDA.UserEmailExpression).
Run order:
Any time; safe to run before or after the matching code is deployed.
Re-runnable: does nothing when the column already exists.
*/
IF COL_LENGTH('dbo.Users', 'Email') IS NULL
BEGIN
ALTER TABLE dbo.Users ADD Email nvarchar(1000) NULL;
PRINT 'dbo.Users.Email added.';
END
ELSE
PRINT 'dbo.Users.Email already exists - nothing to do.';
GO