-- Tables

-- Alters

ALTER TABLE [AKUZ].[T_PHARMACY] ADD [Mail] varchar(200) NULL

ALTER TABLE [AKUZ].[T_PHARMACY] ADD [EhrRusBr9ap1s2qb] int NULL

ALTER TABLE [AKUZ].[T_PHARMACY] ADD CONSTRAINT [FK_T_EHR_RUS_BR9AP1S2QB_T_PHARMACY_EhrRusBr9ap1s2qb]
FOREIGN KEY([EhrRusBr9ap1s2qb]) REFERENCES [EHR].[T_EHR_RUS_BR9AP1S2QB] ([EhrRusID])
GO

declare @guid uniqueidentifier = newid()

INSERT INTO [VCLib].[T_OBJECT_MODIFICATION_ACTION]
           ([ObjectModificationActionID]
           ,[Entities]
           ,[Position]
           ,[type_]
           ,[Active]
           ,[Name]
           ,[Instruction]
           ,[InstructionType])
     VALUES
           (@guid
           ,(select top 1 EntityID from vclib.T_ENTITIES where EntName = 'PHARMACY')
           ,1
           ,(select top 1 EntityID from vclib.T_ENTITIES where EntName = 'SINGLE_MODIFICATION_ACTION')
           ,0
           ,'sp_RDS_Pharmacy'
           ,'sp_RDS_Pharmacy'
           ,0)

INSERT INTO [VCLib].[T_OBJECT_MODIFICATION_ACTION_PARAM]
           ([ObjectModificationActionParamID]
           ,[ObjectModificationAction]
           ,[ParamValue]
           ,[Name])
     VALUES
           (newid()
           ,@guid
           ,'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem"><lx:StepString name="ObjectProperties" /><lx:StepString name="IsNew" /></lx:Path>'
           ,'@IsNew')

INSERT INTO [VCLib].[T_OBJECT_MODIFICATION_ACTION_PARAM]
           ([ObjectModificationActionParamID]
           ,[ObjectModificationAction]
           ,[ParamValue]
           ,[Name])
     VALUES
           (newid()
           ,@guid
           ,'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem"><lx:StepString name="Code" /></lx:Path>'
           ,'@ID')
GO