BEGIN TRANSACTION;

DO $$
BEGIN
	BEGIN
		ALTER TABLE flows ADD COLUMN template VARCHAR(100) NOT NULL DEFAULT '';
	EXCEPTION
		WHEN duplicate_column THEN RAISE NOTICE 'Info : Column not added, already exists';
	END;
END;
$$;

UPDATE flows SET template = 'dcns' WHERE template = '';

ALTER TABLE flows ALTER COLUMN templates DROP DEFAULT;

COMMIT;