-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
Could you please create a UUID option or field in the PostgreSQL-generated script in the Norma Visual Studio extension? Postgres offers a UUID field, and I need to make an ALTER statement to add the UUID field in my Docker Compose script, rather than editing it through the Norma GUI. It would be advantageous to have this field in the Norma interface.
Here is example of a generated script by copilot:
-- UUID Column Migration Script
-- This script ensures the uuidvalue column is native PostgreSQL UUID type
-- Run this AFTER the initial schema has been created
BEGIN;
-- Connect to the ulu database
\c ulu;
-- Enable UUID extension first
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- Simple ALTER COLUMN to convert varchar to UUID
-- PostgreSQL can automatically convert valid UUID strings to UUID type
ALTER TABLE ulu_levels.uuid
ALTER COLUMN uuidvalue TYPE UUID
USING uuidvalue::UUID;
-- Add unique constraint only if it doesn't already exist
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM pg_constraint
WHERE conname = 'uk_uuid_uuidvalue'
) THEN
ALTER TABLE ulu_levels.uuid
ADD CONSTRAINT uk_uuid_uuidvalue UNIQUE (uuidvalue);
END IF;
END
$$;
-- Add index for better performance
CREATE INDEX IF NOT EXISTS idx_uuid_uuidvalue
ON ulu_levels.uuid(uuidvalue);
-- Verify the column type change
SELECT
column_name,
data_type,
is_nullable
FROM information_schema.columns
WHERE table_schema = 'ulu_levels'
AND table_name = 'uuid'
AND column_name = 'uuidvalue';
COMMIT;
Marc Noon
Metadata
Metadata
Assignees
Labels
No labels