Skip to content

Commit

Permalink
fix: Textual database fields now default to null
Browse files Browse the repository at this point in the history
  • Loading branch information
live627 committed Mar 13, 2021
1 parent 5a48748 commit 183eb35
Showing 1 changed file with 34 additions and 8 deletions.
42 changes: 34 additions & 8 deletions install.php
Expand Up @@ -17,27 +17,38 @@
),
array(
'name' => 'title',
'type' => 'tinytext',
'type' => 'varchar',
'size' => 150,
'default' => '',
),
array(
'name' => 'subject',
'type' => 'tinytext',
'type' => 'varchar',
'size' => 150,
'default' => '',
),
array(
'name' => 'icon',
'type' => 'tinytext',
'type' => 'varchar',
'size' => 150,
'default' => '',
),
array(
'name' => 'form_exit',
'type' => 'tinytext',
'type' => 'varchar',
'size' => 150,
'default' => '',
),
array(
'name' => 'template_function',
'type' => 'tinytext',
'type' => 'varchar',
'size' => 150,
'default' => '',
),
array(
'name' => 'output',
'type' => 'text',
'default' => '',
),
);

Expand All @@ -52,6 +63,10 @@
// Perform the table creation.
$smcFunc['db_create_table']('{db_prefix}cf_forms', $columns, $indexes, array(), 'update_remove');

foreach ($columns as $column)
if (stripos($column['type'], 'char') !== false || stripos($column['type'], 'text') !== false)
$smcFunc['db_change_column']('{db_prefix}cf_forms', $column['name'], $column);

// Set up the correct columns for the table.
$columns = array(
array(
Expand All @@ -67,19 +82,26 @@
),
array(
'name' => 'title',
'type' => 'tinytext',
'type' => 'varchar',
'size' => 150,
'default' => '',
),
array(
'name' => 'text',
'type' => 'tinytext',
'type' => 'varchar',
'size' => 150,
'default' => '',
),
array(
'name' => 'type',
'type' => 'tinytext',
'type' => 'varchar',
'size' => 150,
'default' => '',
),
array(
'name' => 'type_vars',
'type' => 'text',
'default' => '',
),
);

Expand All @@ -97,6 +119,10 @@

$smcFunc['db_create_table']('{db_prefix}cf_fields', $columns, $indexes, array(), 'update_remove');

foreach ($columns as $column)
if (stripos($column['type'], 'char') !== false || stripos($column['type'], 'text') !== false)
$smcFunc['db_change_column']('{db_prefix}cf_fields', $column['name'], $column);

// Delete any field that has the ID 0, just for version compatibility reasons.
$smcFunc['db_query']('', '
DELETE
Expand Down

0 comments on commit 183eb35

Please sign in to comment.