BEGIN;


CREATE OR REPLACE FUNCTION process_raw_tiktok_event() RETURNS TRIGGER AS $process_raw_tiktok_event$
	BEGIN
		INSERT INTO tiktok_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_tiktok_event$ LANGUAGE plpgsql;

CREATE OR REPLACE TRIGGER tiktok_store_events
	AFTER INSERT ON raw_store_events
	FOR EACH ROW
	WHEN (NEW.platform = 'tiktok')
	EXECUTE FUNCTION process_raw_tiktok_event();


COMMIT;
