 # Table structure for table `permissions`
 #
 
-CREATE TABLE {$db_prefix}permissions (
-  id_group smallint(5) NOT NULL default '0',
-  permission varchar(30) NOT NULL default '',
-  add_deny tinyint(4) NOT NULL default '1',
-  PRIMARY KEY (id_group, permission)
-) ENGINE=MyISAM;
+$db_table->db_create_table('{db_prefix}permissions',
+	array(
+		array('name' => 'id_group',   'type' => 'smallint', 'size' => 5, 'default' => 0),
+		array('name' => 'permission', 'type' => 'varchar', 'size' => 30, 'default' => ''),
+		array('name' => 'add_deny',   'type' => 'tinyint', 'size' => 4, 'default' => 1),
+	),
+	array(
+		array('name' => 'group_permission', 'columns' => array('id_group', 'permission'), 'type' => 'primary'),
+	)
+);
 
 #
 # Dumping data for table `permissions`

# Table structure for table `personal_messages`
#

CREATE TABLE {$db_prefix}personal_messages (
  id_pm int(10) unsigned NOT NULL auto_increment,
  id_pm_head int(10) unsigned NOT NULL default '0',
  id_member_from mediumint(8) unsigned NOT NULL default '0',
  deleted_by_sender tinyint(3) unsigned NOT NULL default '0',
  from_name varchar(255) NOT NULL default '',
  msgtime int(10) unsigned NOT NULL default '0',
  subject varchar(255) NOT NULL default '',
  body text NOT NULL,
  PRIMARY KEY (id_pm),
  KEY id_member (id_member_from, deleted_by_sender),
  KEY msgtime (msgtime),
  KEY id_pm_head (id_pm_head)
) ENGINE=MyISAM;

#
# Table structure for table `pm_recipients`
#

CREATE TABLE {$db_prefix}pm_recipients (
  id_pm int(10) unsigned NOT NULL default '0',
  id_member mediumint(8) unsigned NOT NULL default '0',
  labels varchar(60) NOT NULL default '-1',
  bcc tinyint(3) unsigned NOT NULL default '0',
  is_read tinyint(3) unsigned NOT NULL default '0',
  is_new tinyint(3) unsigned NOT NULL default '0',
  deleted tinyint(3) unsigned NOT NULL default '0',
  PRIMARY KEY (id_pm, id_member),
  UNIQUE id_member (id_member, deleted, id_pm)
) ENGINE=MyISAM;

#
# Table structure for table `pm_rules`
#

CREATE TABLE {$db_prefix}pm_rules (
  id_rule int(10) unsigned NOT NULL auto_increment,
  id_member int(10) unsigned NOT NULL default '0',
  rule_name varchar(60) NOT NULL default '',
  criteria text NOT NULL,
  actions text NOT NULL,
  delete_pm tinyint(3) unsigned NOT NULL default '0',
  is_or tinyint(3) unsigned NOT NULL default '0',
  PRIMARY KEY (id_rule),
  KEY id_member (id_member),
  KEY delete_pm (delete_pm)
) ENGINE=MyISAM;

#
# Table structure for table `polls`
#

CREATE TABLE {$db_prefix}polls (
  id_poll mediumint(8) unsigned NOT NULL auto_increment,
  question varchar(255) NOT NULL default '',
  voting_locked tinyint(1) NOT NULL default '0',
  max_votes tinyint(3) unsigned NOT NULL default '1',
  expire_time int(10) unsigned NOT NULL default '0',
  hide_results tinyint(3) unsigned NOT NULL default '0',
  change_vote tinyint(3) unsigned NOT NULL default '0',
  guest_vote tinyint(3) unsigned NOT NULL default '0',
  num_guest_voters int(10) unsigned NOT NULL default '0',
  reset_poll int(10) unsigned NOT NULL default '0',
  id_member mediumint(8) unsigned NOT NULL default '0',
  poster_name varchar(255) NOT NULL default '',
  PRIMARY KEY (id_poll)
) ENGINE=MyISAM;

#
# Table structure for table `poll_choices`
#

CREATE TABLE {$db_prefix}poll_choices (
  id_poll mediumint(8) unsigned NOT NULL default '0',
  id_choice tinyint(3) unsigned NOT NULL default '0',
  label varchar(255) NOT NULL default '',
  votes smallint(5) unsigned NOT NULL default '0',
  PRIMARY KEY (id_poll, id_choice)
) ENGINE=MyISAM;

#
# Table structure for table `postby_emails`
#

CREATE TABLE {$db_prefix}postby_emails (
  id_email varchar(50) NOT NULL default '',
  time_sent int(10) NOT NULL default '0',
  email_to varchar(50) NOT NULL default '',
  PRIMARY KEY (id_email)
) ENGINE=MyISAM;

#
# Table structure for table `postby_emails_error`
#

CREATE TABLE {$db_prefix}postby_emails_error (
  id_email int(10) NOT NULL auto_increment,
  error varchar(255) NOT NULL default '',
  data_id varchar(255) NOT NULL default '0',
  subject varchar(255) NOT NULL default '',
  id_message int(10) NOT NULL default '0',
  id_board smallint(5) NOT NULL default '0',
  email_from varchar(50) NOT NULL default '',
  message_type char(10) NOT NULL default '',
  message mediumtext NOT NULL,
  PRIMARY KEY (id_email)
) ENGINE=MyISAM;

#
# Table structure for table `postby_emails_filters`
#

CREATE TABLE {$db_prefix}postby_emails_filters (
  id_filter int(10) NOT NULL auto_increment,
  filter_style char(5) NOT NULL default '',
  filter_type varchar(255) NOT NULL default '',
  filter_to varchar(255) NOT NULL default '',
  filter_from varchar(255) NOT NULL default '',
  filter_name varchar(255) NOT NULL default '',
  filter_order int(10) NOT NULL default '0',
  PRIMARY KEY (id_filter)
) ENGINE=MyISAM;

#
# Table structure for table `scheduled_tasks`
#

CREATE TABLE {$db_prefix}scheduled_tasks (
  id_task smallint(5) NOT NULL auto_increment,
  next_time int(10) NOT NULL default '0',
  time_offset int(10) NOT NULL default '0',
  time_regularity smallint(5) NOT NULL default '0',
  time_unit varchar(1) NOT NULL default 'h',
  disabled tinyint(3) NOT NULL default '0',
  task varchar(24) NOT NULL default '',
  PRIMARY KEY (id_task),
  KEY next_time (next_time),
  KEY disabled (disabled),
  UNIQUE task (task)
) ENGINE=MyISAM;

#
# Dumping data for table `scheduled_tasks`

# Table structure for table `members`
#

$db_table->db_create_table('{db_prefix}members',
	array(
		array('name' => 'id_member',            'type' => 'mediumint', 'size' => 8, 'unsigned' => true, 'auto' => true),
		array('name' => 'member_name',          'type' => 'varchar', 'size' => 80, 'default' => ''),
		array('name' => 'date_registered',      'type' => 'int', 'size' => 10, 'unsigned' => true, 'default' => 0),
		array('name' => 'posts',                'type' => 'mediumint', 'size' => 8, 'unsigned' => true, 'default' => 0),
		array('name' => 'id_group',             'type' => 'smallint', 'size' => 5, 'unsigned' => true, 'default' => 0),
		array('name' => 'lngfile',              'type' => 'varchar', 'size' => 255, 'default' => ''),
		array('name' => 'last_login',           'type' => 'int', 'size' => 10, 'unsigned' => true, 'default' => 0),
		array('name' => 'real_name',            'type' => 'varchar', 'size' => 255, 'default' => ''),
		array('name' => 'personal_messages',    'type' => 'smallint', 'size' => 5, 'default' => 0),
		array('name' => 'mentions',             'type' => 'smallint', 'size' => 5, 'default' => 0),
		array('name' => 'unread_messages',      'type' => 'smallint', 'size' => 5, 'default' => 0),
		array('name' => 'new_pm',               'type' => 'tinyint', 'size' => 3, 'unsigned' => true, 'default' => 0),
		array('name' => 'buddy_list',           'type' => 'text'),
		array('name' => 'pm_ignore_list',       'type' => 'varchar', 'size' => 255, 'default' => ''),
		array('name' => 'pm_prefs',             'type' => 'mediumint', 'size' => 8, 'default' => 2),
		array('name' => 'mod_prefs',            'type' => 'varchar', 'size' => 20, 'default' => ''),
		array('name' => 'message_labels',       'type' => 'text'),
		array('name' => 'passwd',               'type' => 'varchar', 'size' => 64, 'default' => ''),
		array('name' => 'openid_uri',           'type' => 'text'),
		array('name' => 'email_address',        'type' => 'varchar', 'size' => 255, 'default' => ''),
		array('name' => 'personal_text',        'type' => 'varchar', 'size' => 255, 'default' => ''),
		array('name' => 'gender',               'type' => 'tinyint', 'size' => 4, 'unsigned' => true, 'default' => 0),
		array('name' => 'birthdate',            'type' => 'date', 'default' => '0001-01-01'),
		array('name' => 'website_title',        'type' => 'varchar', 'size' => 255, 'default' => ''),
		array('name' => 'website_url',          'type' => 'varchar', 'size' => 255, 'default' => ''),
		array('name' => 'location',             'type' => 'varchar', 'size' => 255, 'default' => ''),
		array('name' => 'hide_email',           'type' => 'tinyint', 'size' => 4, 'default' => 0),
		array('name' => 'show_online',          'type' => 'tinyint', 'size' => 4, 'default' => 1),
		array('name' => 'time_format',          'type' => 'varchar', 'size' => 80, 'default' => ''),
		array('name' => 'signature',            'type' => 'text'),
		array('name' => 'time_offset',          'type' => 'float', 'default' => 0),
		array('name' => 'avatar',               'type' => 'varchar', 'size' => 255, 'default' => ''),
		array('name' => 'pm_email_notify',      'type' => 'tinyint', 'size' => 4, 'default' => 0),
		array('name' => 'karma_bad',            'type' => 'smallint', 'size' => 5, 'unsigned' => true, 'default' => 0),
		array('name' => 'karma_good',           'type' => 'smallint', 'size' => 5, 'unsigned' => true, 'default' => 0),
		array('name' => 'likes_given',          'type' => 'mediumint', 'size' => 5, 'unsigned' => true, 'default' => 0),
		array('name' => 'likes_received',       'type' => 'mediumint', 'size' => 5, 'unsigned' => true, 'default' => 0),
		array('name' => 'usertitle',            'type' => 'varchar', 'size' => 255, 'default' => ''),
		array('name' => 'notify_announcements', 'type' => 'tinyint', 'size' => 4, 'default' => 1),
		array('name' => 'notify_regularity',    'type' => 'tinyint', 'size' => 4, 'default' => 1),
		array('name' => 'notify_send_body',     'type' => 'tinyint', 'size' => 4, 'default' => 0),
		array('name' => 'notify_types',         'type' => 'tinyint', 'size' => 4, 'default' => 2),
		array('name' => 'member_ip',            'type' => 'varchar', 'size' => 255, 'default' => ''),
		array('name' => 'member_ip2',           'type' => 'varchar', 'size' => 255, 'default' => ''),
		array('name' => 'secret_question',      'type' => 'varchar', 'size' => 255, 'default' => ''),
		array('name' => 'secret_answer',        'type' => 'varchar', 'size' => 64, 'default' => ''),
		array('name' => 'id_theme',             'type' => 'tinyint', 'size' => 4, 'unsigned' => true, 'default' => 0),
		array('name' => 'is_activated',         'type' => 'tinyint', 'size' => 3, 'unsigned' => true, 'default' => 1),
		array('name' => 'validation_code',      'type' => 'varchar', 'size' => 10, 'default' => ''),
		array('name' => 'id_msg_last_visit',    'type' => 'int', 'size' => 10, 'unsigned' => true, 'default' => 0),
		array('name' => 'additional_groups',    'type' => 'varchar', 'size' => 255, 'default' => ''),
		array('name' => 'smiley_set',           'type' => 'varchar', 'size' => 48, 'default' => ''),
		array('name' => 'id_post_group',        'type' => 'smallint', 'size' => 5, 'unsigned' => true, 'default' => 0),
		array('name' => 'total_time_logged_in', 'type' => 'int', 'size' => 10, 'unsigned' => true, 'default' => 0),
		array('name' => 'password_salt',        'type' => 'varchar', 'size' => 255, 'default' => ''),
		array('name' => 'ignore_boards',        'type' => 'text'),
		array('name' => 'warning',              'type' => 'tinyint', 'size' => 4, 'default' => 0),
		array('name' => 'passwd_flood',         'type' => 'varchar', 'size' => 12, 'default' => ''),
		array('name' => 'receive_from',         'type' => 'tinyint', 'size' => 4, 'unsigned' => true, 'default' => 1),
	),
	array(
		array('name' => 'id_member',            'columns' => array('id_member'), 'type' => 'primary'),
		array('name' => 'member_name',          'columns' => array('member_name'), 'type' => 'key'),
		array('name' => 'real_name',            'columns' => array('real_name'), 'type' => 'key'),
		array('name' => 'date_registered',      'columns' => array('date_registered'), 'type' => 'key'),
		array('name' => 'id_group',             'columns' => array('id_group'), 'type' => 'key'),
		array('name' => 'birthdate',            'columns' => array('birthdate'), 'type' => 'key'),
		array('name' => 'posts',                'columns' => array('posts'), 'type' => 'key'),
		array('name' => 'last_login',           'columns' => array('last_login'), 'type' => 'key'),
		array('name' => 'lngfile',              'columns' => array('lngfile(30)'), 'type' => 'key'),
		array('name' => 'id_post_group',        'columns' => array('id_post_group'), 'type' => 'key'),
		array('name' => 'warning',              'columns' => array('warning'), 'type' => 'key'),
		array('name' => 'total_time_logged_in', 'columns' => array('total_time_logged_in'), 'type' => 'key'),
		array('name' => 'id_theme',             'columns' => array('id_theme'), 'type' => 'key'),
	)
);

#
# Table structure for table `member_logins`
#

$db_table->db_create_table('{db_prefix}member_logins',
	array(
		array('name' => 'id_login',  'type' => 'int', 'size' => 10, 'auto' => true),
		array('name' => 'id_member', 'type' => 'mediumint', 'size' => 8, 'unsigned' => true, 'default' => 0),
		array('name' => 'time',      'type' => 'int', 'size' => 10, 'default' => 0),
		array('name' => 'ip',        'type' => 'varchar', 'size' => 255, 'default' => 0),
		array('name' => 'ip2',       'type' => 'varchar', 'size' => 255, 'default' => 0),
	),
	array(
		array('name' => 'id_login',  'columns' => array('id_login'), 'type' => 'primary'),
		array('name' => 'id_member', 'columns' => array('id_member'), 'type' => 'key'),
		array('name' => 'time',      'columns' => array('time'), 'type' => 'key'),
	)
);

#
# Table structure for table `message_icons`
#

$db_table->db_create_table('{db_prefix}message_icons',
	array(
		array('name' => 'id_icon',    'type' => 'smallint', 'size' => 5, 'unsigned' => true, 'auto' => true),
		array('name' => 'title',      'type' => 'varchar', 'size' => 80, 'default' => ''),
		array('name' => 'filename',   'type' => 'varchar', 'size' => 80, 'default' => ''),
		array('name' => 'id_board',   'type' => 'smallint', 'size' => 5, 'unsigned' => true, 'default' => 0),
		array('name' => 'icon_order', 'type' => 'smallint', 'size' => 5, 'unsigned' => true, 'default' => 0),
	),
	array(
		array('name' => 'id_icon',  'columns' => array('id_icon'), 'type' => 'primary'),
		array('name' => 'id_board', 'columns' => array('id_board'), 'type' => 'key'),
	)
);

#
# Dumping data for table `message_icons`
