---------------------- UP ---------------------------
BEGIN TRANSACTION;
GO

DECLARE @var0 sysname;
SELECT @var0 = [d].[name]
FROM [sys].[default_constraints] [d]
INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id]
WHERE ([d].[parent_object_id] = OBJECT_ID(N'[Stems]') AND [c].[name] = N'IndexNumber');
IF @var0 IS NOT NULL EXEC(N'ALTER TABLE [Stems] DROP CONSTRAINT [' + @var0 + '];');
ALTER TABLE [Stems] ALTER COLUMN [IndexNumber] nvarchar(50) NOT NULL;
GO

ALTER TABLE [Stems] ADD [ProductionOrder] nvarchar(50) NOT NULL DEFAULT N'';
GO

CREATE INDEX [UX_StemRfId] ON [ProcessDatas] ([MachineId], [StemRfId]);
GO

INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20240702095506_UpdatedStem', N'7.0.7');
GO

COMMIT;
GO




-------------------------- DOWN -------------------------------

BEGIN TRANSACTION;
GO

DROP INDEX [UX_StemRfId] ON [ProcessDatas];
GO

DECLARE @var0 sysname;
SELECT @var0 = [d].[name]
FROM [sys].[default_constraints] [d]
INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id]
WHERE ([d].[parent_object_id] = OBJECT_ID(N'[Stems]') AND [c].[name] = N'ProductionOrder');
IF @var0 IS NOT NULL EXEC(N'ALTER TABLE [Stems] DROP CONSTRAINT [' + @var0 + '];');
ALTER TABLE [Stems] DROP COLUMN [ProductionOrder];
GO

DECLARE @var1 sysname;
SELECT @var1 = [d].[name]
FROM [sys].[default_constraints] [d]
INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id]
WHERE ([d].[parent_object_id] = OBJECT_ID(N'[Stems]') AND [c].[name] = N'IndexNumber');
IF @var1 IS NOT NULL EXEC(N'ALTER TABLE [Stems] DROP CONSTRAINT [' + @var1 + '];');
ALTER TABLE [Stems] ALTER COLUMN [IndexNumber] int NOT NULL;
GO

DELETE FROM [__EFMigrationsHistory]
WHERE [MigrationId] = N'20240702095506_UpdatedStem';
GO

COMMIT;
GO