IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'OutputKindFk'
    WHERE SysObjects.Name = 'Ware'
)
BEGIN
  ALTER TABLE Ware ADD [OutputKindFk] Int NULL

CREATE TABLE dbo.[ArrangementLineLog] (
[ArrangementLineLogPk] Int NOT NULL,
[ArrangementLineFk] Int NULL,
[WareFk] Int NULL,
[DateStamp] DateTime NOT NULL,
[Text] NVarchar (50) NOT NULL,
[Pcs] Int NOT NULL) ON [Primary]

CREATE TABLE dbo.[TicketLog] (
[TicketLogPk] Int NOT NULL,
[ArrangementLineLogFk] Int NOT NULL,
[ReferenceNumber] Int NOT NULL,
[GuestNumber] Int NOT NULL,
[StaffFk] Int NOT NULL,
[Pcs] Int NOT NULL,
[DateStamp] DateTime NOT NULL,
[Comment] NVarchar (50) NULL) ON [Primary]
END
GO

ALTER TABLE Ware WITH NOCHECK ADD CONSTRAINT FK_Ware_OutputKind FOREIGN KEY (OutputKindFk) REFERENCES PrinterTypes (PkPrinterType)

