BEGIN;


CREATE OR REPLACE FUNCTION process_raw_wix_event() RETURNS TRIGGER AS $process_raw_wix_event$
	BEGIN
		INSERT INTO wix_store_events (
			platform,
			store_id,
			event_timestamp,
			event_id
		)
		SELECT
			NEW.platform,
			NEW.store_id,
			NEW.event_timestamp,
			NEW.event_id;
		RETURN NULL;
	END;
$process_raw_wix_event$ LANGUAGE plpgsql;

CREATE OR REPLACE TRIGGER wix_store_events
	AFTER INSERT ON raw_store_events
	FOR EACH ROW
	WHEN (NEW.platform = 'wix')
	EXECUTE FUNCTION process_raw_wix_event();


COMMIT;

