20 lines
537 B
SQL
20 lines
537 B
SQL
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;
|