Revision 853 (by ahitrov, 2026/08/20 23:19:58) Profile-coupon link and merge function
CREATE TABLE webshop_user_coupons (
	id integer DEFAULT nextval(('public.documents_id_seq'::text)::regclass) NOT NULL,
	ctime timestamp without time zone DEFAULT now() NOT NULL,
	mtime timestamp without time zone DEFAULT now() NOT NULL,
	class text DEFAULT 'webshop::ProfileCouponLink'::text NOT NULL,
	status smallint default 0 NOT NULL,
	session text,
	source_id integer,
	source_class text,
	dest_id integer,
	dest_class text default 'webshop::Coupon'::text,
	data text
);

CREATE INDEX webshop_user_coupons_session ON webshop_user_coupons USING btree (session) where session IS NOT NULL;
CREATE UNIQUE INDEX webshop_user_coupons_in_order ON webshop_user_coupons USING btree (source_id, dest_id) where source_id > 0;
create index webshop_user_coupons_source on webshop_user_coupons (source_id);
create index webshop_user_coupons_dest on webshop_user_coupons (dest_id);