mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-20 00:20:44 +08:00
Fixes #1242: Gii Model generation added dropped table fields in Postgresql
This commit is contained in:
@@ -242,18 +242,17 @@ SQL;
|
|||||||
$schemaName = $this->db->quoteValue($table->schemaName);
|
$schemaName = $this->db->quoteValue($table->schemaName);
|
||||||
$sql = <<<SQL
|
$sql = <<<SQL
|
||||||
SELECT
|
SELECT
|
||||||
current_database() as table_catalog,
|
d.nspname AS table_schema,
|
||||||
d.nspname AS table_schema,
|
c.relname AS table_name,
|
||||||
c.relname AS table_name,
|
a.attname AS column_name,
|
||||||
a.attname AS column_name,
|
t.typname AS data_type,
|
||||||
t.typname AS data_type,
|
a.attlen AS character_maximum_length,
|
||||||
a.attlen AS character_maximum_length,
|
pg_catalog.col_description(c.oid, a.attnum) AS column_comment,
|
||||||
pg_catalog.col_description(c.oid, a.attnum) AS column_comment,
|
a.atttypmod AS modifier,
|
||||||
a.atttypmod AS modifier,
|
a.attnotnull = false AS is_nullable,
|
||||||
a.attnotnull = false AS is_nullable,
|
CAST(pg_get_expr(ad.adbin, ad.adrelid) AS varchar) AS column_default,
|
||||||
CAST(pg_get_expr(ad.adbin, ad.adrelid) AS varchar) AS column_default,
|
coalesce(pg_get_expr(ad.adbin, ad.adrelid) ~ 'nextval',false) AS is_autoinc,
|
||||||
coalesce(pg_get_expr(ad.adbin, ad.adrelid) ~ 'nextval',false) AS is_autoinc,
|
array_to_string((select array_agg(enumlabel) from pg_enum where enumtypid=a.atttypid)::varchar[],',') as enum_values,
|
||||||
array_to_string((select array_agg(enumlabel) from pg_enum where enumtypid=a.atttypid)::varchar[],',') as enum_values,
|
|
||||||
CASE atttypid
|
CASE atttypid
|
||||||
WHEN 21 /*int2*/ THEN 16
|
WHEN 21 /*int2*/ THEN 16
|
||||||
WHEN 23 /*int4*/ THEN 32
|
WHEN 23 /*int4*/ THEN 32
|
||||||
@@ -289,7 +288,7 @@ FROM
|
|||||||
LEFT JOIN pg_namespace d ON d.oid = c.relnamespace
|
LEFT JOIN pg_namespace d ON d.oid = c.relnamespace
|
||||||
LEFT join pg_constraint ct on ct.conrelid=c.oid and ct.contype='p'
|
LEFT join pg_constraint ct on ct.conrelid=c.oid and ct.contype='p'
|
||||||
WHERE
|
WHERE
|
||||||
a.attnum > 0
|
a.attnum > 0 and t.typename != ''
|
||||||
and c.relname = {$tableName}
|
and c.relname = {$tableName}
|
||||||
and d.nspname = {$schemaName}
|
and d.nspname = {$schemaName}
|
||||||
ORDER BY
|
ORDER BY
|
||||||
|
|||||||
Reference in New Issue
Block a user