use [iWare.SCADA]

--- EquipmentWorkingLogÐÂÔöÍâ¼üÁÐEquipId   ±ä¸üÊ±¼äµã£º2023-02-23
IF NOT EXISTS ( SELECT  *
                FROM    syscolumns
                WHERE   id = OBJECT_ID('EquipmentWorkingLog')
                        AND name = 'EquipId' )
    BEGIN
        ALTER TABLE dbo.EquipmentWorkingLog ADD  EquipId  BIGINT NOT NULL
    END
GO

IF NOT EXISTS ( SELECT  *
                FROM    information_schema.KEY_COLUMN_USAGE
                WHERE   CONSTRAINT_NAME='FK_EquipmentWorkingLog_EquipmentBaseInfo_EquipId')
    BEGIN
        ALTER TABLE dbo.KnifeToolDataMonitor ADD  constraint FK_EquipmentWorkingLog_EquipmentBaseInfo_EquipId FOREIGN KEY (EquipId)
		references EquipmentBaseInfo(Id)
    END
GO

--- KnifeToolDataMonitorÐÂÔöÍâ¼üÁÐEquipId   ±ä¸üÊ±¼äµã£º2023-02-23
IF NOT EXISTS ( SELECT  *
                FROM    syscolumns
                WHERE   id = OBJECT_ID('KnifeToolDataMonitor')
                        AND name = 'EquipId' )
    BEGIN
        ALTER TABLE dbo.KnifeToolDataMonitor ADD  EquipId  BIGINT NOT NULL
    END
GO

IF NOT EXISTS ( SELECT  *
                FROM    information_schema.KEY_COLUMN_USAGE
                WHERE   CONSTRAINT_NAME='FK_KnifeToolDataMonitor_EquipmentBaseInfo_EquipId')
    BEGIN
        ALTER TABLE dbo.KnifeToolDataMonitor ADD  constraint FK_KnifeToolDataMonitor_EquipmentBaseInfo_EquipId FOREIGN KEY (EquipId)
		references EquipmentBaseInfo(Id)
    END
GO



alter table [ThreadStatusMonitor] alter column Threadstatue int null
alter table [ThreadStatusMonitor] alter column Threadendtime datetime2(7) null