create table enquesta
(
	id integer not null primary key default nextval('public.documents_id_seq'::text),
	class text not null,
	ctime timestamp not null default now(),
	mtime timestamp not null default now(),
	dtime timestamp not null default now(),
	session_id char(32),
	uid integer not null default 0,
	object_class text not null default 'promosite::Voting',
	object_id integer not null,
	status smallint not null default 0,
	sections integer[],
	name text,
	voting text,
	data text
);
create index enquesta_sections on enquesta using gist ( "sections" "gist__int_ops" );
create index enquesta_object on enquesta (object_id);
create unique index enquesta_uid_vote on enquesta (uid, object_id) where uid > 0;
create unique index enquesta_session_vote on enquesta (session_id, object_id) where session_id IS NOT NULL;
