Code Duplication    Length = 11-13 lines in 2 locations

Sources/DbPackages-postgresql.php 2 locations

@@ 391-401 (lines=11) @@
388
		);
389
	}
390
	// Different default?
391
	if (isset($column_info['default']) && $column_info['default'] != $old_info['default'])
392
	{
393
		$action = $column_info['default'] !== null ? 'SET DEFAULT \'' . $smcFunc['db_escape_string']($column_info['default']) . '\'' : 'DROP DEFAULT';
394
		$smcFunc['db_query']('', '
395
			ALTER TABLE ' . $table_name . '
396
			ALTER COLUMN ' . $column_info['name'] . ' ' . $action,
397
			array(
398
				'security_override' => true,
399
			)
400
		);
401
	}
402
	// Is it null - or otherwise?
403
	if (isset($column_info['null']) && $column_info['null'] != $old_info['null'])
404
	{
@@ 407-419 (lines=13) @@
404
	{
405
		$action = $column_info['null'] ? 'DROP' : 'SET';
406
		$smcFunc['db_transaction']('begin');
407
		if (!$column_info['null'])
408
		{
409
			// We have to set it to something if we are making it NOT NULL. And we must comply with the current column format.
410
			$setTo = isset($column_info['default']) ? $column_info['default'] : (strpos($old_info['type'], 'int') !== false ? 0 : '');
411
			$smcFunc['db_query']('', '
412
				UPDATE ' . $table_name . '
413
				SET ' . $column_info['name'] . ' = \'' . $setTo . '\'
414
				WHERE ' . $column_info['name'] . ' IS NULL',
415
				array(
416
					'security_override' => true,
417
				)
418
			);
419
		}
420
		$smcFunc['db_query']('', '
421
			ALTER TABLE ' . $table_name . '
422
			ALTER COLUMN ' . $column_info['name'] . ' ' . $action . ' NOT NULL',