/***** Object:  Table [PHARM].[T_ADDITIONAL_BARCODE_ATTRIBUTE] *****/
CREATE TABLE [PHARM].[T_ADDITIONAL_BARCODE_ATTRIBUTE]
(
    [AdditionalBarcodeAttributeID] uniqueidentifier NOT NULL,
    [BarcodeTemplateAttribute] uniqueidentifier NOT NULL,
    [Name] varchar(255) NOT NULL,
    [Lexem] varchar(max) NOT NULL
)
ON [PRIMARY]
GO
ALTER TABLE [PHARM].[T_ADDITIONAL_BARCODE_ATTRIBUTE] ADD CONSTRAINT [PK_T_ADDITIONAL_BARCODE_ATTRIBUTE]
PRIMARY KEY CLUSTERED ([AdditionalBarcodeAttributeID]) ON [PRIMARY]
GO
ALTER TABLE [PHARM].[T_ADDITIONAL_BARCODE_ATTRIBUTE] ADD CONSTRAINT [FK_T_BARCODE_TEMPLATE_ATTRIBUTE_T_ADDITIONAL_BARCODE_ATTRIBUTE_BarcodeTemplateAttribute]
FOREIGN KEY([BarcodeTemplateAttribute]) REFERENCES [PHARM].[T_BARCODE_TEMPLATE_ATTRIBUTE] ([BarcodeTemplateAttributeID])
GO

/***** Object:  Table [PHARM].[T_BARCODE_TEMPLATE] *****/
ALTER TABLE [PHARM].[T_BARCODE_TEMPLATE] ADD [Version] int NULL
GO
UPDATE [PHARM].[T_BARCODE_TEMPLATE] SET [Version] = 102
GO
ALTER TABLE [PHARM].[T_BARCODE_TEMPLATE] ALTER COLUMN [Version] int NOT NULL
GO

/***** Object:  Table [PHARM].[T_BARCODE_TEMPLATE_ATTRIBUTE] *****/
ALTER TABLE [PHARM].[T_BARCODE_TEMPLATE_ATTRIBUTE] ADD [Name] varchar(255) NULL
GO
ALTER TABLE [PHARM].[T_BARCODE_TEMPLATE_ATTRIBUTE] ADD [BarcodeTemplateAttribute] uniqueidentifier NULL
GO
ALTER TABLE [PHARM].[T_BARCODE_TEMPLATE_ATTRIBUTE] ADD CONSTRAINT [FK_T_BARCODE_TEMPLATE_ATTRIBUTE_T_BARCODE_TEMPLATE_ATTRIBUTE_BarcodeTemplateAttribute]
FOREIGN KEY([BarcodeTemplateAttribute]) REFERENCES [PHARM].[T_BARCODE_TEMPLATE_ATTRIBUTE] ([BarcodeTemplateAttributeID])
GO