Skip to content

Commit

Permalink
Added support for PostgreSQL identity column (directus#5502)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oreilles authored May 5, 2021
1 parent d912f07 commit da1c3ed
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/schema/src/dialects/postgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export default class Postgres extends KnexPostgres implements SchemaInspector {
c.column_name,
c.column_default as default_value,
c.is_nullable,
c.data_type
c.data_type,
c.is_identity
FROM
information_schema.columns c
LEFT JOIN information_schema.tables t
Expand Down Expand Up @@ -64,9 +65,10 @@ export default class Postgres extends KnexPostgres implements SchemaInspector {

overview[column.table_name].columns[column.column_name] = {
...column,
default_value: column.default_value?.startsWith('nextval(')
? 'AUTO_INCREMENT'
: this.parseDefaultValue(column.default_value),
default_value:
column.is_identity === 'YES' || column.default_value?.startsWith('nextval(')
? 'AUTO_INCREMENT'
: this.parseDefaultValue(column.default_value),
is_nullable: column.is_nullable === 'YES',
};
}
Expand Down

0 comments on commit da1c3ed

Please sign in to comment.