drop table if exists pager_messages cascade;
create table pager_messages(
	pager_message_id serial,
	ctstamp timestamp without time zone not null default now(),
	poster_user_id integer not null references users( user_id ),
	target_user_id integer not null references users( user_id ),
	message text,
	is_target_acknowledged boolean not null default false,
	constraint pager_messages_pager_message_id_pkey primary key( pager_message_id )
);

comment on table pager_messages is 'storage of pager messages';
comment on column pager_messages.pager_message_id is 'unique id of message';
comment on column pager_messages.ctstamp is 'creation of message';
comment on column pager_messages.poster_user_id is 'reference id to users (poster user)';
comment on column pager_messages.target_user_id is 'reference id to users (target user)';
comment on column pager_messages.message is 'the pager message itself';
comment on column pager_messages.is_target_acknowledged is 'boolean flag of target acknowledged the message';

comment on constraint pager_messages_pager_message_id_pkey on pager_messages is 'unique constraint of table';
comment on constraint pager_messages_poster_user_id_fkey on pager_messages is 'foreign constraint to users table (on poster_user_id)';
comment on constraint pager_messages_target_user_id_fkey on pager_messages is 'foreign constraint to users table (on target_user_id)';
