drop table if exists users cascade;
create table users(
	user_id serial not null,
	user_name varchar(128),
	reg_tstamp timestamp without time zone not null default now(),
	email varchar(128),
	pwd varchar(64),
	hash char(32),
	contact_phone varchar(96),
	is_acknowledged boolean default false,
	is_admin_acknowledged boolean default false,
	is_deleted boolean default false,
	is_instant_sender boolean default false,
	constraint users_user_id_pkey primary key( user_id )
);

comment on table users is 'storage of users';
comment on column users.user_id is 'unique id of table';
comment on column users.user_name is 'name of the user';
comment on column users.reg_tstamp is 'registration timestamp';
comment on column users.email is 'email of the user';
comment on column users.pwd is 'password of user';
comment on column users.hash is 'hash of the user';
comment on column users.contact_phone is 'contact phone of the user';
comment on column users.is_acknowledged is 'is user acknowledged itself (opt-in email)';
comment on column users.is_admin_acknowledged is 'is user proofreaden by administrator';
comment on column users.is_deleted is 'deleted flag of user';
comment on column users.is_instant_sender is 'is user instant notification sending is available';

comment on constraint users_user_id_pkey on users is 'unique constraint of table';

create index users_pwd_ind on users( pwd );
comment on index users_pwd_ind is 'password index of user';

create index users_is_deleted_ind on users( is_deleted );
comment on index users_is_deleted_ind is 'deleted index of users';

create index users_hash_ind on users( hash );
comment on index users_hash_ind is 'hash index of users';
