Skip to content

Commit

Permalink
#961 Major database update
Browse files Browse the repository at this point in the history
  • Loading branch information
Yannick committed Nov 6, 2014
1 parent 66c12e1 commit 57f7b74
Show file tree
Hide file tree
Showing 3 changed files with 313 additions and 2 deletions.
160 changes: 160 additions & 0 deletions db_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,166 @@ function stripslashes_array($array) {
if (!array_key_exists('o_private_message', $luna_config))
$db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_private_message\', \'0\')') or error('Unable to insert config value \'o_private_message\'', __FILE__, __LINE__, $db->error());

// Since 0.0.3250: Add the messages table
if (!$db->table_exists('messages')) {
$schema = array(
'FIELDS' => array(
'id' => array(
'datatype' => 'SERIAL',
'allow_null' => false
),
'shared_id' => array(
'datatype' => 'INT(10)',
'allow_null' => false,
'default' => '0'
),
'last_shared_id' => array(
'datatype' => 'INT(10)',
'allow_null' => false,
'default' => '0'
),
'last_post' => array(
'datatype' => 'INT(10)',
'allow_null' => true,
'default' => '0'
),
'last_post_id' => array(
'datatype' => 'INT(10)',
'allow_null' => true,
'default' => '0'
),
'last_poster' => array(
'datatype' => 'VARCHAR(255)',
'allow_null' => false,
'default' => '0'
),
'owner' => array(
'datatype' => 'INTEGER',
'allow_null' => false,
'default' => '0'
),
'subject' => array(
'datatype' => 'VARCHAR(255)',
'allow_null' => false
),
'message' => array(
'datatype' => 'MEDIUMTEXT',
'allow_null' => false
),
'hide_smilies' => array(
'datatype' => 'TINYINT(1)',
'allow_null' => false,
'default' => '0'
),
'show_message' => array(
'datatype' => 'TINYINT(1)',
'allow_null' => false,
'default' => '0'
),
'sender' => array(
'datatype' => 'VARCHAR(200)',
'allow_null' => false
),
'receiver' => array(
'datatype' => 'VARCHAR(200)',
'allow_null' => true
),
'sender_id' => array(
'datatype' => 'INT(10)',
'allow_null' => false,
'default' => '0'
),
'receiver_id' => array(
'datatype' => 'VARCHAR(255)',
'allow_null' => true,
'default' => '0'
),
'sender_ip' => array(
'datatype' => 'VARCHAR(39)',
'allow_null' => true
),
'posted' => array(
'datatype' => 'INT(10)',
'allow_null' => false,
),
'showed' => array(
'datatype' => 'TINYINT(1)',
'allow_null' => false,
'default' => '0'
)
),
'PRIMARY KEY' => array('id'),
);

$db->create_table('messages', $schema) or error('Unable to create messages table', __FILE__, __LINE__, $db->error());
}

// Since 0.0.3250: Add the messages table
if (!$db->table_exists('contacts')) {
$schema = array(
'FIELDS' => array(
'id' => array(
'datatype' => 'SERIAL',
'allow_null' => false
),
'user_id' => array(
'datatype' => 'INT(10)',
'allow_null' => false,
'default' => '0'
),
'contact_id' => array(
'datatype' => 'INT(10)',
'allow_null' => false,
'default' => '0'
),
'contact_name' => array(
'datatype' => 'VARCHAR(255)',
'allow_null' => false,
),
'allow_msg' => array(
'datatype' => 'TINYINT(1)',
'allow_null' => false,
'default' => '1'
)
),
'PRIMARY KEY' => array('id'),
);

$db->create_table('contacts', $schema) or error('Unable to create contacts table', __FILE__, __LINE__, $db->error());
}

// Since 0.0.3250: Add the messages table
if (!$db->table_exists('contacts')) {

This comment has been minimized.

Copy link
@Quy

Quy Nov 7, 2014

Contributor

Should be sending_lists.

$schema = array(
'FIELDS' => array(
'id' => array(
'datatype' => 'SERIAL',
'allow_null' => false
),
'user_id' => array(
'datatype' => 'INT(10)',
'allow_null' => false,
'default' => '0'
),
'array_id' => array(
'datatype' => 'VARCHAR(255)',
'allow_null' => false,
),
'name' => array(
'datatype' => 'VARCHAR(255)',
'allow_null' => false,
),
'receivers' => array(
'datatype' => 'VARCHAR(255)',
'allow_null' => false,
),
),
'PRIMARY KEY' => array('id'),
);

$db->create_table('sending_lists', $schema) or error('Unable to create sending lists table', __FILE__, __LINE__, $db->error());
}

break;

// Preparse posts
Expand Down
4 changes: 2 additions & 2 deletions include/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ class Version {
const FORUM_VERSION = '0.0.2';

// The Luna Core version
const FORUM_CORE_VERSION = '0.0.3248';
const FORUM_CORE_VERSION = '0.0.3250';

// The database version number, every change in the database requires this number to go one up
const FORUM_DB_VERSION = 84.73;
const FORUM_DB_VERSION = 85.00;

// The parser version number, every change to the parser requires this number to go one up
const FORUM_PARSER_VERSION = 10;
Expand Down
151 changes: 151 additions & 0 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,157 @@ function process_form(the_form) {
$schema['UNIQUE KEYS']['username_idx'] = array('username(25)');

$db->create_table('users', $schema) or error('Unable to create users table', __FILE__, __LINE__, $db->error());

$schema = array(
'FIELDS' => array(
'id' => array(
'datatype' => 'SERIAL',
'allow_null' => false
),
'shared_id' => array(
'datatype' => 'INT(10)',
'allow_null' => false,
'default' => '0'
),
'last_shared_id' => array(
'datatype' => 'INT(10)',
'allow_null' => false,
'default' => '0'
),
'last_post' => array(
'datatype' => 'INT(10)',
'allow_null' => true,
'default' => '0'
),
'last_post_id' => array(
'datatype' => 'INT(10)',
'allow_null' => true,
'default' => '0'
),
'last_poster' => array(
'datatype' => 'VARCHAR(255)',
'allow_null' => false,
'default' => '0'
),
'owner' => array(
'datatype' => 'INTEGER',
'allow_null' => false,
'default' => '0'
),
'subject' => array(
'datatype' => 'VARCHAR(255)',
'allow_null' => false
),
'message' => array(
'datatype' => 'MEDIUMTEXT',
'allow_null' => false
),
'hide_smilies' => array(
'datatype' => 'TINYINT(1)',
'allow_null' => false,
'default' => '0'
),
'show_message' => array(
'datatype' => 'TINYINT(1)',
'allow_null' => false,
'default' => '0'
),
'sender' => array(
'datatype' => 'VARCHAR(200)',
'allow_null' => false
),
'receiver' => array(
'datatype' => 'VARCHAR(200)',
'allow_null' => true
),
'sender_id' => array(
'datatype' => 'INT(10)',
'allow_null' => false,
'default' => '0'
),
'receiver_id' => array(
'datatype' => 'VARCHAR(255)',
'allow_null' => true,
'default' => '0'
),
'sender_ip' => array(
'datatype' => 'VARCHAR(39)',
'allow_null' => true
),
'posted' => array(
'datatype' => 'INT(10)',
'allow_null' => false,
),
'showed' => array(
'datatype' => 'TINYINT(1)',
'allow_null' => false,
'default' => '0'
)
),
'PRIMARY KEY' => array('id'),
);

$db->create_table('messages', $schema) or error('Unable to create messages table', __FILE__, __LINE__, $db->error());

$schema = array(
'FIELDS' => array(
'id' => array(
'datatype' => 'SERIAL',
'allow_null' => false
),
'user_id' => array(
'datatype' => 'INT(10)',
'allow_null' => false,
'default' => '0'
),
'contact_id' => array(
'datatype' => 'INT(10)',
'allow_null' => false,
'default' => '0'
),
'contact_name' => array(
'datatype' => 'VARCHAR(255)',
'allow_null' => false,
),
'allow_msg' => array(
'datatype' => 'TINYINT(1)',
'allow_null' => false,
'default' => '1'
)
),
'PRIMARY KEY' => array('id'),
);

$db->create_table('contacts', $schema) or error('Unable to create contacts table', __FILE__, __LINE__, $db->error());

$schema = array(
'FIELDS' => array(
'id' => array(
'datatype' => 'SERIAL',
'allow_null' => false
),
'user_id' => array(
'datatype' => 'INT(10)',
'allow_null' => false,
'default' => '0'
),
'array_id' => array(
'datatype' => 'VARCHAR(255)',
'allow_null' => false,
),
'name' => array(
'datatype' => 'VARCHAR(255)',
'allow_null' => false,
),
'receivers' => array(
'datatype' => 'VARCHAR(255)',
'allow_null' => false,
),
),
'PRIMARY KEY' => array('id'),
);

$db->create_table('sending_lists', $schema) or error('Unable to create sending lists table', __FILE__, __LINE__, $db->error());


$now = time();
Expand Down

0 comments on commit 57f7b74

Please sign in to comment.