From 8a90a6b170f847d17958b6fc443cdc6585767c48 Mon Sep 17 00:00:00 2001 From: jojo aquino Date: Sat, 26 Apr 2025 09:28:23 +0100 Subject: [PATCH] change StreamID type from int to string --- .../Scripts/04_EventLog_StreamID.sql | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 EnotaryoPH/EnotaryoPH.DbMigration/Scripts/04_EventLog_StreamID.sql 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;