diff --git a/EnotaryoPH/EnotaryoPH.DbMigration/Scripts/04_EventLog_StreamID.sql b/EnotaryoPH/EnotaryoPH.DbMigration/Scripts/04_EventLog_StreamID.sql new file mode 100644 index 0000000..f42723e --- /dev/null +++ b/EnotaryoPH/EnotaryoPH.DbMigration/Scripts/04_EventLog_StreamID.sql @@ -0,0 +1,19 @@ +BEGIN TRANSACTION; + +-- Create a new column with the desired data type +ALTER TABLE "EventLogs" +ADD COLUMN IF NOT EXISTS "NewStreamID" VARCHAR(255) NOT NULL; + +-- Update values in the new column (cast the original int8 to varchar) +UPDATE "EventLogs" +SET "NewStreamID" = CAST("StreamID" AS VARCHAR); + +-- Drop the original column (keeping only valid data) +ALTER TABLE "EventLogs" +DROP COLUMN "StreamID"; + +-- Rename the new column to the original name +ALTER TABLE "EventLogs" +RENAME COLUMN "NewStreamID" TO "StreamID"; + +COMMIT TRANSACTION;