 				on delete cascade
 				on update cascade;
 			return next 'Linked the session id to the users.';
+		end if;
+		
+		if failed_test('test_users_table_groupinvite_exists') then
+			create table users.group_invite();
+			return next 'Created the group invite table.';
+		end if;
+		if failed_test('test_users_table_groupinvite_column_link_exists') then
+			alter table users.group_invite
+				add column link uuid;
+			return next 'Added the group invite link column.';
+		end if;
+		if failed_test('test_users_table_groupinvite_column_link_is_uuid') then
+			alter table users.group_invite
+				alter column link type uuid;
+			return next 'Changed group invite link column to uuid.';
+		end if;
+		if failed_test('test_users_table_groupinvite_column_link_is_pk') then
+			alter table users.group_invite
+				add primary key (link);
+			return next 'Added the primary key to group_invite';
+		end if;
+		if failed_test('test_users_table_groupinvite_column_groupid_exists') then
+			alter table users.group_invite
+				add column group_id uuid;
+			return next 'Added the group invite groupid column.';
+		end if;
+		if failed_test('test_users_table_groupinvite_column_groupid_is_uuid') then
+			alter table users.group_invite
+				alter column group_id type uuid;
+			return next 'Changed group invite group id column to uuid.';
+		end if;
+		if failed_test('test_users_table_groupinvite_column_groupid_is_fk') then
+			alter table users.group_invite
+				add constraint invite_grpid 
+				foreign key (group_id) 
+				references users.group (id)
+				match full
+				on delete cascade
+				on update cascade;
+			return next 'Linked the group invite group id to the group id.';
+		end if;
+		if failed_test('test_users_table_groupinvite_column_userid_exists') then
+			alter table users.group_invite
+				add column user_id uuid;
+			return next 'Added the group invite userid column.';
+		end if;
+		if failed_test('test_users_table_groupinvite_column_userid_is_uuid') then
+			alter table users.group_invite
+				alter column user_id type uuid;
+			return next 'Changed group invite user id column to uuid.';
+		end if;
+		if failed_test('test_users_table_groupinvite_column_userid_is_fk') then
+			alter table users.group_invite
+				add constraint invite_usrid 
+				foreign key (user_id) 
+				references users.user (id)
+				match full
+				on delete cascade
+				on update cascade;
+			return next 'Linked the group invite user id to the user id.';
+		end if;
+		if failed_test('test_users_table_groupinvite_column_refused_exists') then
+			alter table users.group_invite
+				add column refused boolean;
+			return next 'Added the group invite refused column.';
+		end if;
+		if failed_test('test_users_table_groupinvite_column_refused_is_boolean') then
+			alter table users.group_invite
+				alter column refused type boolean;
+			return next 'Changed group invite refused column to boolean.';
+		end if;
+		if failed_test('test_users_table_groupinvite_colume_refused_has_default') then
+			alter table users.group_invite
+				alter column refused set default false;
+			return next 'Set the default for users group invite refused.';
+		end if;
+		if failed_test('test_users_table_groupinvite_column_expire_exists') then
+			alter table users.group_invite
+				add column expire timestamp with time zone;
+			return next 'Added the group invite expiration column.';
+		end if;
+		if failed_test('test_users_table_groupinvite_column_expire_is_timestamp') then
+			alter table users.group_invite
+				alter column expire type boolean;
+			return next 'Changed group invite expire column to timestamp.';
+		end if;
+		if failed_test('test_users_table_groupinvite_colume_expire_has_default') then
+			alter table users.group_invite
+				alter column expire set default now() + interval '1 month';
+			return next 'Set the default for group invite expiration.';
 		end if;
 		
 		drop trigger if exists protect_anonymous on users.user;

	end;
$test$ language plpgsql;

create or replace function correct_users()
returns setof text as $func$
	declare 

				username	text,
				passwd		text),
			users.logout(
				sessid		text),
			users.group_user_add(
				sessid		text,
				groupname	text,
				username	text)
		from public;
		
		grant execute on function 
