Postgresql Database


Back to resource list

This resource manages PostgreSQL databases



  • :create - Creates the given database
  • :update - Updates the given database
  • :drop - Drops the given database
  • :delete - Alias for :drop


NameName?TypeDefaultDescriptionAllowed Values
databaseStringThe name of a database to create
ownerString, IntegerThe role name of the user who will own the new database, or DEFAULT to use the default (namely, the user executing the command). To create a database owned by another role, you must be a direct or indirect member of that role, or be a superuser.
templateStringThe name of the template from which to create the new database, or DEFAULT to use the default template (template1)
encodingIntegerCharacter set encoding to use in the new database
strategyStringStrategy to be used in creating the new database
localeStringThis is a shortcut for setting LC_COLLATE and LC_CTYPE at once
lc_collateStringCollation order (LC_COLLATE) to use in the new database. This affects the sort order applied to strings, e.g., in queries with ORDER BY, as well as the order used in indexes on text columns. The default is to use the collation order of the template database.
lc_ctypeStringCharacter classification (LC_CTYPE) to use in the new database. This affects the categorization of characters, e.g., lower, upper and digit. The default is to use the character classification of the template database.
icu_localeStringSpecifies the ICU locale ID if the ICU locale provider is used
locale_providerStringSpecifies the provider to use for the default collation in this database
collation_versionStringSpecifies the collation version string to store with the database
tablespaceStringThe name of the tablespace that will be associated with the new database
allow_connectionstrue, falseIf false then no one can connect to this database
connection_limitInteger, StringHow many concurrent connections can be made to this database. -1 (the default) means no limit.
is_templatetrue, falseIf true, then this database can be cloned by any user with CREATEDB privileges; if false (the default), then only superusers or the owner of the database can clone it.


  • PostgreSQL::Cookbook::SqlHelpers::Database


To create database named 'my_app' with owner 'user1':

postgresql_database 'my_app' do
  owner 'user1'
Was this helpful?