sozsoft-platform/configs/seeds/sql/object/Prc_T_MaterialRequestLine.sql
2026-10-09 20:02:27 +03:00

43 lines
No EOL
2 KiB
Transact-SQL

IF OBJECT_ID(N'[dbo].[Prc_T_MaterialRequestLine]', 'U') IS NULL
BEGIN
CREATE TABLE [dbo].[Prc_T_MaterialRequestLine]
(
[Id] uniqueidentifier NOT NULL DEFAULT NEWID(),
[TenantId] uniqueidentifier NULL,
[MaterialRequestId] uniqueidentifier NOT NULL,
[ProductId] uniqueidentifier NOT NULL,
[Quantity] decimal(18, 4) NOT NULL,
[UomId] uniqueidentifier NOT NULL,
[FulfillmentMethod] nvarchar(16) NOT NULL DEFAULT 'Purchase',
[DueDate] date NOT NULL,
[RequestReason] nvarchar(256) NOT NULL,
[DeliveredQuantity] decimal(18, 4) NOT NULL DEFAULT 0,
[PlannedQuantity] decimal(18, 4) NULL,
[PurchaseResponsibleUserId] uniqueidentifier NULL,
[LineStatus] nvarchar(16) NOT NULL DEFAULT 'Waiting',
[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_MaterialRequestLine] 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 INDEXPROPERTY(OBJECT_ID(N'[dbo].[Prc_T_MaterialRequestLine]'), 'IX_Prc_T_MaterialRequestLine_MaterialRequestId', 'IndexID') IS NULL
BEGIN
CREATE INDEX [IX_Prc_T_MaterialRequestLine_MaterialRequestId] ON [dbo].[Prc_T_MaterialRequestLine] ([MaterialRequestId] ASC);
END
GO
IF OBJECT_ID(N'[dbo].[FK_Prc_T_MaterialRequestLine_MaterialRequestId]', 'F') IS NULL
BEGIN
ALTER TABLE [dbo].[Prc_T_MaterialRequestLine] ADD CONSTRAINT [FK_Prc_T_MaterialRequestLine_MaterialRequestId] FOREIGN KEY ([MaterialRequestId]) REFERENCES [dbo].[Prc_T_MaterialRequest] ([Id]) ON DELETE CASCADE ON UPDATE NO ACTION;
END
GO