Dynamically adds new types to the database and adds new values to existing enums
install
npm install -S pg-type
usage
require('pg-type')()
.connString('postgres://localhost/mydb')
.types({
some_enum_type: ['val_1', 'val_2', 'val_3']
, some_other_type: { type: 'domain', as: 'int check ( value < 100 )' }
})
.create( function( error, results ){
/* Types added/modified! */
})
Then later on you end up modifying your apps types:
require('pg-type')()
.connString('postgres://localhost/mydb')
.types({
some_enum_type: ['val_1', 'val_2', 'val_3', 'val_4', 'val_5']
, some_other_type: { type: 'domain', as: 'int check ( value < 100 )' }
, some_other_type2: { type: 'domain', as: 'int check ( value > 200 )' }
})
.create( function( error, results ){
/* Types added/modified! */
})
pgtype will modify your enums (never drops) and add new types.
Pg Type creator factory
Gets or sets the connection string
Gets or mixes in types
Creates new types/enums and checks to see if enums need to be modified.
Will not remove enum values so you'll still need to use something like pg-delta for that.