I have managed to convert most of my schema from mysql to postgres but it doesn't seem to convert the functions or triggers.
i have used the mysql editor in the program but it doesn't seem to show any errors and looks like it executed fine but no triggers or functions seem to appear.
can anyone help.
Code:
create or replace function prodotti_price_log_after_insert_trigger()
returns trigger
language plpgsql volatile as $$
declare previous_price real;
begin
SELECT prezzobuy INTO previous_price FROM prodotti WHERE codart=NEW.codart;
IF previous_price > NEW.prezzobuy THEN
UPDATE prodotti_descriptions SET social_networks_reduced=0 WHERE codart=NEW.codart;
END IF;
end
$$;
Code:
create or replace function shopto_customers_before_update_trigger()
returns trigger
language plpgsql volatile as $$
declare exists_already integer;
begin
IF NEW.platforms <> OLD.platforms THEN
SELECT count(*) INTO exists_already FROM shopto_newsletters WHERE customer_id=OLD.id;
IF exists_already > 0 THEN
UPDATE shopto_newsletters SET platforms=NEW.platforms WHERE customer_id=NEW.id;
ELSE
INSERT INTO shopto_newsletters (created, modified, email, platforms, customer_id) VALUES (now(), now(), NEW.email, NEW.platforms, NEW.id);
END IF;
END IF;
end
$$;
Code:
create or replace function mtdb_magic_modified()
returns trigger
language plpgsql stable as $$
begin
NEW.modified = CURRENT_TIMESTAMP;
return new;
end;
$$;
those are just a few