function(string $table)
{
if ($table = $this->tableFullName($table, true)){
if ($r = $this->rawQuery(<< 0 AND STRPOS(data_type, 'int') > 0
THEN REPLACE(REPLACE(data_type, 'integer', 'serial'), 'int', 'serial')
ELSE data_type
END
||
coalesce('(' || character_maximum_length || ')', '') ||
CASE
WHEN STRPOS(data_type, 'int') = 0 AND numeric_precision IS NOT NULL AND numeric_scale IS NOT NUll
THEN '(' || numeric_precision || ',' || numeric_scale || ')'
ELSE ''
END ||
CASE
WHEN is_nullable = 'YES' THEN ''
ELSE ' NOT NULL'
END ||
CASE
WHEN STRPOS(column_default, 'nextval') > 0 AND STRPOS(data_type, 'int') > 0
THEN ''
ELSE coalesce(' DEFAULT ' || column_default || ' ', '')
END
AS column_expr
FROM information_schema.columns
WHERE table_schema = 'public' AND table_name = '$table'
ORDER BY ordinal_position) column_list;
PGSQL
)
) {
return $r->fetch(\PDO::FETCH_ASSOC)['create_table'] ?? '';
}
}
return '';
}