IF OBJECT_ID(N'[dbo].[Prc_T_PurchaseOrderLine]', 'U') IS NULL BEGIN CREATE TABLE [dbo].[Prc_T_PurchaseOrderLine] ( [Id] uniqueidentifier NOT NULL DEFAULT NEWID(), [TenantId] uniqueidentifier NULL, [PurchaseOrderId] uniqueidentifier NOT NULL, [ProductId] uniqueidentifier NOT NULL, [Description] nvarchar(512) NULL, [Quantity] decimal(18, 4) NOT NULL DEFAULT 1, [UomId] nvarchar(50) NOT NULL DEFAULT 'Adet', [UnitPrice] decimal(18, 4) NOT NULL DEFAULT 0, [TaxRate] decimal(18, 4) NOT NULL DEFAULT 20, [Amount] decimal(18, 4) NOT NULL DEFAULT 0, [DeliveryDate] datetime NULL, [MaterialRequestItemId] uniqueidentifier NULL, [PurchaseRfqLineId] uniqueidentifier NULL, [ReceivedQuantity] decimal(18, 4) NOT NULL DEFAULT 0, [CreationTime] datetime2 NOT NULL DEFAULT GETUTCDATE(), [CreatorId] uniqueidentifier NULL, [LastModificationTime] datetime2 NULL, [LastModifierId] uniqueidentifier NULL, [IsDeleted] bit NOT NULL DEFAULT 0, [DeletionTime] datetime2 NULL, [DeleterId] uniqueidentifier NULL, CONSTRAINT [PK_Prc_T_PurchaseOrderLine] PRIMARY KEY NONCLUSTERED ( [Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO IF OBJECT_ID(N'[dbo].[FK_Prc_T_PurchaseOrderLine_PurchaseOrderId]', 'F') IS NULL BEGIN ALTER TABLE [dbo].[Prc_T_PurchaseOrderLine] ADD CONSTRAINT [FK_Prc_T_PurchaseOrderLine_PurchaseOrderId] FOREIGN KEY ([PurchaseOrderId]) REFERENCES [dbo].[Prc_T_PurchaseOrder] ([Id]) ON DELETE CASCADE ON UPDATE NO ACTION; END GO