drop table rtl433;
create table rtl433 (
	time timestamp without time zone,
	model text,
	id integer,
	json jsonb,
	_id serial
);

CREATE OR REPLACE FUNCTION json_fn()
  RETURNS TRIGGER AS
$func$
BEGIN
   NEW := jsonb_populate_record(NEW, NEW.json); -- or hstore alternative
   RETURN NEW;
END
$func$ LANGUAGE plpgsql;

CREATE TRIGGER json_trigger
BEFORE INSERT OR UPDATE ON rtl433 FOR EACH ROW
EXECUTE PROCEDURE json_fn();


